From 45001d3b429bb9341f5c5a0c70cc9856b70a3f8e Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Fri, 7 Mar 2025 01:41:31 +0800 Subject: [PATCH 1/2] runtime/internal: clean up completely We've been slowly moving packages from runtime/internal to internal/runtime. For now, runtime/internal only has test packages. It's a good change to clean up the references to runtime/internal in the toolchain. Change-Id: I35c2e86b73d86bd17b58cc74c0682bde1c970a90 --- src/cmd/dist/test.go | 2 +- src/cmd/go/internal/load/pkg.go | 2 +- src/cmd/internal/objabi/pkgspecial.go | 2 +- src/cmd/link/internal/ld/data.go | 3 +-- .../internal => internal/runtime}/startlinetest/func_amd64.go | 0 .../internal => internal/runtime}/startlinetest/func_amd64.s | 0 .../internal => internal/runtime}/wasitest/host_test.go | 0 .../internal => internal/runtime}/wasitest/nonblock_test.go | 0 .../internal => internal/runtime}/wasitest/tcpecho_test.go | 0 .../runtime}/wasitest/testdata/nonblock.go | 0 .../runtime}/wasitest/testdata/tcpecho.go | 0 src/net/file_wasip1_test.go | 2 +- src/runtime/atomic_pointer.go | 4 ++-- src/runtime/panic.go | 2 +- src/runtime/pprof/protomem_test.go | 3 --- src/runtime/preempt.go | 1 - src/runtime/start_line_amd64_test.go | 2 +- 17 files changed, 9 insertions(+), 14 deletions(-) rename src/{runtime/internal => internal/runtime}/startlinetest/func_amd64.go (100%) rename src/{runtime/internal => internal/runtime}/startlinetest/func_amd64.s (100%) rename src/{runtime/internal => internal/runtime}/wasitest/host_test.go (100%) rename src/{runtime/internal => internal/runtime}/wasitest/nonblock_test.go (100%) rename src/{runtime/internal => internal/runtime}/wasitest/tcpecho_test.go (100%) rename src/{runtime/internal => internal/runtime}/wasitest/testdata/nonblock.go (100%) rename src/{runtime/internal => internal/runtime}/wasitest/testdata/tcpecho.go (100%) diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 6199dbbb93cdcc..a380e46c5dadd4 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -926,7 +926,7 @@ func (t *tester) registerTests() { t.registerTest("wasip1 host tests", &goTest{ variant: "host", - pkg: "runtime/internal/wasitest", + pkg: "internal/runtime/wasitest", timeout: 1 * time.Minute, runOnHost: true, }) diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 0c4639ce82c321..825b299dd71624 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -3540,7 +3540,7 @@ func SelectCoverPackages(roots []*Package, match []func(*Package) bool, op strin // $GOROOT/src/internal/coverage/pkid.go dealing with // hard-coding of runtime package IDs. cmode := cfg.BuildCoverMode - if cfg.BuildRace && p.Standard && (p.ImportPath == "runtime" || strings.HasPrefix(p.ImportPath, "runtime/internal")) { + if cfg.BuildRace && p.Standard && (p.ImportPath == "runtime") { cmode = "regonly" } diff --git a/src/cmd/internal/objabi/pkgspecial.go b/src/cmd/internal/objabi/pkgspecial.go index 871c28f58829ab..118d2d412678d0 100644 --- a/src/cmd/internal/objabi/pkgspecial.go +++ b/src/cmd/internal/objabi/pkgspecial.go @@ -92,7 +92,7 @@ var allowAsmABIPkgs = []string{ "internal/bytealg", "internal/chacha8rand", "internal/runtime/syscall", - "runtime/internal/startlinetest", + "internal/runtime/startlinetest", } // LookupPkgSpecial returns special build properties for the given package path. diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index 0fd3bacd2fb454..67ee71bab31939 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -78,8 +78,7 @@ func isRuntimeDepPkg(pkg string) bool { "unsafe": return true } - return (strings.HasPrefix(pkg, "runtime/internal/") || strings.HasPrefix(pkg, "internal/runtime/")) && - !strings.HasSuffix(pkg, "_test") + return strings.HasPrefix(pkg, "internal/runtime/") && !strings.HasSuffix(pkg, "_test") } // Estimate the max size needed to hold any new trampolines created for this function. This diff --git a/src/runtime/internal/startlinetest/func_amd64.go b/src/internal/runtime/startlinetest/func_amd64.go similarity index 100% rename from src/runtime/internal/startlinetest/func_amd64.go rename to src/internal/runtime/startlinetest/func_amd64.go diff --git a/src/runtime/internal/startlinetest/func_amd64.s b/src/internal/runtime/startlinetest/func_amd64.s similarity index 100% rename from src/runtime/internal/startlinetest/func_amd64.s rename to src/internal/runtime/startlinetest/func_amd64.s diff --git a/src/runtime/internal/wasitest/host_test.go b/src/internal/runtime/wasitest/host_test.go similarity index 100% rename from src/runtime/internal/wasitest/host_test.go rename to src/internal/runtime/wasitest/host_test.go diff --git a/src/runtime/internal/wasitest/nonblock_test.go b/src/internal/runtime/wasitest/nonblock_test.go similarity index 100% rename from src/runtime/internal/wasitest/nonblock_test.go rename to src/internal/runtime/wasitest/nonblock_test.go diff --git a/src/runtime/internal/wasitest/tcpecho_test.go b/src/internal/runtime/wasitest/tcpecho_test.go similarity index 100% rename from src/runtime/internal/wasitest/tcpecho_test.go rename to src/internal/runtime/wasitest/tcpecho_test.go diff --git a/src/runtime/internal/wasitest/testdata/nonblock.go b/src/internal/runtime/wasitest/testdata/nonblock.go similarity index 100% rename from src/runtime/internal/wasitest/testdata/nonblock.go rename to src/internal/runtime/wasitest/testdata/nonblock.go diff --git a/src/runtime/internal/wasitest/testdata/tcpecho.go b/src/internal/runtime/wasitest/testdata/tcpecho.go similarity index 100% rename from src/runtime/internal/wasitest/testdata/tcpecho.go rename to src/internal/runtime/wasitest/testdata/tcpecho.go diff --git a/src/net/file_wasip1_test.go b/src/net/file_wasip1_test.go index 4f4259069d1f73..91f57eecdacf6e 100644 --- a/src/net/file_wasip1_test.go +++ b/src/net/file_wasip1_test.go @@ -20,7 +20,7 @@ import ( // socket extensions with the net package using net.FileConn/net.FileListener. // // Note that the creation of net.Conn and net.Listener values for TCP sockets -// has an end-to-end test in src/runtime/internal/wasitest, here we are only +// has an end-to-end test in src/internal/runtime/wasitest, here we are only // verifying the code paths specific to UDP, and error handling for invalid use // of the functions. diff --git a/src/runtime/atomic_pointer.go b/src/runtime/atomic_pointer.go index df067ede77f8eb..311ef7d0bda300 100644 --- a/src/runtime/atomic_pointer.go +++ b/src/runtime/atomic_pointer.go @@ -49,7 +49,7 @@ func atomicstorep(ptr unsafe.Pointer, new unsafe.Pointer) { atomic.StorepNoWB(noescape(ptr), new) } -// atomic_storePointer is the implementation of runtime/internal/UnsafePointer.Store +// atomic_storePointer is the implementation of internal/runtime/atomic.UnsafePointer.Store // (like StoreNoWB but with the write barrier). // //go:nosplit @@ -58,7 +58,7 @@ func atomic_storePointer(ptr *unsafe.Pointer, new unsafe.Pointer) { atomicstorep(unsafe.Pointer(ptr), new) } -// atomic_casPointer is the implementation of runtime/internal/UnsafePointer.CompareAndSwap +// atomic_casPointer is the implementation of internal/runtime/atomic.UnsafePointer.CompareAndSwap // (like CompareAndSwapNoWB but with the write barrier). // //go:nosplit diff --git a/src/runtime/panic.go b/src/runtime/panic.go index c31cfd6e1aeff4..07a96a237b8876 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -59,7 +59,7 @@ func panicCheck1(pc uintptr, msg string) { throw(msg) } // TODO: is this redundant? How could we be in malloc - // but not in the runtime? runtime/internal/*, maybe? + // but not in the runtime? internal/runtime/*, maybe? gp := getg() if gp != nil && gp.m != nil && gp.m.mallocing != 0 { throw(msg) diff --git a/src/runtime/pprof/protomem_test.go b/src/runtime/pprof/protomem_test.go index 4d08e67ddc7540..43f4d3efe1c9e8 100644 --- a/src/runtime/pprof/protomem_test.go +++ b/src/runtime/pprof/protomem_test.go @@ -275,9 +275,6 @@ func TestHeapRuntimeFrames(t *testing.T) { if strings.Contains(l, "internal/runtime/") { t.Errorf("Sample got %s, want no runtime frames", l) } - if strings.Contains(l, "runtime/internal/") { - t.Errorf("Sample got %s, want no runtime frames", l) - } if strings.Contains(l, "mapassign") { // in case mapassign moves to a package not matching above paths. t.Errorf("Sample got %s, want no mapassign frames", l) } diff --git a/src/runtime/preempt.go b/src/runtime/preempt.go index 839f3875be318b..c41c3558359c0c 100644 --- a/src/runtime/preempt.go +++ b/src/runtime/preempt.go @@ -418,7 +418,6 @@ func isAsyncSafePoint(gp *g, pc, sp, lr uintptr) (bool, uintptr) { u, uf := newInlineUnwinder(f, pc) name := u.srcFunc(uf).name() if stringslite.HasPrefix(name, "runtime.") || - stringslite.HasPrefix(name, "runtime/internal/") || stringslite.HasPrefix(name, "internal/runtime/") || stringslite.HasPrefix(name, "reflect.") { // For now we never async preempt the runtime or diff --git a/src/runtime/start_line_amd64_test.go b/src/runtime/start_line_amd64_test.go index 305ed0b126621f..0b4807ad154c39 100644 --- a/src/runtime/start_line_amd64_test.go +++ b/src/runtime/start_line_amd64_test.go @@ -5,7 +5,7 @@ package runtime_test import ( - "runtime/internal/startlinetest" + "internal/runtime/startlinetest" "testing" ) From fad32e2e81d11508e734c3c3d3b0c1da583f89f5 Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Fri, 7 Mar 2025 08:58:27 +0800 Subject: [PATCH 2/2] 2 Change-Id: I41b8b98c9e57afe65848edfc50af7a56d73dce88 --- src/cmd/go/internal/load/pkg.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 825b299dd71624..95ddb670306101 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -3540,7 +3540,7 @@ func SelectCoverPackages(roots []*Package, match []func(*Package) bool, op strin // $GOROOT/src/internal/coverage/pkid.go dealing with // hard-coding of runtime package IDs. cmode := cfg.BuildCoverMode - if cfg.BuildRace && p.Standard && (p.ImportPath == "runtime") { + if cfg.BuildRace && p.Standard && p.ImportPath == "runtime" { cmode = "regonly" }