-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Backport release-24.05] go: Backport go 1.23 to nixos-24.05 #339654
Closed
mglazer
wants to merge
5
commits into
NixOS:release-24.05
from
mglazer:mglazer/backport-go-123-upstream
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
40b4f41
go_1_23: init at 1.23rc1
zowoq 7fb69e6
go: drop gccgo bootstrap, drop autoPatchelfHook from bootstrap (#322825)
zowoq 25b8a77
go_1_23: 1.23rc1 -> 1.23rc2
zowoq 5249992
go: support FreeBSD
rhelmot ae08f10
go_1_23: 1.23rc2 -> 1.23.0
techknowlogick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
{ lib | ||
, stdenv | ||
, fetchurl | ||
, tzdata | ||
, substituteAll | ||
, iana-etc | ||
, Security | ||
, Foundation | ||
, xcbuild | ||
, mailcap | ||
, buildPackages | ||
, pkgsBuildTarget | ||
, threadsCross | ||
, testers | ||
, skopeo | ||
, buildGo123Module | ||
}: | ||
|
||
let | ||
goBootstrap = buildPackages.callPackage ./bootstrap121.nix { }; | ||
|
||
skopeoTest = skopeo.override { buildGoModule = buildGo123Module; }; | ||
|
||
goarch = platform: { | ||
"aarch64" = "arm64"; | ||
"arm" = "arm"; | ||
"armv5tel" = "arm"; | ||
"armv6l" = "arm"; | ||
"armv7l" = "arm"; | ||
"i686" = "386"; | ||
"mips" = "mips"; | ||
"mips64el" = "mips64le"; | ||
"mipsel" = "mipsle"; | ||
"powerpc64" = "ppc64"; | ||
"powerpc64le" = "ppc64le"; | ||
"riscv64" = "riscv64"; | ||
"s390x" = "s390x"; | ||
"x86_64" = "amd64"; | ||
"wasm32" = "wasm"; | ||
}.${platform.parsed.cpu.name} or (throw "Unsupported system: ${platform.parsed.cpu.name}"); | ||
|
||
# We need a target compiler which is still runnable at build time, | ||
# to handle the cross-building case where build != host == target | ||
targetCC = pkgsBuildTarget.targetPackages.stdenv.cc; | ||
|
||
isCross = stdenv.buildPlatform != stdenv.targetPlatform; | ||
in | ||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "go"; | ||
version = "1.23.0"; | ||
|
||
src = fetchurl { | ||
url = "https://go.dev/dl/go${finalAttrs.version}.src.tar.gz"; | ||
hash = "sha256-Qreo6A2AXaoDAi7T/eQyHUw78smQoUQWXQHu7Nb2mcY="; | ||
}; | ||
|
||
strictDeps = true; | ||
buildInputs = [ ] | ||
++ lib.optionals stdenv.isLinux [ stdenv.cc.libc.out ] | ||
++ lib.optionals (stdenv.hostPlatform.libc == "glibc") [ stdenv.cc.libc.static ]; | ||
|
||
depsTargetTargetPropagated = lib.optionals stdenv.targetPlatform.isDarwin [ Foundation Security xcbuild ]; | ||
|
||
depsBuildTarget = lib.optional isCross targetCC; | ||
|
||
depsTargetTarget = lib.optional stdenv.targetPlatform.isWindows threadsCross.package; | ||
|
||
postPatch = '' | ||
patchShebangs . | ||
''; | ||
|
||
patches = [ | ||
(substituteAll { | ||
src = ./iana-etc-1.17.patch; | ||
iana = iana-etc; | ||
}) | ||
# Patch the mimetype database location which is missing on NixOS. | ||
# but also allow static binaries built with NixOS to run outside nix | ||
(substituteAll { | ||
src = ./mailcap-1.17.patch; | ||
inherit mailcap; | ||
}) | ||
# prepend the nix path to the zoneinfo files but also leave the original value for static binaries | ||
# that run outside a nix server | ||
(substituteAll { | ||
src = ./tzdata-1.19.patch; | ||
inherit tzdata; | ||
}) | ||
./remove-tools-1.11.patch | ||
./go_no_vendor_checks-1.22.patch | ||
]; | ||
|
||
GOOS = if stdenv.targetPlatform.isWasi then "wasip1" else 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; | ||
|
||
# {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those | ||
# to be different from CC/CXX | ||
CC_FOR_TARGET = | ||
if isCross then | ||
"${targetCC}/bin/${targetCC.targetPrefix}cc" | ||
else | ||
null; | ||
CXX_FOR_TARGET = | ||
if isCross then | ||
"${targetCC}/bin/${targetCC.targetPrefix}c++" | ||
else | ||
null; | ||
|
||
GOARM = toString (lib.intersectLists [ (stdenv.hostPlatform.parsed.cpu.version or "") ] [ "5" "6" "7" ]); | ||
GO386 = "softfloat"; # from Arch: don't assume sse2 on i686 | ||
# Wasi does not support CGO | ||
CGO_ENABLED = if stdenv.targetPlatform.isWasi then 0 else 1; | ||
|
||
GOROOT_BOOTSTRAP = "${goBootstrap}/share/go"; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
export GOCACHE=$TMPDIR/go-cache | ||
|
||
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. | ||
export CC=${buildPackages.stdenv.cc}/bin/cc | ||
''} | ||
ulimit -a | ||
|
||
pushd src | ||
./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/go | ||
cp -a bin pkg src lib misc api doc go.env $out/share/go | ||
mkdir -p $out/bin | ||
ln -s $out/share/go/bin/* $out/bin | ||
runHook postInstall | ||
''; | ||
|
||
disallowedReferences = [ goBootstrap ]; | ||
|
||
passthru = { | ||
inherit goBootstrap skopeoTest; | ||
tests = { | ||
skopeo = testers.testVersion { package = skopeoTest; }; | ||
version = testers.testVersion { | ||
package = finalAttrs.finalPackage; | ||
command = "go version"; | ||
version = "go${finalAttrs.version}"; | ||
}; | ||
}; | ||
}; | ||
|
||
meta = with lib; { | ||
changelog = "https://go.dev/doc/devel/release#go${lib.versions.majorMinor finalAttrs.version}"; | ||
description = "Go Programming language"; | ||
homepage = "https://go.dev/"; | ||
license = licenses.bsd3; | ||
maintainers = teams.golang.members; | ||
platforms = platforms.darwin ++ platforms.linux ++ platforms.wasi ++ platforms.freebsd; | ||
mainProgram = "go"; | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason this is failing the cherrypick, is
platforms.wasi
was added here:050df1a
which is before go1.23 existed. I opted to not add additional functionality that wasn't part of the strict set of cherrypicks when resolving the merge conflict. Happy to add platforms.wasi to go1.22 if that's desired.