Repository navigation
buildGoModule: always set -buildid= as ldflag - #276685
Merged
Merged
Conversation
katexochen
force-pushed
the
buildGoModule/buildid
branch
from
December 25, 2023 11:30
ef05acc to
ea8a179
Compare
Contributor
|
Please also set diff --git a/pkgs/build-support/go/package.nix b/pkgs/build-support/go/package.nix
index 7e099b76f0b7..55c8c1390b5b 100644
--- a/pkgs/build-support/go/package.nix
+++ b/pkgs/build-support/go/package.nix
@@ -37,6 +37,8 @@
, CGO_ENABLED ? go.CGO_ENABLED
+, ldflags ? [ ]
+
# needed for buildFlags{,Array} warning
, buildFlags ? ""
, buildFlagsArray ? ""
@@ -91,6 +93,9 @@ let
GOARM = toString (lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
+ # If not set to an explicit value, set the buildid empty for reproducibility.
+ ldflags = ldflags ++ lib.optionals (!lib.any (lib.hasPrefix "-buildid=") ldflags) [ "-buildid=" ];
+
configurePhase = args.configurePhase or (''
runHook preConfigure
|
katexochen
force-pushed
the
buildGoModule/buildid
branch
from
December 26, 2023 08:23
ea8a179 to
9487240
Compare
Signed-off-by: Paul Meyer <[email protected]>
from buildGoModules invocations This is now always set by buildGoModule.
katexochen
force-pushed
the
buildGoModule/buildid
branch
from
December 28, 2023 09:01
9487240 to
77d6ba8
Compare
zowoq
approved these changes
Dec 30, 2023
2 of 13 tasks
Member
Author
|
@zowoq do we need an additional review or can this be merged? |
1 of 13 tasks
1 of 13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
The
buildidin Go depends on the source path, even iftrimpathis set. It is mostly used as cache key to detect whether a binary needs to be rebuild or not (a use case with no importance for nixpkgs). For improving build reproducibility, we should always set it to an empty value. This is especially interesting for content-addressed builds.For more background on
buildid, seeThis PR
buildGoModuleadd-buildid=to ldflags when not explicitly set-buildid=is still explicitly setbuildidto another value where required-buildid=from pkgsldflagsto be a list, where it previously could also be set as string. The only affected pkg wasgofumpt.Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.