lol

go_1_15: init at 1.15beta1 (#91463)

authored by

Colin and committed by
GitHub
b71423ae 29c073f6

+401
+252
pkgs/development/compilers/go/1.15.nix
··· 1 + { stdenv, fetchurl, tzdata, iana-etc, runCommand 2 + , perl, which, pkgconfig, patch, procps, pcre, cacert, Security, Foundation 3 + , mailcap, runtimeShell 4 + , buildPackages, pkgsTargetTarget 5 + , fetchpatch 6 + }: 7 + 8 + let 9 + 10 + inherit (stdenv.lib) optionals optionalString; 11 + 12 + goBootstrap = runCommand "go-bootstrap" {} '' 13 + mkdir $out 14 + cp -rf ${buildPackages.go_bootstrap}/* $out/ 15 + chmod -R u+w $out 16 + find $out -name "*.c" -delete 17 + cp -rf $out/bin/* $out/share/go/bin/ 18 + ''; 19 + 20 + goarch = platform: { 21 + "i686" = "386"; 22 + "x86_64" = "amd64"; 23 + "aarch64" = "arm64"; 24 + "arm" = "arm"; 25 + "armv5tel" = "arm"; 26 + "armv6l" = "arm"; 27 + "armv7l" = "arm"; 28 + }.${platform.parsed.cpu.name} or (throw "Unsupported system"); 29 + 30 + in 31 + 32 + stdenv.mkDerivation rec { 33 + pname = "go"; 34 + version = "1.15beta1"; 35 + 36 + src = fetchurl { 37 + url = "https://dl.google.com/go/go${version}.src.tar.gz"; 38 + sha256 = "1h1sg6j9jac5bw2pjrd13bf4nr18prs89147izdhzbhp896sikbq"; 39 + }; 40 + 41 + # perl is used for testing go vet 42 + nativeBuildInputs = [ perl which pkgconfig patch procps ]; 43 + buildInputs = [ cacert pcre ] 44 + ++ optionals stdenv.isLinux [ stdenv.cc.libc.out ] 45 + ++ optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ]; 46 + 47 + depsTargetTargetPropagated = optionals stdenv.isDarwin [ Security Foundation ]; 48 + 49 + hardeningDisable = [ "all" ]; 50 + 51 + prePatch = '' 52 + patchShebangs ./ # replace /bin/bash 53 + 54 + # This source produces shell script at run time, 55 + # and thus it is not corrected by patchShebangs. 56 + substituteInPlace misc/cgo/testcarchive/carchive_test.go \ 57 + --replace '#!/usr/bin/env bash' '#!${runtimeShell}' 58 + 59 + # Patch the mimetype database location which is missing on NixOS. 60 + # but also allow static binaries built with NixOS to run outside nix 61 + sed -i 's,\"/etc/mime.types,"${mailcap}/etc/mime.types\"\,\n\t&,' src/mime/type_unix.go 62 + 63 + # Disabling the 'os/http/net' tests (they want files not available in 64 + # chroot builds) 65 + rm src/net/{listen,parse}_test.go 66 + rm src/syscall/exec_linux_test.go 67 + 68 + # !!! substituteInPlace does not seems to be effective. 69 + # The os test wants to read files in an existing path. Just don't let it be /usr/bin. 70 + sed -i 's,/usr/bin,'"`pwd`", src/os/os_test.go 71 + sed -i 's,/bin/pwd,'"`type -P pwd`", src/os/os_test.go 72 + # Fails on aarch64 73 + sed -i '/TestFallocate/aif true \{ return\; \}' src/cmd/link/internal/ld/fallocate_test.go 74 + # Skip this test since ssl patches mess it up. 75 + sed -i '/TestLoadSystemCertsLoadColonSeparatedDirs/aif true \{ return\; \}' src/crypto/x509/root_unix_test.go 76 + # Disable another PIE test which breaks. 77 + sed -i '/TestTrivialPIE/aif true \{ return\; \}' misc/cgo/testshared/shared_test.go 78 + # Disable the BuildModePie test 79 + sed -i '/TestBuildmodePIE/aif true \{ return\; \}' src/cmd/go/go_test.go 80 + # Disable the unix socket test 81 + sed -i '/TestShutdownUnix/aif true \{ return\; \}' src/net/net_test.go 82 + # Disable the hostname test 83 + sed -i '/TestHostname/aif true \{ return\; \}' src/os/os_test.go 84 + # ParseInLocation fails the test 85 + sed -i '/TestParseInSydney/aif true \{ return\; \}' src/time/format_test.go 86 + # Remove the api check as it never worked 87 + sed -i '/src\/cmd\/api\/run.go/ireturn nil' src/cmd/dist/test.go 88 + # Remove the coverage test as we have removed this utility 89 + sed -i '/TestCoverageWithCgo/aif true \{ return\; \}' src/cmd/go/go_test.go 90 + # Remove the timezone naming test 91 + sed -i '/TestLoadFixed/aif true \{ return\; \}' src/time/time_test.go 92 + # Remove disable setgid test 93 + sed -i '/TestRespectSetgidDir/aif true \{ return\; \}' src/cmd/go/internal/work/build_test.go 94 + # Remove cert tests that conflict with NixOS's cert resolution 95 + sed -i '/TestEnvVars/aif true \{ return\; \}' src/crypto/x509/root_unix_test.go 96 + # TestWritevError hangs sometimes 97 + sed -i '/TestWritevError/aif true \{ return\; \}' src/net/writev_test.go 98 + # TestVariousDeadlines fails sometimes 99 + sed -i '/TestVariousDeadlines/aif true \{ return\; \}' src/net/timeout_test.go 100 + 101 + sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go 102 + sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_unix.go 103 + 104 + # Disable cgo lookup tests not works, they depend on resolver 105 + rm src/net/cgo_unix_test.go 106 + 107 + '' + optionalString stdenv.isLinux '' 108 + # prepend the nix path to the zoneinfo files but also leave the original value for static binaries 109 + # that run outside a nix server 110 + sed -i 's,\"/usr/share/zoneinfo/,"${tzdata}/share/zoneinfo/\"\,\n\t&,' src/time/zoneinfo_unix.go 111 + 112 + '' + optionalString stdenv.isAarch32 '' 113 + echo '#!${runtimeShell}' > misc/cgo/testplugin/test.bash 114 + '' + optionalString stdenv.isDarwin '' 115 + substituteInPlace src/race.bash --replace \ 116 + "sysctl machdep.cpu.extfeatures | grep -qv EM64T" true 117 + sed -i 's,strings.Contains(.*sysctl.*,true {,' src/cmd/dist/util.go 118 + sed -i 's,"/etc","'"$TMPDIR"'",' src/os/os_test.go 119 + sed -i 's,/_go_os_test,'"$TMPDIR"'/_go_os_test,' src/os/path_test.go 120 + 121 + sed -i '/TestChdirAndGetwd/aif true \{ return\; \}' src/os/os_test.go 122 + sed -i '/TestCredentialNoSetGroups/aif true \{ return\; \}' src/os/exec/exec_posix_test.go 123 + sed -i '/TestRead0/aif true \{ return\; \}' src/os/os_test.go 124 + sed -i '/TestSystemRoots/aif true \{ return\; \}' src/crypto/x509/root_darwin_test.go 125 + 126 + sed -i '/TestGoInstallRebuildsStalePackagesInOtherGOPATH/aif true \{ return\; \}' src/cmd/go/go_test.go 127 + sed -i '/TestBuildDashIInstallsDependencies/aif true \{ return\; \}' src/cmd/go/go_test.go 128 + 129 + sed -i '/TestDisasmExtld/aif true \{ return\; \}' src/cmd/objdump/objdump_test.go 130 + 131 + sed -i 's/unrecognized/unknown/' src/cmd/link/internal/ld/lib.go 132 + 133 + # TestCurrent fails because Current is not implemented on Darwin 134 + sed -i 's/TestCurrent/testCurrent/g' src/os/user/user_test.go 135 + sed -i 's/TestLookup/testLookup/g' src/os/user/user_test.go 136 + 137 + touch $TMPDIR/group $TMPDIR/hosts $TMPDIR/passwd 138 + ''; 139 + 140 + patches = [ 141 + ./remove-tools-1.11.patch 142 + ./ssl-cert-file-1.15.patch 143 + ./remove-test-pie-1.15.patch 144 + ./creds-test.patch 145 + ./go-1.9-skip-flaky-19608.patch 146 + ./go-1.9-skip-flaky-20072.patch 147 + ./skip-external-network-tests-1.15.patch 148 + ./skip-nohup-tests.patch 149 + ./skip-cgo-tests-1.15.patch 150 + ] ++ [ 151 + # breaks under load: https://github.com/golang/go/issues/25628 152 + (if stdenv.isAarch32 153 + then ./skip-test-extra-files-on-aarch32-1.14.patch 154 + else ./skip-test-extra-files-on-386-1.14.patch) 155 + ]; 156 + 157 + postPatch = '' 158 + find . -name '*.orig' -exec rm {} ';' 159 + ''; 160 + 161 + GOOS = stdenv.targetPlatform.parsed.kernel.name; 162 + GOARCH = goarch stdenv.targetPlatform; 163 + # GOHOSTOS/GOHOSTARCH must match the building system, not the host system. 164 + # Go will nevertheless build a for host system that we will copy over in 165 + # the install phase. 166 + GOHOSTOS = stdenv.buildPlatform.parsed.kernel.name; 167 + GOHOSTARCH = goarch stdenv.buildPlatform; 168 + 169 + # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those 170 + # to be different from CC/CXX 171 + CC_FOR_TARGET = if (stdenv.buildPlatform != stdenv.targetPlatform) then 172 + "${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}cc" 173 + else 174 + null; 175 + CXX_FOR_TARGET = if (stdenv.buildPlatform != stdenv.targetPlatform) then 176 + "${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}c++" 177 + else 178 + null; 179 + 180 + GOARM = toString (stdenv.lib.intersectLists [(stdenv.hostPlatform.parsed.cpu.version or "")] ["5" "6" "7"]); 181 + GO386 = 387; # from Arch: don't assume sse2 on i686 182 + CGO_ENABLED = 1; 183 + # Hopefully avoids test timeouts on Hydra 184 + GO_TEST_TIMEOUT_SCALE = 3; 185 + 186 + # Indicate that we are running on build infrastructure 187 + # Some tests assume things like home directories and users exists 188 + GO_BUILDER_NAME = "nix"; 189 + 190 + GOROOT_BOOTSTRAP="${goBootstrap}/share/go"; 191 + 192 + postConfigure = '' 193 + export GOCACHE=$TMPDIR/go-cache 194 + # this is compiled into the binary 195 + export GOROOT_FINAL=$out/share/go 196 + 197 + export PATH=$(pwd)/bin:$PATH 198 + 199 + # Independent from host/target, CC should produce code for the building system. 200 + export CC=${buildPackages.stdenv.cc}/bin/cc 201 + ulimit -a 202 + ''; 203 + 204 + postBuild = '' 205 + (cd src && ./make.bash) 206 + ''; 207 + 208 + doCheck = stdenv.hostPlatform == stdenv.targetPlatform && !stdenv.isDarwin; 209 + 210 + checkPhase = '' 211 + runHook preCheck 212 + (cd src && HOME=$TMPDIR GOCACHE=$TMPDIR/go-cache ./run.bash --no-rebuild) 213 + runHook postCheck 214 + ''; 215 + 216 + preInstall = '' 217 + rm -r pkg/obj 218 + # Contains the wrong perl shebang when cross compiling, 219 + # since it is not used for anything we can deleted as well. 220 + rm src/regexp/syntax/make_perl_groups.pl 221 + '' + (if (stdenv.buildPlatform != stdenv.hostPlatform) then '' 222 + mv bin/*_*/* bin 223 + rmdir bin/*_* 224 + ${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' 225 + rm -rf pkg/${GOHOSTOS}_${GOHOSTARCH} pkg/tool/${GOHOSTOS}_${GOHOSTARCH} 226 + ''} 227 + '' else if (stdenv.hostPlatform != stdenv.targetPlatform) then '' 228 + rm -rf bin/*_* 229 + ${optionalString (!(GOHOSTARCH == GOARCH && GOOS == GOHOSTOS)) '' 230 + rm -rf pkg/${GOOS}_${GOARCH} pkg/tool/${GOOS}_${GOARCH} 231 + ''} 232 + '' else ""); 233 + 234 + installPhase = '' 235 + runHook preInstall 236 + mkdir -p $GOROOT_FINAL 237 + cp -a bin pkg src lib misc api doc $GOROOT_FINAL 238 + ln -s $GOROOT_FINAL/bin $out/bin 239 + runHook postInstall 240 + ''; 241 + 242 + disallowedReferences = [ goBootstrap ]; 243 + 244 + meta = with stdenv.lib; { 245 + branch = "1.15"; 246 + homepage = "http://golang.org/"; 247 + description = "The Go Programming language"; 248 + license = licenses.bsd3; 249 + maintainers = teams.golang.members; 250 + platforms = platforms.linux ++ platforms.darwin; 251 + }; 252 + }
+34
pkgs/development/compilers/go/remove-test-pie-1.15.patch
··· 1 + diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go 2 + index e1cd4965c3..66bf980fc6 100644 3 + --- a/src/cmd/dist/test.go 4 + +++ b/src/cmd/dist/test.go 5 + @@ -584,29 +584,6 @@ func (t *tester) registerTests() { 6 + }) 7 + } 8 + 9 + - // Test internal linking of PIE binaries where it is supported. 10 + - if t.internalLinkPIE() { 11 + - t.tests = append(t.tests, distTest{ 12 + - name: "pie_internal", 13 + - heading: "internal linking of -buildmode=pie", 14 + - fn: func(dt *distTest) error { 15 + - t.addCmd(dt, "src", t.goTest(), "reflect", "-buildmode=pie", "-ldflags=-linkmode=internal", t.timeout(60)) 16 + - return nil 17 + - }, 18 + - }) 19 + - // Also test a cgo package. 20 + - if t.cgoEnabled && t.internalLink() { 21 + - t.tests = append(t.tests, distTest{ 22 + - name: "pie_internal_cgo", 23 + - heading: "internal linking of -buildmode=pie", 24 + - fn: func(dt *distTest) error { 25 + - t.addCmd(dt, "src", t.goTest(), "os/user", "-buildmode=pie", "-ldflags=-linkmode=internal", t.timeout(60)) 26 + - return nil 27 + - }, 28 + - }) 29 + - } 30 + - } 31 + - 32 + // sync tests 33 + if goos != "js" { // js doesn't support -cpu=10 34 + t.tests = append(t.tests, distTest{
+13
pkgs/development/compilers/go/skip-cgo-tests-1.15.patch
··· 1 + diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go 2 + index e1cd4965c3..0980d044df 100644 3 + --- a/src/cmd/dist/test.go 4 + +++ b/src/cmd/dist/test.go 5 + @@ -1136,7 +1136,7 @@ func (t *tester) cgoTest(dt *distTest) error { 6 + t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", "-ldflags=-linkmode=internal") 7 + } 8 + t.addCmd(dt, "misc/cgo/testtls", t.goTest(), "-buildmode=pie") 9 + - t.addCmd(dt, "misc/cgo/nocgo", t.goTest(), "-buildmode=pie") 10 + + //t.addCmd(dt, "misc/cgo/nocgo", t.goTest(), "-buildmode=pie") 11 + } 12 + } 13 + }
+13
pkgs/development/compilers/go/skip-external-network-tests-1.15.patch
··· 1 + diff --git a/src/net/dial_test.go b/src/net/dial_test.go 2 + index 01582489de..5b5faa5424 100644 3 + --- a/src/net/dial_test.go 4 + +++ b/src/net/dial_test.go 5 + @@ -990,6 +990,8 @@ func TestDialerControl(t *testing.T) { 6 + // except that it won't skip testing on non-mobile builders. 7 + func mustHaveExternalNetwork(t *testing.T) { 8 + t.Helper() 9 + + t.Skipf("Nix sandbox does not have networking") 10 + + 11 + mobile := runtime.GOOS == "android" || runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" 12 + if testenv.Builder() == "" || mobile { 13 + testenv.MustHaveExternalNetwork(t)
+76
pkgs/development/compilers/go/ssl-cert-file-1.15.patch
··· 1 + diff --git a/src/crypto/x509/root_darwin_amd64.go b/src/crypto/x509/root_darwin_amd64.go 2 + index 8ad5a9607d..1d6091cf83 100644 3 + --- a/src/crypto/x509/root_darwin_amd64.go 4 + +++ b/src/crypto/x509/root_darwin_amd64.go 5 + @@ -8,6 +8,7 @@ import ( 6 + "bytes" 7 + "crypto/x509/internal/macOS" 8 + "fmt" 9 + + "io/ioutil" 10 + "os" 11 + "strings" 12 + ) 13 + @@ -23,6 +24,14 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate 14 + var loadSystemRootsWithCgo func() (*CertPool, error) 15 + 16 + func loadSystemRoots() (*CertPool, error) { 17 + + if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" { 18 + + data, err := ioutil.ReadFile(file) 19 + + if err == nil { 20 + + roots := NewCertPool() 21 + + roots.AppendCertsFromPEM(data) 22 + + return roots, nil 23 + + } 24 + + } 25 + var trustedRoots []*Certificate 26 + untrustedRoots := make(map[string]bool) 27 + 28 + diff --git a/src/crypto/x509/root_darwin_arm64.go b/src/crypto/x509/root_darwin_arm64.go 29 + index 2fb079ba66..6a072f3e78 100644 30 + --- a/src/crypto/x509/root_darwin_arm64.go 31 + +++ b/src/crypto/x509/root_darwin_arm64.go 32 + @@ -6,6 +6,11 @@ 33 + 34 + package x509 35 + 36 + +import ( 37 + + "io/ioutil" 38 + + "os" 39 + +) 40 + + 41 + func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) { 42 + return nil, nil 43 + } 44 + @@ -14,6 +19,14 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate 45 + var loadSystemRootsWithCgo func() (*CertPool, error) 46 + 47 + func loadSystemRoots() (*CertPool, error) { 48 + + if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" { 49 + + data, err := ioutil.ReadFile(file) 50 + + if err == nil { 51 + + roots := NewCertPool() 52 + + roots.AppendCertsFromPEM(data) 53 + + return roots, nil 54 + + } 55 + + } 56 + p := NewCertPool() 57 + p.AppendCertsFromPEM([]byte(systemRootsPEM)) 58 + return p, nil 59 + diff --git a/src/crypto/x509/root_unix.go b/src/crypto/x509/root_unix.go 60 + index b48e618a65..195c1ff25a 100644 61 + --- a/src/crypto/x509/root_unix.go 62 + +++ b/src/crypto/x509/root_unix.go 63 + @@ -42,6 +42,13 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate 64 + 65 + func loadSystemRoots() (*CertPool, error) { 66 + roots := NewCertPool() 67 + + if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" { 68 + + data, err := ioutil.ReadFile(file) 69 + + if err == nil { 70 + + roots.AppendCertsFromPEM(data) 71 + + return roots, nil 72 + + } 73 + + } 74 + 75 + files := certFiles 76 + if f := os.Getenv(certFileEnv); f != "" {
+13
pkgs/top-level/all-packages.nix
··· 8766 8766 buildPackages = buildPackages // { stdenv = gcc8Stdenv; }; 8767 8767 }); 8768 8768 8769 + go_1_15 = callPackage ../development/compilers/go/1.15.nix ({ 8770 + inherit (darwin.apple_sdk.frameworks) Security Foundation; 8771 + } // lib.optionalAttrs stdenv.isAarch64 { 8772 + stdenv = gcc8Stdenv; 8773 + buildPackages = buildPackages // { stdenv = gcc8Stdenv; }; 8774 + }); 8775 + 8769 8776 go = go_1_14; 8770 8777 8771 8778 go-repo-root = callPackage ../development/tools/go-repo-root { }; ··· 15486 15493 buildGo114Package = callPackage ../development/go-packages/generic { 15487 15494 go = buildPackages.go_1_14; 15488 15495 }; 15496 + buildGo115Package = callPackage ../development/go-packages/generic { 15497 + go = buildPackages.go_1_15; 15498 + }; 15489 15499 15490 15500 buildGoPackage = buildGo114Package; 15491 15501 ··· 15494 15504 }; 15495 15505 buildGo114Module = callPackage ../development/go-modules/generic { 15496 15506 go = buildPackages.go_1_14; 15507 + }; 15508 + buildGo115Module = callPackage ../development/go-modules/generic { 15509 + go = buildPackages.go_1_15; 15497 15510 }; 15498 15511 15499 15512 buildGoModule = buildGo114Module;