Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: working directory affects binaries even with -trimpath #33772
After #16860 was closed, I was hoping that I could build byte-for-byte identical builds regardless of what machine was used to build the binaries. At the present moment, building binaries are nearly identical regardless of the machine used, except for the following bytes:
There seems to be some type of build ID encoded into the binary.
Steps to reproduce:
Unfortunately, that command will take a while to run since it needs to build the C++
This need not block
Here's a shorter repro without needing to build
Running that above on different machines produces different binaries, even if both machines are the same host OS.
It seems that the current working directory has some affect on the build ID embedded in the binary:
Manually specifying the "-buildid" removes the last source of variability when the release binaries is built on one system or another. See golang/go#33772 (comment) Change-Id: Ibc9b8e99b5b76719735942a510570bcbf96dfea6 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/193498 Reviewed-by: Damien Neil <firstname.lastname@example.org>
I just hit the same issue -- is there somewhere this can be documented better, and/or maybe given a -reproducible flag that == "-trimpath -ldflags=-buildid="?
…y when -trimpath is set The '-trimpath' flag tells 'go build' to trim any paths from the output files that are tied to the current workspace or toolchain. When this flag is set, we do not need to include the package directory in the text hashed to construct the action ID for each package. Updates #33772 Fixes #34326 Change-Id: I20b902d2f58019709b15864ca79aa0d9255ae707 Reviewed-on: https://go-review.googlesource.com/c/go/+/195318 Run-TryBot: Jay Conrod <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Bryan C. Mills <email@example.com> (cherry picked from commit aa680c0) Reviewed-on: https://go-review.googlesource.com/c/go/+/198259 Run-TryBot: Bryan C. Mills <firstname.lastname@example.org> Reviewed-by: Jay Conrod <email@example.com>