From db74ffb4b1667a42ac09603d81dc81401f7b85fd Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 31 Mar 2020 01:29:35 +0100 Subject: fix(nix/buildGo): Remove absolute references to GOROOT from binaries 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 --- nix/buildGo/default.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'nix/buildGo') diff --git a/nix/buildGo/default.nix b/nix/buildGo/default.nix index 8d790cbea2..03c0b2bc4b 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 ''; -- cgit 1.4.1