Unverified Commit 555243d8 authored by Jörg Thalheim's avatar Jörg Thalheim Committed by GitHub
Browse files

Merge pull request #315455 from nagy/go-wasi32

go: Support WASI platform
parents 51a4edb8 050df1a7
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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";
  };
})