cmd/link: establish dependable package initialization order

(This is a retry of CL 462035 which was reverted at 474976.
The only change from that CL is the aix fix SRODATA->SNOPTRDATA
at inittask.go:141)

As described here:

https://github.com/golang/go/issues/31636#issuecomment-493271830

"Find the lexically earliest package that is not initialized yet,
but has had all its dependencies initialized, initialize that package,
 and repeat."

Simplify the runtime a bit, by just computing the ordering required
in the linker and giving a list to the runtime.

Update #31636
Fixes #57411

RELNOTE=yes

Change-Id: I28c09451d6aa677d7394c179d23c2c02c503fc56
Reviewed-on: https://go-review.googlesource.com/c/go/+/478916
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Keith Randall 2023-01-12 20:25:39 -08:00
parent d4bcfe4e83
commit 2b92c39fe0
14 changed files with 324 additions and 56 deletions

View file

@ -119,6 +119,10 @@ type ArchSyms struct {
DynStr loader.Sym
unreachableMethod loader.Sym
// Symbol containing a list of all the inittasks that need
// to be run at startup.
mainInittasks loader.Sym
}
// mkArchSym is a helper for setArchSyms, to set up a special symbol.