-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/link: allow deriving GNU build ID from Go build ID ID #61469
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
Conversation
5f79f18
to
12264b2
Compare
This PR (HEAD: 12264b2) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/511475. Important tips:
|
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Than McIntosh: Patch Set 1: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Gopher Robot: Patch Set 1: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Cherry Mui: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Patrick Steinhardt: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Cherry Mui: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
12264b2
to
0360328
Compare
This PR (HEAD: 0360328) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/511475. Important tips:
|
Message from Patrick Steinhardt: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Cherry Mui: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Patrick Steinhardt: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Cherry Mui: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
0360328
to
3106d49
Compare
This PR (HEAD: 3106d49) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/511475. Important tips:
|
Message from Patrick Steinhardt: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Ian Lance Taylor: Patch Set 3: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Gopher Robot: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Gopher Robot: Patch Set 3: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Cherry Mui: Patch Set 3: (5 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
3106d49
to
a49faea
Compare
This PR (HEAD: a49faea) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/511475. Important tips:
|
Message from Patrick Steinhardt: Patch Set 4: (5 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Patrick Steinhardt: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Patrick Steinhardt: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Michael Pratt: Patch Set 6: Code-Review+1 Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Go LUCI: Patch Set 6: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2023-09-08T14:22:51Z","revision":"27873d87bb08c58422b861f749b97a8ee1bb397d"} Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Michael Pratt: Patch Set 6: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Go LUCI: Patch Set 6: This CL has failed the run. Reason: Tryjob golang/try/gotip-linux-amd64-newinliner has failed Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Go LUCI: Patch Set 6: LUCI-TryBot-Result-1 Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Cherry Mui: Patch Set 6: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
a49faea
to
82e19d2
Compare
This PR (HEAD: 82e19d2) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/511475. Important tips:
|
Message from Patrick Steinhardt: Patch Set 6: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Cherry Mui: Patch Set 7: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Go LUCI: Patch Set 7: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2023-09-15T15:37:56Z","revision":"a243f0b4c3ce721fd131b84a593d9c818ff42942"} Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Cherry Mui: Patch Set 7: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Go LUCI: Patch Set 7: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Go LUCI: Patch Set 7: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Cherry Mui: Patch Set 7: Code-Review+2 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
While it is possible to embed a GNU build ID into the linked executable by passing `-B 0xBUILDID` to the linker, the build ID will need to be precomputed by the build system somehow. This makes it unnecessarily complex to generate a deterministic build ID as it either requires the build system to hash all inputs manually or to build the binary twice, once to compute its hash and once with the GNU build ID derived from that hash. Despite being complex, it is also inefficient as it requires the build system to duplicate some of the work that the Go linker already performs anyway. Introduce a new argument "gobuildid" that can be passed to `-B` that causes the linker to automatically derive the GNU build ID from the Go build ID. Given that the Go build ID is deterministically computed from all of its inputs, the resulting GNU build ID should be deterministic in the same way, which is the desired behaviour. Furthermore, given that the `-B` flag currently requires a "0x" prefix for all values passed to it, using "gobuildid" as value is a backwards compatible change. An alternative would be to unconditionally calculate the GNU build ID unless otherwise specified. This would require some larger rework though because building the Go toolchain would not converge anymore due the GNU build ID changing on every stage, which in turn would cause the Go build ID to change as well. Fixes golang#41004
82e19d2
to
5483305
Compare
This PR (HEAD: 5483305) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/511475. Important tips:
|
Message from Patrick Steinhardt: Patch Set 7: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Cherry Mui: Patch Set 8: Code-Review+2 Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Go LUCI: Patch Set 8: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2023-09-18T16:12:26Z","revision":"3671c830cd4dbc274e57a857628b16793e7680a7"} Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
While it is possible to embed a GNU build ID into the linked executable by passing `-B 0xBUILDID` to the linker, the build ID will need to be precomputed by the build system somehow. This makes it unnecessarily complex to generate a deterministic build ID as it either requires the build system to hash all inputs manually or to build the binary twice, once to compute its hash and once with the GNU build ID derived from that hash. Despite being complex, it is also inefficient as it requires the build system to duplicate some of the work that the Go linker already performs anyway. Introduce a new argument "gobuildid" that can be passed to `-B` that causes the linker to automatically derive the GNU build ID from the Go build ID. Given that the Go build ID is deterministically computed from all of its inputs, the resulting GNU build ID should be deterministic in the same way, which is the desired behaviour. Furthermore, given that the `-B` flag currently requires a "0x" prefix for all values passed to it, using "gobuildid" as value is a backwards compatible change. An alternative would be to unconditionally calculate the GNU build ID unless otherwise specified. This would require some larger rework though because building the Go toolchain would not converge anymore due the GNU build ID changing on every stage, which in turn would cause the Go build ID to change as well. Fixes #41004 Change-Id: I707c5fc321749c00761643d6cc79d44bf2cd744d GitHub-Last-Rev: 5483305 GitHub-Pull-Request: #61469 Reviewed-on: https://go-review.googlesource.com/c/go/+/511475 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Message from Cherry Mui: Patch Set 8: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Go LUCI: Patch Set 8: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
Message from Go LUCI: Patch Set 8: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/511475. |
This PR is being closed because golang.org/cl/511475 has been merged. |
While it is possible to embed a GNU build ID into the linked
executable by passing
-B 0xBUILDID
to the linker, the build ID willneed to be precomputed by the build system somehow. This makes it
unnecessarily complex to generate a deterministic build ID as it
either requires the build system to hash all inputs manually or to
build the binary twice, once to compute its hash and once with the GNU
build ID derived from that hash. Despite being complex, it is also
inefficient as it requires the build system to duplicate some of the
work that the Go linker already performs anyway.
Introduce a new argument "gobuildid" that can be passed to
-B
thatcauses the linker to automatically derive the GNU build ID from the Go
build ID. Given that the Go build ID is deterministically computed
from all of its inputs, the resulting GNU build ID should be
deterministic in the same way, which is the desired behaviour.
Furthermore, given that the
-B
flag currently requires a "0x" prefixfor all values passed to it, using "gobuildid" as value is a backwards
compatible change.
An alternative would be to unconditionally calculate the GNU build ID
unless otherwise specified. This would require some larger rework
though because building the Go toolchain would not converge anymore
due the GNU build ID changing on every stage, which in turn would
cause the Go build ID to change as well.
Fixes #41004