Skip to content

Commit

Permalink
build: make go buildid static (#30342)
Browse files Browse the repository at this point in the history
The previous clearing of buildid did fully work, turns out we need to
set it in `ldflags`

The go buildid is the only remaining hurdle for reproducible builds, see
ethereum/go-ethereum#28987 (comment)

This PR changes the go build id application note to say literally `none`

golang/go#33772 (comment):

> This difference is due to the .note.go.buildid section added by the
linker. It can be set to something static e.g. -ldflags=-buildid= (empty
string) to gain reproducibility.
  • Loading branch information
holiman authored and ucwong committed Aug 23, 2024
1 parent 98827bd commit 37effed
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ func doInstall(cmdline []string) {
// buildFlags returns the go tool flags for building.
func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (flags []string) {
var ld []string
// See https://github.com/golang/go/issues/33772#issuecomment-528176001
// We need to set --buildid to the linker here, and also pass --build-id to the
// cgo-linker further down.
ld = append(ld, "--buildid=none")
if env.Commit != "" {
ld = append(ld, "-X", "main.gitCommit="+env.Commit)
ld = append(ld, "-X", "main.gitDate="+env.Date)
Expand Down

0 comments on commit 37effed

Please sign in to comment.