@@ -1,7 +1,7 @@
11{ stdenv, lib, fetchurl, tzdata, iana_etc, go_1_4, runCommand
22, perl, which, pkgconfig, patch
33, pcre
4−, Security }:
4+, Security, Foundation }:
55
66let
77 goBootstrap = runCommand "go-bootstrap" {} ''
@@ -25,7 +25,9 @@ stdenv.mkDerivation rec {
2525 # perl is used for testing go vet
2626 nativeBuildInputs = [ perl which pkgconfig patch ];
2727 buildInputs = [ pcre ];
28− propagatedBuildInputs = lib.optional stdenv.isDarwin Security;
28+ propagatedBuildInputs = lib.optionals stdenv.isDarwin [
29+ Security Foundation
30+ ];
2931
3032 # I'm not sure what go wants from its 'src', but the go installation manual
3133 # describes an installation keeping the src.
@@ -67,18 +69,26 @@ stdenv.mkDerivation rec {
6769 '' + lib.optionalString stdenv.isLinux ''
6870 sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go
6971 '' + 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
7075 sed -i 's,"/etc","'"$TMPDIR"'",' src/os/os_test.go
7176 sed -i 's,/_go_os_test,'"$TMPDIR"'/_go_os_test,' src/os/path_test.go
7277 sed -i '/TestRead0/areturn' src/os/os_test.go
7378 sed -i '/TestSystemRoots/areturn' src/crypto/x509/root_darwin_test.go
7479
80+ sed -i '/TestDisasmExtld/areturn' src/cmd/objdump/objdump_test.go
81+
7582 touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd
7683 '';
7784
7885 patches = [
7986 ./cacert-1.5.patch
8087 ./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;
8292
8393 GOOS = if stdenv.isDarwin then "darwin" else "linux";
8494 GOARCH = if stdenv.isDarwin then "amd64"