diff options
author | Vincent Ambo <tazjin@google.com> | 2020-03-31T00·29+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-03-31T00·29+0100 |
commit | db74ffb4b1667a42ac09603d81dc81401f7b85fd (patch) | |
tree | 65b85083b8338dbef98359bad63d02e6c519e51d /nix | |
parent | eab4f0e9c09a53fbec11014a62574161b3a48d78 (diff) |
fix(nix/buildGo): Remove absolute references to GOROOT from binaries r/606
Setting the GOROOT_FINAL environment variables replaces the absolute location of the Go standard library sources in the final build artefacts with a fake location (in this case starting with go/src/...). This is despite the documentation for 'trimpath' (in 'go tool compile') stating that it would affect all source paths: That's only true for user code! I figured this out by reading through the implementation of the other 'trimpath' (in 'gob build'): https://go-review.googlesource.com/c/go/+/173345
Diffstat (limited to 'nix')
-rw-r--r-- | nix/buildGo/default.nix | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/nix/buildGo/default.nix b/nix/buildGo/default.nix index 8d790cbea2c9..03c0b2bc4b9d 100644 --- a/nix/buildGo/default.nix +++ b/nix/buildGo/default.nix @@ -57,6 +57,7 @@ let in runCommand name {} '' ${go}/bin/go tool compile -o ${name}.a -trimpath=$PWD -trimpath=${go} ${includeSources uniqueDeps} ${spaceOut srcs} mkdir -p $out/bin + export GOROOT_FINAL=go ${go}/bin/go tool link -o $out/bin/${name} -buildid nix ${xFlags x_defs} ${includeLibs uniqueDeps} ${name}.a ''; |