diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2020-11-30 00:01:26 -0800 |
|---|---|---|
| committer | Matthew Dempsky <mdempsky@google.com> | 2020-12-01 01:26:28 +0000 |
| commit | 0f9f27287b6eaac1634248e325aaab848e0dfd55 (patch) | |
| tree | eecef0d14ca1fdc8779dce007e9f00e8734493bc /src/cmd/compile/internal/gc/init.go | |
| parent | 41ad4dec991c11d9e1efff27fc0b1568f5981c9c (diff) | |
| download | go-git-0f9f27287b6eaac1634248e325aaab848e0dfd55.tar.gz | |
[dev.regabi] cmd/compile: remove types.InitSyms
It's not types's responsibility to understand how package
initialization is implemented. Instead, have gc keep track of the
order that packages were imported, and then look for inittask
declarations.
Also, use resolve to force importing of the inittask's export data, so
that we can get the appropriate linker symbol index. (This is also why
this CL doesn't satisfy "toolstash -cmp".)
Change-Id: I5b706497d4a8d1c4439178863b4a8dba4da0f5a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/274006
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/gc/init.go')
| -rw-r--r-- | src/cmd/compile/internal/gc/init.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/gc/init.go b/src/cmd/compile/internal/gc/init.go index ed0218c0e2..b5fd2e7c75 100644 --- a/src/cmd/compile/internal/gc/init.go +++ b/src/cmd/compile/internal/gc/init.go @@ -27,6 +27,9 @@ func renameinit() *types.Sym { return s } +// List of imported packages, in source code order. See #31636. +var sourceOrderImports []*types.Pkg + // fninit makes an initialization record for the package. // See runtime/proc.go:initTask for its layout. // The 3 tasks for initialization are: @@ -40,8 +43,15 @@ func fninit(n []ir.Node) { var fns []*obj.LSym // functions to call for package initialization // Find imported packages with init tasks. - for _, s := range types.InitSyms { - deps = append(deps, s.Linksym()) + for _, pkg := range sourceOrderImports { + n := resolve(ir.AsNode(pkg.Lookup(".inittask").Def)) + if n == nil { + continue + } + if n.Op() != ir.ONAME || n.Class() != ir.PEXTERN { + base.Fatalf("bad inittask: %v", n) + } + deps = append(deps, n.Sym().Linksym()) } // Make a function that contains all the initialization statements. |
