build: schedule package initialization in Go order - #2254
Conversation
LLGo baseline benchmarks
Program measurements
Core language and compiler benchmarks
No main baseline exists yet; all metrics are marked Warning
|
There was a problem hiding this comment.
Review summary
Reviewed the substantive changes (package-init ordering + unconditional main. symbol prefix); the large set of cl/_testdata, cl/_testgo, cl/_testrt, and cl/_testmeta updates are mechanical fixture regenerations from the symbol rename and were not individually reviewed.
The change is well-structured and well-tested:
packageInitOrder(Kahn's toposort, ready packages picked by lexicographically-smallest import path) matches Go's cross-package initialization contract, and thetest/go/package_init_order_test.gointegration probe (b,z,a) plusmain_module_test.goassertions pin the observable ordering.- The
RewriteMainPrefixflag removal is complete and consistent — no dangling references remain acrossflags.go,build.go,abi.go, andllgenf.go— andmain_module.go:107now adds apkg.Types != nilguard that the base version lacked. - In
ModeTestthe computedpackageInitsare intentionally not appended; dependency inits still run transitively via the test main's guardedinit, so this is not a dropped-init bug.
No bugs, regressions, security, or performance concerns found. The O(n^2) selection loop in packageInitOrder is fine at build-time scale. One minor maintainability note inline.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
d822bf8 to
fac2e9e
Compare
Summary
..inittaskheader from the synthetic entry module for compiler-internal linkname compatibilitycl.PkgSkipsInitnoinit.goandissue31636.goxfails, plus stale Darwininit1.goxfailsThe ordering is computed globally at final link time. This avoids the tempting but incorrect fix of sorting only direct imports: the added
a -> z, independentb, shared tracker regression requiresb, z, a, whereas sorted DFS would producez, a, b. Existing guarded package init functions make the pre-scheduled calls idempotent when the root init later reaches its direct imports.Validation
go test ./internal/build -count=1go test ./internal/build ./test/goroot -count=1 -timeout=15mgo test -vet=off ./test/go -run ^TestPackageInitializationUsesLexicalReadyOrder$ -count=1 -timeout=10mpackageInitOrderandlinkedPackageInitNamesboth 100%init1.go+noinit.gowith the normal xfail fileinit1.go,noinit.go, andfixedbugs/issue31636.gowith the normal xfail filego test ./test/gowithout-vet=offstill hits the pre-existing Go 1.26 vendoredprintfanalyzer panic; the same command fails on unchanged main.