Merge pull request #50223 from ryan4729/go-cross-compile

go: make compiler usable for cross compiles
This commit is contained in:
John Ericson 2018-11-11 18:31:44 -05:00 committed by GitHub
commit c94ccfd81e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -131,14 +131,17 @@ stdenv.mkDerivation rec {
substituteInPlace "src/cmd/link/internal/ld/lib.go" --replace dsymutil ${llvm}/bin/llvm-dsymutil
'';
GOOS = if stdenv.isDarwin then "darwin" else "linux";
GOARCH = if stdenv.isDarwin then "amd64"
else if stdenv.targetPlatform.isi686 then "386"
else if stdenv.targetPlatform.isx86_64 then "amd64"
else if stdenv.targetPlatform.isAarch32 then "arm"
else if stdenv.targetPlatform.isAarch64 then "arm64"
else throw "Unsupported system";
GOARM = toString (stdenv.lib.intersectLists [(stdenv.targetPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
GOOS = stdenv.hostPlatform.parsed.kernel.name;
GOARCH = {
"i686" = "386";
"x86_64" = "amd64";
"aarch64" = "arm64";
"arm" = "arm";
"armv5tel" = "arm";
"armv6l" = "arm";
"armv7l" = "arm";
}.${stdenv.hostPlatform.parsed.cpu.name} or (throw "Unsupported system");
GOARM = toString (stdenv.lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]);
GO386 = 387; # from Arch: don't assume sse2 on i686
CGO_ENABLED = 1;
GOROOT_BOOTSTRAP = "${goBootstrap}/share/go";