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:
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.
return s
}
-// List of .inittask entries in imported packages, in source code order.
-var InitSyms []*Sym
-
// LookupOK looks up name in pkg and reports whether it previously existed.
func (pkg *Pkg) LookupOK(name string) (s *Sym, existed bool) {
// TODO(gri) remove this check in favor of specialized lookup
Name: name,
Pkg: pkg,
}
- if name == ".inittask" {
- InitSyms = append(InitSyms, s)
- }
pkg.Syms[name] = s
return s, false
}