Repository navigation
Closed as duplicate
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
Go version
go version go1.25.5 X:nodwarf5 linux/amd64
Output of go env in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/res/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/res/.config/go/env'
GOEXE=''
GOEXPERIMENT='nodwarf5'
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1033279940=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/res/.local/share/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/res/.local/share/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/res/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.5 X:nodwarf5'
GOWORK=''
PKG_CONFIG='pkg-config'What did you do?
Using the same example code listed on #75253 on both linux/386 and linux/amd64
- Build a single shared library
- Build a cgo application that links against that library
- Remove the cache directory (
~/.cache/go-build/) - Build the same cgo application again using the same shared library
What did you see happen?
The .note.go.buildid and subsequently the .note.gnu.build-id sections of the ELF file will be different.
What did you expect to see?
Given the same library, source files, build path, and build arguments that the output binary should be the same.
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
- StatusShow more project fieldsDone
Activity
StaticRocket commentedon Jan 17, 2026
Only related issue I could find was this, but it was platform specific. This seems to be a platform agnostic issue now.
#56896
[-]x/build: reproducible builds with cgo[/-][+]cmd/compile: reproducible builds with cgo[/+]StaticRocket commentedon Jan 18, 2026
Hm. Apparently this issue is conditional on some external factor? I tested this with
go version go1.25.5 X:nodwarf5 linux/amd64on another machine and the binary was reproducible.The only difference between the two
go envoutputs is theGOGCCFLAGS, where one is-ffile-prefix-map=/tmp/go-build2479072616=/tmp/go-buildand the other is-ffile-prefix-map=/tmp/go-build1033279940=/tmp/go-build. I don't think that should have any bearing on build ID thought.StaticRocket commentedon Jan 20, 2026
Alright. I zeroed in on the 386 version of this issue, using Yocto's reproducible build selftest to make sure I'm not going crazy. Dumping the hashes for every stage and forcing the build to be single threaded I can see that the first hash to change is:
Followed almost immediately by:
This causes the runtime hash to change and from there I assume it cascades.
A few lines of context around these changes
A:
B:
ianlancetaylor commentedon Jan 20, 2026
I wonder if those are the first packages in the build to import the unsafe package.
Not that I know why that would matter.
StaticRocket commentedon Jan 21, 2026
Going to go ahead and attach the full compilation logs for both the A and B test for 386 for anyone who wants to poke around.
a.txt
b.txt
StaticRocket commentedon Jan 21, 2026
On amd64 the build makes it much further before any discrepancies, but a late
runtime/cgoimport still has a different hash.a-amd64.txt
b-amd64.txt
StaticRocket commentedon Jan 22, 2026
Huh. Is this a typo in the documentation?
go/src/cmd/go/internal/work/buildid.go
Lines 50 to 52 in 2d37c20
Looking into the build cache for the amd64 result I can see that the output of the cgo build step did actually result in a different
OutputID.This appears to be because
cgo_ldflags are being included in the binary, and that includes thefile-prefix-mapamong other incorrect linker arguments that included build paths. So this was actually just Yocto being weird. Sorry for the false flag.StaticRocket commentedon Jan 22, 2026
Now, they site the following bug for why they need the prefix-maps in the LDFLAGS to begin with:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101473
StaticRocket commentedon Jan 23, 2026
Now duplicate of: #77086
bitbake.conf: remove DEBUG_PREFIX_MAP from TARGET_LDFLAGS
bitbake.conf: remove DEBUG_PREFIX_MAP from TARGET_LDFLAGS
bitbake.conf: remove DEBUG_PREFIX_MAP from TARGET_LDFLAGS
bitbake.conf: remove DEBUG_PREFIX_MAP from TARGET_LDFLAGS
bitbake.conf: remove DEBUG_PREFIX_MAP from TARGET_LDFLAGS