]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/obj: make aix/ppc64 builds reproducible
authorRuss Cox <rsc@golang.org>
Tue, 13 Jun 2023 02:56:23 +0000 (22:56 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 13 Jun 2023 18:59:19 +0000 (18:59 +0000)
commitccf75b36ff884c5a6839be143dd4366824c85aca
tree90fff100c3b0b561db98b1eadb0911fd4cfb691c
parent8b5ed3cdaeba621687c71c19174bb4db0f5713f0
cmd/internal/obj: make aix/ppc64 builds reproducible

sort.Slice was being used to sort some newly added entries by name
to make the ctxt.Data slice reproducible, but some existing entries
have the same name, and the effect was to take the non-determinism
of the tail entries and scatter it into the earlier, deterministic section
when multiple entries had the same name.

The specific entries with the same name are type SDWARFVAR, which
all have an empty name but different relocations. If they are shuffled,
then the relocation symbols are visited in a different order, which
enters them into the string table in a different order, which results in
different object files, different object file hashes, and different build IDs
for the final executables.

Use sort.SliceStable to avoid reordering entries we don't mean to reorder.

Also add a simple test for scheduling-related non-determinism.
I debugged this originally using 'go install -race cmd/compile',
but that was slow and turned out not to be terribly reliable.
Using a few different GOMAXPROCS settings turns out to be a much more
effective (and faster) way to scramble scheduling decisions.

Fixes #60759.

Change-Id: Ia966b02b9fdaefa971f998a09319ca375bdf8604
Reviewed-on: https://go-review.googlesource.com/c/go/+/502755
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/go/testdata/script/repro_build.txt [new file with mode: 0644]
src/cmd/internal/obj/sym.go