From: Cherry Zhang Date: Sat, 12 Oct 2019 05:07:31 +0000 (-0400) Subject: [dev.link] cmd/internal/obj: sort ctxt.Data on AIX X-Git-Tag: go1.14beta1~292^2^2~58 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c9f633487b6279ff17f1c0b50ccf6bd685e78656;p=gostls13.git [dev.link] cmd/internal/obj: sort ctxt.Data on AIX On AIX, TOC symbols may be created and added to ctxt.Data concurrently. To ensure reproducible builds, sort ctxt.Data. This implements the same logic as WriteObjFile does for old object files. Change-Id: I2e6e2d7755352848981544a4fb68b828a188c2ca Reviewed-on: https://go-review.googlesource.com/c/go/+/201021 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: Than McIntosh --- diff --git a/src/cmd/internal/obj/sym.go b/src/cmd/internal/obj/sym.go index e72ec3e701..39d294183d 100644 --- a/src/cmd/internal/obj/sym.go +++ b/src/cmd/internal/obj/sym.go @@ -37,6 +37,7 @@ import ( "fmt" "log" "math" + "sort" ) func Linknew(arch *LinkArch) *Link { @@ -167,6 +168,16 @@ func (ctxt *Link) NumberSyms(asm bool) { return } + if ctxt.Headtype == objabi.Haix { + // Data must be sorted to keep a constant order in TOC symbols. + // As they are created during Progedit, two symbols can be switched between + // two different compilations. Therefore, BuildID will be different. + // TODO: find a better place and optimize to only sort TOC symbols + sort.Slice(ctxt.Data, func(i, j int) bool { + return ctxt.Data[i].Name < ctxt.Data[j].Name + }) + } + ctxt.pkgIdx = make(map[string]int32) ctxt.defs = []*LSym{} ctxt.nonpkgdefs = []*LSym{}