go-1.5: fix build on darwin, set to default version for all platforms

Changed files
+29 -7
pkgs
development
compilers
top-level
+2
pkgs/development/compilers/go/1.4.nix
···
sed -i '/TestResolveTCPAddr/areturn' src/net/tcp_test.go
sed -i '/TestResolveUDPAddr/areturn' src/net/udp_test.go
+
sed -i '/TestCgoExternalThreadSIGPROF/areturn' src/runtime/crash_cgo_test.go
+
touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd
'';
+13 -3
pkgs/development/compilers/go/1.5.nix
···
{ stdenv, lib, fetchurl, tzdata, iana_etc, go_1_4, runCommand
, perl, which, pkgconfig, patch
, pcre
-
, Security }:
+
, Security, Foundation }:
let
goBootstrap = runCommand "go-bootstrap" {} ''
···
# perl is used for testing go vet
nativeBuildInputs = [ perl which pkgconfig patch ];
buildInputs = [ pcre ];
-
propagatedBuildInputs = lib.optional stdenv.isDarwin Security;
+
propagatedBuildInputs = lib.optionals stdenv.isDarwin [
+
Security Foundation
+
];
# I'm not sure what go wants from its 'src', but the go installation manual
# describes an installation keeping the src.
···
'' + lib.optionalString stdenv.isLinux ''
sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go
'' + lib.optionalString stdenv.isDarwin ''
+
substituteInPlace src/race.bash --replace \
+
"sysctl machdep.cpu.extfeatures | grep -qv EM64T" true
+
sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go
sed -i 's,"/etc","'"$TMPDIR"'",' src/os/os_test.go
sed -i 's,/_go_os_test,'"$TMPDIR"'/_go_os_test,' src/os/path_test.go
sed -i '/TestRead0/areturn' src/os/os_test.go
sed -i '/TestSystemRoots/areturn' src/crypto/x509/root_darwin_test.go
+
+
sed -i '/TestDisasmExtld/areturn' src/cmd/objdump/objdump_test.go
touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd
'';
···
patches = [
./cacert-1.5.patch
./remove-tools-1.5.patch
-
];
+
]
+
# -ldflags=-s is required to compile on Darwin, see
+
# https://github.com/golang/go/issues/11994
+
++ stdenv.lib.optional stdenv.isDarwin ./strip.patch;
GOOS = if stdenv.isDarwin then "darwin" else "linux";
GOARCH = if stdenv.isDarwin then "amd64"
+12
pkgs/development/compilers/go/strip.patch
···
+
diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go
+
index 0b14725..a7608ce 100644
+
--- a/src/cmd/go/build.go
+
+++ b/src/cmd/go/build.go
+
@@ -2310,6 +2310,7 @@ func (gcToolchain) ld(b *builder, root *action, out string, allactions []*action
+
}
+
}
+
var ldflags []string
+
+ ldflags = append(ldflags, "-s")
+
if buildContext.InstallSuffix != "" {
+
ldflags = append(ldflags, "-installsuffix", buildContext.InstallSuffix)
+
}
+2 -4
pkgs/top-level/all-packages.nix
···
};
go_1_5 = callPackage ../development/compilers/go/1.5.nix {
-
inherit (darwin.apple_sdk.frameworks) Security;
+
inherit (darwin.apple_sdk.frameworks) Security Foundation;
};
-
go = if stdenv.isDarwin
-
then go_1_4 # missing DWARF files during go-1.5 build
-
else go_1_5;
+
go = go_1_5;
go-repo-root = goPackages.go-repo-root.bin // { outputs = [ "bin" ]; };