Merge pull request #315455 from nagy/go-wasi32

go: Support WASI platform
This commit is contained in:
Jörg Thalheim 2024-05-29 06:47:03 +02:00 committed by GitHub
commit 555243d8d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,6 +37,7 @@ let
"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,
@ -90,7 +91,7 @@ stdenv.mkDerivation (finalAttrs: {
./go_no_vendor_checks-1.22.patch
];
GOOS = stdenv.targetPlatform.parsed.kernel.name;
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
@ -113,7 +114,8 @@ stdenv.mkDerivation (finalAttrs: {
GOARM = toString (lib.intersectLists [ (stdenv.hostPlatform.parsed.cpu.version or "") ] [ "5" "6" "7" ]);
GO386 = "softfloat"; # from Arch: don't assume sse2 on i686
CGO_ENABLED = 1;
# Wasi does not support CGO
CGO_ENABLED = if stdenv.targetPlatform.isWasi then 0 else 1;
GOROOT_BOOTSTRAP = if useGccGoBootstrap then goBootstrap else "${goBootstrap}/share/go";
@ -184,7 +186,7 @@ stdenv.mkDerivation (finalAttrs: {
homepage = "https://go.dev/";
license = licenses.bsd3;
maintainers = teams.golang.members;
platforms = platforms.darwin ++ platforms.linux;
platforms = platforms.darwin ++ platforms.linux ++ platforms.wasi;
mainProgram = "go";
};
})