Skip to content
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

cmd/link: -B gobuildid doesn't work when building the toolchain itself #63934

Open
znkr opened this issue Nov 3, 2023 · 2 comments
Open

cmd/link: -B gobuildid doesn't work when building the toolchain itself #63934

znkr opened this issue Nov 3, 2023 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@znkr
Copy link
Contributor

znkr commented Nov 3, 2023

This is a follow up to #41004 which added support for -B gobuildid to cmd/link. Unfortunately, this doesn't work when building the toolchain itself.

What version of Go are you using (go version)?

tip

What did you do?

 % GO_LDFLAGS="-B gobuildid" ./make.bash

What did you expect to see?

A successful build producing Go toolchain binaries that have .note.gnu.build-id ELF section.

What did you see instead?

 % GO_LDFLAGS="-B gobuildid" ./make.bash
Building Go cmd/dist using /usr/lib/google-golang. (go1.22-20230729-RC00 cl/552016856 +457721cd52 X:fieldtrack,bo
ringcrypto linux/amd64)
Building Go toolchain1 using /usr/lib/google-golang.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for linux/amd64.
HASH[moduleIndex]
HASH[moduleIndex]: "devel go1.22-eca5a97340 Tue Sep 19 05:51:26 2023 +0000"
HASH[moduleIndex]: "modroot [RECACTED]/dev/go/src/cmd\n"
...
HASH[moduleIndex]: "file template.go 2023-09-19 12:37:51.569044164 +0000 UTC 7335\n"
HASH[moduleIndex]: 5cf632a5d0cc7bcf669b75b3abc54664c46ea44ca853a3d5812f5efccf086406
cmd/link true
go tool dist: unexpected stale targets reported by  [RECACTED]/dev/go/pkg/tool/linux_amd64/go_bootstrap list -gcflags="" -ldflags="-B gobuildid" for [cmd/asm cmd/cgo cmd/compile cmd/link] (consider rerunning with GOMAXPROCS=1 GODEBUG=gocachehash=1):
        STALE cmd/asm: stale dependency: internal/goarch
        STALE cmd/cgo: stale dependency: internal/goarch
        STALE cmd/compile: stale dependency: internal/goarch
        STALE cmd/link: stale dependency: internal/goarch
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Nov 3, 2023
@cherrymui
Copy link
Member

cherrymui commented Nov 3, 2023

This is known, and we went back and forth a few times in CL https://go.dev/cl/511475 , and that is partly the reason we don't always do this (if -B is not otherwise set).

The issue is that the GNU build ID, being part of the toolchain binary, is considered as input for the next compilation. So there is a convergence problem. There are probably ways to solve it, and we've discussed a lot on the CL. But it needs more thoughts.

If you really want it, maybe you can do go install -ldflags=-B=gobuildid cmd/... after make.bash. That will make the standard library packages become stale and will need rebuild at the next compilation, but that is probably okay.

@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 3, 2023
@cherrymui cherrymui added this to the Unplanned milestone Nov 3, 2023
@znkr
Copy link
Contributor Author

znkr commented Feb 19, 2024

Thanks Cherry. I gave that a spin, but ran into new issues after trying that and gave up. In the end, I solved it by specifying a fixed build id that's overridden with the hash sum of the binary in a separate step after make.bash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants