-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: value of -buildmode in buildinfo can differ from what is used in build ID #63559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The line that puts this data in the cache ID is here: And the logic for the embedded buildinfo is here: That said, the embedded logic seems off too: on some platforms, And the logic for whether to set Either way, this needs a careful test for platforms that default to PIE executables. |
If a binary is built using
Should we record the
|
When go/src/cmd/go/internal/work/init.go Line 236 in c7ea996
This change causes go/src/cmd/go/internal/work/init.go Line 201 in 5993251
subsequently affecting the build id: go/src/cmd/go/internal/work/exec.go Line 212 in 5993251
I'm wondering if this behavior aligns with the expected functionality. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Built two binaries from identical source code, passing
-buildmode=default
to the first and-buildmode=exe
to the second.What did you expect to see?
Both binaries should be identical and have the same hash.
What did you see instead?
The binaries hashes differed, though using
xbindiff
showed that the build ID was the only difference between them. It seems that the buildmode that is actually used is included in binaries build information (exe
in both cases), but the exact value of-buildmode
as passed togo build
is used when creating the build ID. To make reproducing binaries easier I think the same buildmode value that is used in the embedded build information should be used when creating the build ID.Currently it can be very difficult to tell what value of
-buildmode
was passed at build time when you only have a Go binary and no information on its build process. This change would make it easier to reproduce Go binaries using the embedded build information as a guide.The text was updated successfully, but these errors were encountered: