diff options
author | zowoq <59103226+zowoq@users.noreply.github.com> | 2023-09-22 08:19:21 +1000 |
---|---|---|
committer | zowoq <59103226+zowoq@users.noreply.github.com> | 2023-09-22 09:16:27 +1000 |
commit | 3da524ca62cc4a12c5e677ba044ab7c74a65ad0f (patch) | |
tree | e53f0d997c1bc440b65141a438df7bc719cf8199 /pkgs/development/compilers | |
parent | 0d81da813882b9c0930fe608ff7ab66605084e6c (diff) | |
download | nixpkgs-3da524ca62cc4a12c5e677ba044ab7c74a65ad0f.tar nixpkgs-3da524ca62cc4a12c5e677ba044ab7c74a65ad0f.tar.gz nixpkgs-3da524ca62cc4a12c5e677ba044ab7c74a65ad0f.tar.bz2 nixpkgs-3da524ca62cc4a12c5e677ba044ab7c74a65ad0f.tar.lz nixpkgs-3da524ca62cc4a12c5e677ba044ab7c74a65ad0f.tar.xz nixpkgs-3da524ca62cc4a12c5e677ba044ab7c74a65ad0f.tar.zst nixpkgs-3da524ca62cc4a12c5e677ba044ab7c74a65ad0f.zip |
Revert "go_1_21: install from distpack archive"
This reverts commit 1ee50a29288f768c55211963be8040671814986d. broke cross builds
Diffstat (limited to 'pkgs/development/compilers')
-rw-r--r-- | pkgs/development/compilers/go/1.21.nix | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/pkgs/development/compilers/go/1.21.nix b/pkgs/development/compilers/go/1.21.nix index 6fca091f24d..e0562ad32b9 100644 --- a/pkgs/development/compilers/go/1.21.nix +++ b/pkgs/development/compilers/go/1.21.nix @@ -64,6 +64,10 @@ stdenv.mkDerivation (finalAttrs: { depsTargetTarget = lib.optional stdenv.targetPlatform.isWindows threadsCross.package; + postPatch = '' + patchShebangs . + ''; + patches = [ (substituteAll { src = ./iana-etc-1.17.patch; @@ -88,6 +92,8 @@ stdenv.mkDerivation (finalAttrs: { GOOS = stdenv.targetPlatform.parsed.kernel.name; GOARCH = goarch stdenv.targetPlatform; # GOHOSTOS/GOHOSTARCH must match the building system, not the host system. + # Go will nevertheless build a for host system that we will copy over in + # the install phase. GOHOSTOS = stdenv.buildPlatform.parsed.kernel.name; GOHOSTARCH = goarch stdenv.buildPlatform; @@ -110,16 +116,14 @@ stdenv.mkDerivation (finalAttrs: { GOROOT_BOOTSTRAP = if useGccGoBootstrap then goBootstrap else "${goBootstrap}/share/go"; - # Note that we use distpack to avoid moving around cross-compiled binaries. - # The paths are slightly different when buildPlatform != hostPlatform and - # distpack handles assembling outputs in the right place, same as the official - # Go binary releases. See also https://pkg.go.dev/cmd/distpack buildPhase = '' runHook preBuild export GOCACHE=$TMPDIR/go-cache # this is compiled into the binary export GOROOT_FINAL=$out/share/go + export PATH=$(pwd)/bin:$PATH + ${lib.optionalString isCross '' # Independent from host/target, CC should produce code for the building system. # We only set it when cross-compiling. @@ -128,16 +132,34 @@ stdenv.mkDerivation (finalAttrs: { ulimit -a pushd src - bash make.bash -no-banner -distpack + ./make.bash popd runHook postBuild ''; + preInstall = '' + # Contains the wrong perl shebang when cross compiling, + # since it is not used for anything we can deleted as well. + rm src/regexp/syntax/make_perl_groups.pl + '' + (if (stdenv.buildPlatform.system != stdenv.hostPlatform.system) then '' + mv bin/*_*/* bin + rmdir bin/*_* + ${lib.optionalString (!(finalAttrs.GOHOSTARCH == finalAttrs.GOARCH && finalAttrs.GOOS == finalAttrs.GOHOSTOS)) '' + rm -rf pkg/${finalAttrs.GOHOSTOS}_${finalAttrs.GOHOSTARCH} pkg/tool/${finalAttrs.GOHOSTOS}_${finalAttrs.GOHOSTARCH} + ''} + '' else lib.optionalString (stdenv.hostPlatform.system != stdenv.targetPlatform.system) '' + rm -rf bin/*_* + ${lib.optionalString (!(finalAttrs.GOHOSTARCH == finalAttrs.GOARCH && finalAttrs.GOOS == finalAttrs.GOHOSTOS)) '' + rm -rf pkg/${finalAttrs.GOOS}_${finalAttrs.GOARCH} pkg/tool/${finalAttrs.GOOS}_${finalAttrs.GOARCH} + ''} + ''); + installPhase = '' runHook preInstall - mkdir -p $out/{share,bin} - tar -C $out/share -x -z -f "pkg/distpack/go${finalAttrs.version}.$GOOS-$GOARCH.tar.gz" - ln -s $out/share/go/bin/* $out/bin + mkdir -p $GOROOT_FINAL + cp -a bin pkg src lib misc api doc go.env $GOROOT_FINAL + mkdir -p $out/bin + ln -s $GOROOT_FINAL/bin/* $out/bin runHook postInstall ''; |