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
··· 72 72 sed -i '/TestResolveTCPAddr/areturn' src/net/tcp_test.go 73 73 sed -i '/TestResolveUDPAddr/areturn' src/net/udp_test.go 74 74 75 + sed -i '/TestCgoExternalThreadSIGPROF/areturn' src/runtime/crash_cgo_test.go 76 + 75 77 touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd 76 78 ''; 77 79
+13 -3
pkgs/development/compilers/go/1.5.nix
··· 1 1 { stdenv, lib, fetchurl, tzdata, iana_etc, go_1_4, runCommand 2 2 , perl, which, pkgconfig, patch 3 3 , pcre 4 - , Security }: 4 + , Security, Foundation }: 5 5 6 6 let 7 7 goBootstrap = runCommand "go-bootstrap" {} '' ··· 25 25 # perl is used for testing go vet 26 26 nativeBuildInputs = [ perl which pkgconfig patch ]; 27 27 buildInputs = [ pcre ]; 28 - propagatedBuildInputs = lib.optional stdenv.isDarwin Security; 28 + propagatedBuildInputs = lib.optionals stdenv.isDarwin [ 29 + Security Foundation 30 + ]; 29 31 30 32 # I'm not sure what go wants from its 'src', but the go installation manual 31 33 # describes an installation keeping the src. ··· 67 69 '' + lib.optionalString stdenv.isLinux '' 68 70 sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go 69 71 '' + lib.optionalString stdenv.isDarwin '' 72 + substituteInPlace src/race.bash --replace \ 73 + "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true 74 + sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go 70 75 sed -i 's,"/etc","'"$TMPDIR"'",' src/os/os_test.go 71 76 sed -i 's,/_go_os_test,'"$TMPDIR"'/_go_os_test,' src/os/path_test.go 72 77 sed -i '/TestRead0/areturn' src/os/os_test.go 73 78 sed -i '/TestSystemRoots/areturn' src/crypto/x509/root_darwin_test.go 79 + 80 + sed -i '/TestDisasmExtld/areturn' src/cmd/objdump/objdump_test.go 74 81 75 82 touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd 76 83 ''; ··· 78 85 patches = [ 79 86 ./cacert-1.5.patch 80 87 ./remove-tools-1.5.patch 81 - ]; 88 + ] 89 + # -ldflags=-s is required to compile on Darwin, see 90 + # https://github.com/golang/go/issues/11994 91 + ++ stdenv.lib.optional stdenv.isDarwin ./strip.patch; 82 92 83 93 GOOS = if stdenv.isDarwin then "darwin" else "linux"; 84 94 GOARCH = if stdenv.isDarwin then "amd64"
+12
pkgs/development/compilers/go/strip.patch
··· 1 + diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go 2 + index 0b14725..a7608ce 100644 3 + --- a/src/cmd/go/build.go 4 + +++ b/src/cmd/go/build.go 5 + @@ -2310,6 +2310,7 @@ func (gcToolchain) ld(b *builder, root *action, out string, allactions []*action 6 + } 7 + } 8 + var ldflags []string 9 + + ldflags = append(ldflags, "-s") 10 + if buildContext.InstallSuffix != "" { 11 + ldflags = append(ldflags, "-installsuffix", buildContext.InstallSuffix) 12 + }
+2 -4
pkgs/top-level/all-packages.nix
··· 4053 4053 }; 4054 4054 4055 4055 go_1_5 = callPackage ../development/compilers/go/1.5.nix { 4056 - inherit (darwin.apple_sdk.frameworks) Security; 4056 + inherit (darwin.apple_sdk.frameworks) Security Foundation; 4057 4057 }; 4058 4058 4059 - go = if stdenv.isDarwin 4060 - then go_1_4 # missing DWARF files during go-1.5 build 4061 - else go_1_5; 4059 + go = go_1_5; 4062 4060 4063 4061 go-repo-root = goPackages.go-repo-root.bin // { outputs = [ "bin" ]; }; 4064 4062