Skip to content

Commit 972a96b

Browse files
committed
Add a new wasm32-wasip3 target to Rust
This commit adds a new tier 3 target to rustc, `wasm32-wasip3`. This follows in the footsteps of the previous `wasm32-wasip2` target and is used to represent binding to the WASIp3 set of APIs managed by the WASI subgroup to the WebAssembly Community Group. As of now the WASIp3 set of APIs are not finalized nor standardized. They're in the process of doing so and the current trajectory is to have the APIs published in December of this year. The goal here is to get the wheels turning in Rust to have the target in a more-ready-than-nonexistent state by the time this happens in December. For now the `wasm32-wasip3` target looks exactly the same as `wasm32-wasip2` except that `target_env = "p3"` is specified. This indicates to crates in the ecosystem that WASIp3 APIs should be used, such as the [`wasip3` crate]. Over time this target will evolve as implementation in guest toolchains progress, notably: * The standard library will use WASIp3 APIs natively once they're finalized in the WASI subgroup. * Support through `wasi-libc` will be updated to use WASIp3 natively which Rust will then transitively use. * Longer-term, features such as cooperative multithreading will be added to the WASIp3-track of targets to enable using `std::thread`, for example, on this target. These changes are all expected to be non-breaking changes for users of this target. Runtimes supporting WASIp3, currently Wasmtime and Jco, support WASIp2 APIs as well and will work with components whether or not they import WASIp2, both WASIp2 and WASIp3, or just WASIp3 APIs. This means that changing the internal implementation details of libstd over time is expected to be a non-breaking change. [`wasip3` crate]: https://crates.io/crates/wasip3
1 parent c11ef47 commit 972a96b

File tree

9 files changed

+15
-10
lines changed

9 files changed

+15
-10
lines changed

std/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ wasip2 = { version = '0.14.4', features = [
8585
'rustc-dep-of-std',
8686
], default-features = false, package = 'wasi' }
8787

88+
[target.'cfg(all(target_os = "wasi", target_env = "p3"))'.dependencies]
89+
wasip2 = { version = '0.14.4', features = [
90+
'rustc-dep-of-std',
91+
], default-features = false, package = 'wasi' }
92+
8893
[target.'cfg(target_os = "uefi")'.dependencies]
8994
r-efi = { version = "5.2.0", features = ['rustc-dep-of-std'] }
9095
r-efi-alloc = { version = "2.0.0", features = ['rustc-dep-of-std'] }

std/src/os/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub mod linux;
103103
all(target_vendor = "fortanix", target_env = "sgx")
104104
)
105105
)))]
106-
#[cfg(any(target_os = "wasi", doc))]
106+
#[cfg(any(target_os = "wasi", any(target_env = "p1", target_env = "p2"), doc))]
107107
pub mod wasi;
108108

109109
#[cfg(any(all(target_os = "wasi", target_env = "p2"), doc))]

std/src/sys/args/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ cfg_select! {
3636
mod wasip1;
3737
pub use wasip1::*;
3838
}
39-
all(target_os = "wasi", target_env = "p2") => {
39+
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
4040
mod wasip2;
4141
pub use wasip2::*;
4242
}

std/src/sys/net/connection/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cfg_select! {
33
all(target_family = "unix", not(target_os = "l4re")),
44
target_os = "windows",
55
target_os = "hermit",
6-
all(target_os = "wasi", target_env = "p2"),
6+
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")),
77
target_os = "solid_asp3",
88
) => {
99
mod socket;

std/src/sys/net/connection/socket/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cfg_select! {
2525
mod unix;
2626
pub use unix::*;
2727
}
28-
all(target_os = "wasi", target_env = "p2") => {
28+
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
2929
mod wasip2;
3030
pub use wasip2::*;
3131
}

std/src/sys/pal/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ cfg_select! {
4949
mod vexos;
5050
pub use self::vexos::*;
5151
}
52-
all(target_os = "wasi", target_env = "p2") => {
52+
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
5353
mod wasip2;
5454
pub use self::wasip2::*;
5555
}

std/src/sys/random/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ cfg_select! {
9090
mod wasip1;
9191
pub use wasip1::fill_bytes;
9292
}
93-
all(target_os = "wasi", target_env = "p2") => {
93+
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
9494
mod wasip2;
9595
pub use wasip2::{fill_bytes, hashmap_random_keys};
9696
}
@@ -115,7 +115,7 @@ cfg_select! {
115115
target_os = "linux",
116116
target_os = "android",
117117
all(target_family = "wasm", target_os = "unknown"),
118-
all(target_os = "wasi", target_env = "p2"),
118+
all(target_os = "wasi", not(target_env = "p1")),
119119
target_os = "xous",
120120
target_os = "vexos",
121121
)))]

std/src/sys/stdio/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cfg_select! {
3737
mod wasip1;
3838
pub use wasip1::*;
3939
}
40-
all(target_os = "wasi", target_env = "p2") => {
40+
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
4141
mod wasip2;
4242
pub use wasip2::*;
4343
}

std/src/sys/thread/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ cfg_select! {
9999
#[cfg(not(target_feature = "atomics"))]
100100
pub use unsupported::{Thread, available_parallelism};
101101
}
102-
all(target_os = "wasi", target_env = "p2") => {
102+
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
103103
mod wasip2;
104104
pub use wasip2::{sleep, sleep_until};
105105
#[expect(dead_code)]
@@ -146,7 +146,7 @@ cfg_select! {
146146
target_os = "hurd",
147147
target_os = "fuchsia",
148148
target_os = "vxworks",
149-
all(target_os = "wasi", target_env = "p2"),
149+
all(target_os = "wasi", not(target_env = "p1")),
150150
)))]
151151
pub fn sleep_until(deadline: crate::time::Instant) {
152152
use crate::time::Instant;

0 commit comments

Comments
 (0)