systems: rename extant wasi targets to wasip1

Wasi P2 is different enough to Wasi P1 to warrant being treated entirely 
separately, rather than as two minor variants of the same thing. P3 will 
likewise want to be a different target.

I've left aliases in place; maybe eventually, those can be deprecated 
and removed. I've tested this, but it's possible there might be breakage 
somewhere (e.g., the canonical doubles for P1 have changed, though I 
can't imagine why anyone would rely on that).

Fixes https://github.com/NixOS/nixpkgs/issues/435954
This commit is contained in:
Sam Pointon
2026-07-28 19:50:03 +01:00
parent 818edbf586
commit 629b4ee093
11 changed files with 28 additions and 23 deletions
+5 -7
View File
@@ -245,7 +245,7 @@ let
netbsd = "NetBSD";
freebsd = "FreeBSD";
openbsd = "OpenBSD";
wasi = "Wasi";
wasip1 = "WasiP1";
redox = "Redox";
genode = "Genode";
}
@@ -470,6 +470,8 @@ let
rust.platform.os or "none"
else if final.isDarwin then
"macos"
else if final.isWasi then
"wasi"
else if final.isWasm && !final.isWasi then
"unknown" # Needed for {wasm32,wasm64}-unknown-unknown.
else
@@ -528,11 +530,7 @@ let
abi.name;
inferred =
if final.isWasi then
# Rust uses `wasm32-wasip?` rather than `wasm32-unknown-wasi`.
# We cannot know which subversion does the user want, and
# currently use WASI 0.1 as default for compatibility. Custom
# users can set `rust.rustcTargetSpec` to override it.
if final.isWasiP1 then
"${cpu_}-wasip1"
else
"${cpu_}-${vendor_}-${kernel.name}${optionalString (abi.name != "unknown") "-${abi_}"}";
@@ -595,7 +593,7 @@ let
"wasm32" = "wasm";
}
.${final.parsed.cpu.name} or null;
GOOS = if final.isWasi then "wasip1" else final.parsed.kernel.name;
GOOS = if final.isWasiP1 then "wasip1" else final.parsed.kernel.name;
# See https://go.dev/wiki/GoArm
GOARM = toString (lib.intersectLists [ (final.parsed.cpu.version or "") ] [ "5" "6" "7" ]);
+2 -2
View File
@@ -112,8 +112,8 @@ let
"x86_64-redox"
# WASI
"wasm64-wasi"
"wasm32-wasi"
"wasm64-wasip1"
"wasm32-wasip1"
# Windows
"aarch64-windows"
+2 -1
View File
@@ -443,8 +443,9 @@ rec {
# WASM
#
# For historical reasons, Nixpkgs's wasi32 (i.e., without a revision number) corresponds to WASI p1.
wasi32 = {
config = "wasm32-unknown-wasi";
config = "wasm32-unknown-wasip1";
useLLVM = true;
};
+5 -2
View File
@@ -392,8 +392,11 @@ rec {
kernel = kernels.windows;
abi = abis.msvc;
};
isWasi = {
kernel = kernels.wasi;
isWasi = [
{ kernel = kernels.wasip1; }
];
isWasiP1 = {
kernel = kernels.wasip1;
};
isRedox = {
kernel = kernels.redox;
+2 -1
View File
@@ -601,7 +601,7 @@ rec {
execFormat = elf;
families = { };
};
wasi = {
wasip1 = {
execFormat = wasm;
families = { };
};
@@ -640,6 +640,7 @@ rec {
darwin = kernels.macos;
watchos = kernels.ios;
tvos = kernels.ios;
wasi = kernels.wasip1;
win32 = kernels.windows;
};
+2 -2
View File
@@ -95,11 +95,11 @@
magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02\x01'';
mask = ''\xff\xff\xff\xff\xff\xff\xff\xfc\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'';
};
wasm32-wasi = {
wasm32-wasip1 = {
magicOrExtension = ''\x00asm'';
mask = ''\xff\xff\xff\xff'';
};
wasm64-wasi = {
wasm64-wasip1 = {
magicOrExtension = ''\x00asm'';
mask = ''\xff\xff\xff\xff'';
};
+1 -1
View File
@@ -189,7 +189,7 @@ in
emulatedSystems = mkOption {
default = [ ];
example = [
"wasm32-wasi"
"wasm32-wasip1"
"x86_64-windows"
"aarch64-linux"
];
+1 -1
View File
@@ -112,7 +112,7 @@ in
{
boot.binfmt.emulatedSystems = [
"aarch64-linux"
"wasm32-wasi"
"wasm32-wasip1"
];
boot.binfmt.preferStaticEmulators = true;
@@ -245,9 +245,9 @@ let
# https://hacks.mozilla.org/2021/12/webassembly-and-back-again-fine-grained-sandboxing-in-firefox-95/
# We only link c++ libs here, our compiler wrapper can find wasi libc and crt itself.
wasiSysRoot = runCommand "wasi-sysroot" { } ''
mkdir -p $out/lib/wasm32-wasi
mkdir -p $out/lib/wasm32-wasip1
for lib in ${pkgsCross.wasi32.llvmPackages.libcxx}/lib/*; do
ln -s $lib $out/lib/wasm32-wasi
ln -s $lib $out/lib/wasm32-wasip1
done
'';
+5 -3
View File
@@ -67,8 +67,8 @@ rustPlatform.buildRustPackage (finalAttrs: {
# TODO: revisit when https://github.com/DelSkayn/rquickjs/pull/648 is released and extism updated
env.WASI_SDK = runCommand "wasi-sdk" { } ''
mkdir -p $out/bin
ln -s ${lib.getExe' stdenv.cc "wasm32-unknown-wasi-clang"} $out/bin/clang
ln -s ${lib.getExe' stdenv.cc "wasm32-unknown-wasi-ar"} $out/bin/ar
ln -s ${lib.getExe' stdenv.cc "wasm32-unknown-wasip1-clang"} $out/bin/clang
ln -s ${lib.getExe' stdenv.cc "wasm32-unknown-wasip1-ar"} $out/bin/ar
ln -s ${stdenv.cc}/nix-support $out/nix-support
mkdir -p $out/share
ln -s ${stdenv.cc.libc} $out/share/wasi-sysroot
@@ -90,6 +90,8 @@ rustPlatform.buildRustPackage (finalAttrs: {
lib.maintainers.diogotcorreia
lib.maintainers.dotlambda
];
platforms = lib.platforms.wasi;
platforms = [
"wasm32-wasip1"
];
};
})
+1 -1
View File
@@ -120,7 +120,7 @@ rec {
"riscv64-netbsd"
"riscv32-none"
"x86_64-redox"
"wasm32-wasi"
"wasm32-wasip1"
];
badTargetPlatforms = [
# Rust is currently unable to target the n32 ABI