-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: executables built with -trimpath
are not reproducible with development Go toolchains unless -ldflags
removes -buildid=
#59525
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
-trimpath
are not reproducible on Windows unless -ldflags
removes -buildid=
-trimpath
are not reproducible on Windows unless -ldflags
removes -buildid=
The build IDs in unversioned copies of Go include a hash of the compiler binary to incorporate the semantics of the compiler somehow (the version string is assumed good enough in a versioned copy, although that's only true if you don't modify the files in your versioned checkout), so this is working as expected. |
We saw this behavior with 1.20.3 as well, not running tip. |
Er, would that version string include the host operating system too? |
Shouldn't, no. But maybe on 1.20.3 the build-ID depends on the |
-trimpath
are not reproducible on Windows unless -ldflags
removes -buildid=
-trimpath
are not reproducible with development Go toolchains unless -ldflags
removes -buildid=
Sure, let me find a working commit first :)
|
For Go 1.20 you have the default GOARM discrepancy on Linux vs Windows, so I'm not sure how you'd have gotten far enough that -ldflags=-buildid= would help. |
@jrick, you'll want to |
FWIW, creating a VERSION file that says 'go1.999' and then doing
is known to produce the same binaries on Linux and Windows, because that's a subset of what we were testing in #58884, which no one was able to break. It's possible something has broken since then, but unlikely. I believe that if you:
You should get identical output on any machine you run this on. The output is a hash of the overall distribution archive, which includes test2json as well as all the other binaries. |
Can I leave out the 2nd time line?
|
What git commit are you building? That failure would happen if you were building an old (circa Go 1.20) copy of the source tree instead of a recent copy of the master branch. |
Master (267b50a) |
Oops! I confused myself about what is and is not checked in. The -distpack flag and the support for the 'time' line were still pending. I just submitted the CL seconds ago. You need 1635205 or later. Sorry. |
This comment was marked as outdated.
This comment was marked as outdated.
Ignore that i hid that last comment. I saw different build hashes with |
Great! Closing this issue, and we can work on geth in #59500. |
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?
GOOS=windows CGO_ENABLED=0 go install -trimpath cmd/test2json
using a Windows build of the Go toolchain and a Linux build of the Go toolchain checked out at the same commit.What did you expect to see?
Since the two Go toolchains are built from the same source code, and they are both targeting the same platform, and neither should be using an external compiler or linker, the resulting binaries should be identical.
What did you see instead?
The binaries are only identical if I also pass
-ldflags=all=-buildid=
.Adding the
-x
flag to thego install
command confirms thatcmd/go
is passing different-buildid
flags in the two configurations.The text was updated successfully, but these errors were encountered: