Skip to content

Commit 6c0cbcf

Browse files
authored
Rollup merge of #155605 - alexcrichton:wasip3, r=jhpratt
std: Update support for `wasm32-wasip3` This commit performs some minor update within the standard library for the `wasm32-wasip3` target. This target is a tier 3 target currently due to the WASIp3 specification not being officially released. This commit adds a dependency from the standard library on the `wasip3` crate in the same manner as the `wasip1` and `wasip2` crates that it already depends on. The use-sites, for randomness and environment variables, are then updated to handle the wasip2/wasip3 multiplexing.
2 parents b622dd0 + 1dea6b8 commit 6c0cbcf

9 files changed

Lines changed: 46 additions & 25 deletions

File tree

library/Cargo.lock

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ dependencies = [
346346
"vex-sdk",
347347
"wasip1",
348348
"wasip2",
349+
"wasip3",
349350
"windows-link 0.0.0",
350351
]
351352

@@ -418,9 +419,20 @@ dependencies = [
418419

419420
[[package]]
420421
name = "wasip2"
421-
version = "1.0.2+wasi-0.2.9"
422+
version = "1.0.3+wasi-0.2.9"
422423
source = "registry+https://github.com/rust-lang/crates.io-index"
423-
checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
424+
checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6"
425+
dependencies = [
426+
"rustc-std-workspace-alloc",
427+
"rustc-std-workspace-core",
428+
"wit-bindgen",
429+
]
430+
431+
[[package]]
432+
name = "wasip3"
433+
version = "0.6.0+wasi-0.3.0-rc-2026-03-15"
434+
source = "registry+https://github.com/rust-lang/crates.io-index"
435+
checksum = "ed83456dd6a0b8581998c0365e4651fa2997e5093b49243b7f35391afaa7a3d9"
424436
dependencies = [
425437
"rustc-std-workspace-alloc",
426438
"rustc-std-workspace-core",
@@ -513,9 +525,9 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
513525

514526
[[package]]
515527
name = "wit-bindgen"
516-
version = "0.51.0"
528+
version = "0.57.1"
517529
source = "registry+https://github.com/rust-lang/crates.io-index"
518-
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
530+
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
519531
dependencies = [
520532
"rustc-std-workspace-alloc",
521533
"rustc-std-workspace-core",

library/std/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ wasip1 = { version = "1.0.0", features = [
8484
], default-features = false }
8585

8686
[target.'cfg(all(target_os = "wasi", target_env = "p2"))'.dependencies]
87-
wasip2 = { version = '1.0.2', features = [
87+
wasip2 = { version = '1.0.3', features = [
8888
'rustc-dep-of-std',
8989
], default-features = false }
9090

9191
[target.'cfg(all(target_os = "wasi", target_env = "p3"))'.dependencies]
92-
wasip2 = { version = '1.0.2', features = [
92+
wasip3 = { version = '0.6.0', features = [
9393
'rustc-dep-of-std',
9494
], default-features = false }
9595

library/std/src/sys/args/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ cfg_select! {
4242
pub use wasip1::*;
4343
}
4444
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
45-
mod wasip2;
46-
pub use wasip2::*;
45+
mod wasi;
46+
pub use wasi::*;
4747
}
4848
target_os = "xous" => {
4949
mod xous;

library/std/src/sys/args/wasi.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#[cfg(target_env = "p2")]
2+
use wasip2 as wasi;
3+
#[cfg(target_env = "p3")]
4+
use wasip3 as wasi;
5+
6+
pub use super::common::Args;
7+
8+
/// Returns the command line arguments
9+
pub fn args() -> Args {
10+
Args::new(wasi::cli::environment::get_arguments().into_iter().map(|arg| arg.into()).collect())
11+
}

library/std/src/sys/args/wasip2.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

library/std/src/sys/random/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ cfg_select! {
9595
pub use wasip1::fill_bytes;
9696
}
9797
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
98-
mod wasip2;
99-
pub use wasip2::{fill_bytes, hashmap_random_keys};
98+
mod wasi;
99+
pub use wasi::{fill_bytes, hashmap_random_keys};
100100
}
101101
target_os = "zkvm" => {
102102
mod zkvm;

library/std/src/sys/random/wasi.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#[cfg(target_env = "p2")]
2+
use wasip2::random::{insecure_seed::insecure_seed as get_insecure_seed, random::get_random_bytes};
3+
#[cfg(target_env = "p3")]
4+
use wasip3::random::{insecure_seed::get_insecure_seed, random::get_random_bytes};
5+
6+
pub fn fill_bytes(bytes: &mut [u8]) {
7+
bytes.copy_from_slice(&get_random_bytes(u64::try_from(bytes.len()).unwrap()));
8+
}
9+
10+
pub fn hashmap_random_keys() -> (u64, u64) {
11+
get_insecure_seed()
12+
}

library/std/src/sys/random/wasip2.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/tools/tidy/src/deps.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ const PERMITTED_STDLIB_DEPENDENCIES: &[&str] = &[
541541
"vex-sdk",
542542
"wasip1",
543543
"wasip2",
544+
"wasip3",
544545
"windows-link",
545546
"windows-sys",
546547
"windows-targets",

0 commit comments

Comments
 (0)