go_1_22: init at 1.22rc1

zowoq 944f1672 850239d1

+223
+189
pkgs/development/compilers/go/1.22.nix
··· 1 + { lib 2 + , stdenv 3 + , fetchurl 4 + , tzdata 5 + , substituteAll 6 + , iana-etc 7 + , Security 8 + , Foundation 9 + , xcbuild 10 + , mailcap 11 + , buildPackages 12 + , pkgsBuildTarget 13 + , threadsCross 14 + , testers 15 + , skopeo 16 + , buildGo122Module 17 + }: 18 + 19 + let 20 + useGccGoBootstrap = stdenv.buildPlatform.isMusl; 21 + goBootstrap = if useGccGoBootstrap then buildPackages.gccgo12 else buildPackages.callPackage ./bootstrap121.nix { }; 22 + 23 + skopeoTest = skopeo.override { buildGoModule = buildGo122Module; }; 24 + 25 + goarch = platform: { 26 + "aarch64" = "arm64"; 27 + "arm" = "arm"; 28 + "armv5tel" = "arm"; 29 + "armv6l" = "arm"; 30 + "armv7l" = "arm"; 31 + "i686" = "386"; 32 + "mips" = "mips"; 33 + "mips64el" = "mips64le"; 34 + "mipsel" = "mipsle"; 35 + "powerpc64le" = "ppc64le"; 36 + "riscv64" = "riscv64"; 37 + "s390x" = "s390x"; 38 + "x86_64" = "amd64"; 39 + }.${platform.parsed.cpu.name} or (throw "Unsupported system: ${platform.parsed.cpu.name}"); 40 + 41 + # We need a target compiler which is still runnable at build time, 42 + # to handle the cross-building case where build != host == target 43 + targetCC = pkgsBuildTarget.targetPackages.stdenv.cc; 44 + 45 + isCross = stdenv.buildPlatform != stdenv.targetPlatform; 46 + in 47 + stdenv.mkDerivation (finalAttrs: { 48 + pname = "go"; 49 + version = "1.22rc1"; 50 + 51 + src = fetchurl { 52 + url = "https://go.dev/dl/go${finalAttrs.version}.src.tar.gz"; 53 + hash = "sha256-muy7jrrkG5PqJu9bAUKW+75woHYwJJwNiidd871NJuo="; 54 + }; 55 + 56 + strictDeps = true; 57 + buildInputs = [ ] 58 + ++ lib.optionals stdenv.isLinux [ stdenv.cc.libc.out ] 59 + ++ lib.optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ]; 60 + 61 + depsTargetTargetPropagated = lib.optionals stdenv.targetPlatform.isDarwin [ Foundation Security xcbuild ]; 62 + 63 + depsBuildTarget = lib.optional isCross targetCC; 64 + 65 + depsTargetTarget = lib.optional stdenv.targetPlatform.isWindows threadsCross.package; 66 + 67 + postPatch = '' 68 + patchShebangs . 69 + ''; 70 + 71 + patches = [ 72 + (substituteAll { 73 + src = ./iana-etc-1.17.patch; 74 + iana = iana-etc; 75 + }) 76 + # Patch the mimetype database location which is missing on NixOS. 77 + # but also allow static binaries built with NixOS to run outside nix 78 + (substituteAll { 79 + src = ./mailcap-1.17.patch; 80 + inherit mailcap; 81 + }) 82 + # prepend the nix path to the zoneinfo files but also leave the original value for static binaries 83 + # that run outside a nix server 84 + (substituteAll { 85 + src = ./tzdata-1.19.patch; 86 + inherit tzdata; 87 + }) 88 + ./remove-tools-1.11.patch 89 + ./go_no_vendor_checks-1.22.patch 90 + ]; 91 + 92 + GOOS = stdenv.targetPlatform.parsed.kernel.name; 93 + GOARCH = goarch stdenv.targetPlatform; 94 + # GOHOSTOS/GOHOSTARCH must match the building system, not the host system. 95 + # Go will nevertheless build a for host system that we will copy over in 96 + # the install phase. 97 + GOHOSTOS = stdenv.buildPlatform.parsed.kernel.name; 98 + GOHOSTARCH = goarch stdenv.buildPlatform; 99 + 100 + # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those 101 + # to be different from CC/CXX 102 + CC_FOR_TARGET = 103 + if isCross then 104 + "${targetCC}/bin/${targetCC.targetPrefix}cc" 105 + else 106 + null; 107 + CXX_FOR_TARGET = 108 + if isCross then 109 + "${targetCC}/bin/${targetCC.targetPrefix}c++" 110 + else 111 + null; 112 + 113 + GOARM = toString (lib.intersectLists [ (stdenv.hostPlatform.parsed.cpu.version or "") ] [ "5" "6" "7" ]); 114 + GO386 = "softfloat"; # from Arch: don't assume sse2 on i686 115 + CGO_ENABLED = 1; 116 + 117 + GOROOT_BOOTSTRAP = if useGccGoBootstrap then goBootstrap else "${goBootstrap}/share/go"; 118 + 119 + buildPhase = '' 120 + runHook preBuild 121 + export GOCACHE=$TMPDIR/go-cache 122 + # this is compiled into the binary 123 + export GOROOT_FINAL=$out/share/go 124 + 125 + export PATH=$(pwd)/bin:$PATH 126 + 127 + ${lib.optionalString isCross '' 128 + # Independent from host/target, CC should produce code for the building system. 129 + # We only set it when cross-compiling. 130 + export CC=${buildPackages.stdenv.cc}/bin/cc 131 + ''} 132 + ulimit -a 133 + 134 + pushd src 135 + ./make.bash 136 + popd 137 + runHook postBuild 138 + ''; 139 + 140 + preInstall = '' 141 + # Contains the wrong perl shebang when cross compiling, 142 + # since it is not used for anything we can deleted as well. 143 + rm src/regexp/syntax/make_perl_groups.pl 144 + '' + (if (stdenv.buildPlatform.system != stdenv.hostPlatform.system) then '' 145 + mv bin/*_*/* bin 146 + rmdir bin/*_* 147 + ${lib.optionalString (!(finalAttrs.GOHOSTARCH == finalAttrs.GOARCH && finalAttrs.GOOS == finalAttrs.GOHOSTOS)) '' 148 + rm -rf pkg/${finalAttrs.GOHOSTOS}_${finalAttrs.GOHOSTARCH} pkg/tool/${finalAttrs.GOHOSTOS}_${finalAttrs.GOHOSTARCH} 149 + ''} 150 + '' else lib.optionalString (stdenv.hostPlatform.system != stdenv.targetPlatform.system) '' 151 + rm -rf bin/*_* 152 + ${lib.optionalString (!(finalAttrs.GOHOSTARCH == finalAttrs.GOARCH && finalAttrs.GOOS == finalAttrs.GOHOSTOS)) '' 153 + rm -rf pkg/${finalAttrs.GOOS}_${finalAttrs.GOARCH} pkg/tool/${finalAttrs.GOOS}_${finalAttrs.GOARCH} 154 + ''} 155 + ''); 156 + 157 + installPhase = '' 158 + runHook preInstall 159 + mkdir -p $GOROOT_FINAL 160 + cp -a bin pkg src lib misc api doc go.env $GOROOT_FINAL 161 + mkdir -p $out/bin 162 + ln -s $GOROOT_FINAL/bin/* $out/bin 163 + runHook postInstall 164 + ''; 165 + 166 + disallowedReferences = [ goBootstrap ]; 167 + 168 + passthru = { 169 + inherit goBootstrap skopeoTest; 170 + tests = { 171 + skopeo = testers.testVersion { package = skopeoTest; }; 172 + version = testers.testVersion { 173 + package = finalAttrs.finalPackage; 174 + command = "go version"; 175 + version = "go${finalAttrs.version}"; 176 + }; 177 + }; 178 + }; 179 + 180 + meta = with lib; { 181 + changelog = "https://go.dev/doc/devel/release#go${lib.versions.majorMinor finalAttrs.version}"; 182 + description = "The Go Programming language"; 183 + homepage = "https://go.dev/"; 184 + license = licenses.bsd3; 185 + maintainers = teams.golang.members; 186 + platforms = platforms.darwin ++ platforms.linux; 187 + mainProgram = "go"; 188 + }; 189 + })
+23
pkgs/development/compilers/go/go_no_vendor_checks-1.22.patch
··· 1 + Starting from go1.14, go verifes that vendor/modules.txt matches the requirements 2 + and replacements listed in the main module go.mod file, and it is a hard failure if 3 + vendor/modules.txt is missing. 4 + 5 + Relax module consistency checks and switch back to pre go1.14 behaviour if 6 + vendor/modules.txt is missing regardless of go version requirement in go.mod. 7 + 8 + This has been ported from FreeBSD: https://reviews.freebsd.org/D24122 9 + See https://github.com/golang/go/issues/37948 for discussion. 10 + 11 + diff --git a/src/cmd/go/internal/modload/vendor.go b/src/cmd/go/internal/modload/vendor.go 12 + index b2cb44100e..05bf3829d5 100644 13 + --- a/src/cmd/go/internal/modload/vendor.go 14 + +++ b/src/cmd/go/internal/modload/vendor.go 15 + @@ -159,7 +159,7 @@ func checkVendorConsistency(indexes []*modFileIndex, modFiles []*modfile.File, m 16 + panic(fmt.Errorf("not in workspace mode but number of indexes is %v, not 1", len(indexes))) 17 + } 18 + index := indexes[0] 19 + - if gover.Compare(index.goVersion, "1.14") < 0 { 20 + + if gover.Compare(index.goVersion, "1.14") < 0 || (os.Getenv("GO_NO_VENDOR_CHECKS") == "1" && len(vendorMeta) == 0) { 21 + // Go versions before 1.14 did not include enough information in 22 + // vendor/modules.txt to check for consistency. 23 + // If we know that we're on an earlier version, relax the consistency check.
+11
pkgs/top-level/all-packages.nix
··· 25916 25916 go = buildPackages.go_1_21; 25917 25917 }; 25918 25918 25919 + # requires a newer Apple SDK 25920 + go_1_22 = darwin.apple_sdk_11_0.callPackage ../development/compilers/go/1.22.nix { 25921 + inherit (darwin.apple_sdk_11_0.frameworks) Foundation Security; 25922 + }; 25923 + buildGo122Module = darwin.apple_sdk_11_0.callPackage ../build-support/go/module.nix { 25924 + go = buildPackages.go_1_22; 25925 + }; 25926 + buildGo122Package = darwin.apple_sdk_11_0.callPackage ../build-support/go/package.nix { 25927 + go = buildPackages.go_1_22; 25928 + }; 25929 + 25919 25930 leaps = callPackage ../development/tools/leaps { }; 25920 25931 25921 25932 ### DEVELOPMENT / JAVA MODULES