mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-26 13:01:27 +03:00
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.
This commit is contained in:
+16
-4
@@ -346,6 +346,7 @@ dependencies = [
|
|||||||
"vex-sdk",
|
"vex-sdk",
|
||||||
"wasip1",
|
"wasip1",
|
||||||
"wasip2",
|
"wasip2",
|
||||||
|
"wasip3",
|
||||||
"windows-link 0.0.0",
|
"windows-link 0.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -418,9 +419,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasip2"
|
name = "wasip2"
|
||||||
version = "1.0.2+wasi-0.2.9"
|
version = "1.0.3+wasi-0.2.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
|
checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6"
|
||||||
|
dependencies = [
|
||||||
|
"rustc-std-workspace-alloc",
|
||||||
|
"rustc-std-workspace-core",
|
||||||
|
"wit-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasip3"
|
||||||
|
version = "0.6.0+wasi-0.3.0-rc-2026-03-15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ed83456dd6a0b8581998c0365e4651fa2997e5093b49243b7f35391afaa7a3d9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustc-std-workspace-alloc",
|
"rustc-std-workspace-alloc",
|
||||||
"rustc-std-workspace-core",
|
"rustc-std-workspace-core",
|
||||||
@@ -513,9 +525,9 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wit-bindgen"
|
name = "wit-bindgen"
|
||||||
version = "0.51.0"
|
version = "0.57.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
|
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustc-std-workspace-alloc",
|
"rustc-std-workspace-alloc",
|
||||||
"rustc-std-workspace-core",
|
"rustc-std-workspace-core",
|
||||||
|
|||||||
@@ -84,12 +84,12 @@ wasip1 = { version = "1.0.0", features = [
|
|||||||
], default-features = false }
|
], default-features = false }
|
||||||
|
|
||||||
[target.'cfg(all(target_os = "wasi", target_env = "p2"))'.dependencies]
|
[target.'cfg(all(target_os = "wasi", target_env = "p2"))'.dependencies]
|
||||||
wasip2 = { version = '1.0.2', features = [
|
wasip2 = { version = '1.0.3', features = [
|
||||||
'rustc-dep-of-std',
|
'rustc-dep-of-std',
|
||||||
], default-features = false }
|
], default-features = false }
|
||||||
|
|
||||||
[target.'cfg(all(target_os = "wasi", target_env = "p3"))'.dependencies]
|
[target.'cfg(all(target_os = "wasi", target_env = "p3"))'.dependencies]
|
||||||
wasip2 = { version = '1.0.2', features = [
|
wasip3 = { version = '0.6.0', features = [
|
||||||
'rustc-dep-of-std',
|
'rustc-dep-of-std',
|
||||||
], default-features = false }
|
], default-features = false }
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@
|
|||||||
pub use wasip1::*;
|
pub use wasip1::*;
|
||||||
}
|
}
|
||||||
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
|
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
|
||||||
mod wasip2;
|
mod wasi;
|
||||||
pub use wasip2::*;
|
pub use wasi::*;
|
||||||
}
|
}
|
||||||
target_os = "xous" => {
|
target_os = "xous" => {
|
||||||
mod xous;
|
mod xous;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#[cfg(target_env = "p2")]
|
||||||
|
use wasip2 as wasi;
|
||||||
|
#[cfg(target_env = "p3")]
|
||||||
|
use wasip3 as wasi;
|
||||||
|
|
||||||
|
pub use super::common::Args;
|
||||||
|
|
||||||
|
/// Returns the command line arguments
|
||||||
|
pub fn args() -> Args {
|
||||||
|
Args::new(wasi::cli::environment::get_arguments().into_iter().map(|arg| arg.into()).collect())
|
||||||
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
pub use super::common::Args;
|
|
||||||
|
|
||||||
/// Returns the command line arguments
|
|
||||||
pub fn args() -> Args {
|
|
||||||
Args::new(wasip2::cli::environment::get_arguments().into_iter().map(|arg| arg.into()).collect())
|
|
||||||
}
|
|
||||||
@@ -95,8 +95,8 @@
|
|||||||
pub use wasip1::fill_bytes;
|
pub use wasip1::fill_bytes;
|
||||||
}
|
}
|
||||||
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
|
all(target_os = "wasi", any(target_env = "p2", target_env = "p3")) => {
|
||||||
mod wasip2;
|
mod wasi;
|
||||||
pub use wasip2::{fill_bytes, hashmap_random_keys};
|
pub use wasi::{fill_bytes, hashmap_random_keys};
|
||||||
}
|
}
|
||||||
target_os = "zkvm" => {
|
target_os = "zkvm" => {
|
||||||
mod zkvm;
|
mod zkvm;
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#[cfg(target_env = "p2")]
|
||||||
|
use wasip2::random::{insecure_seed::insecure_seed as get_insecure_seed, random::get_random_bytes};
|
||||||
|
#[cfg(target_env = "p3")]
|
||||||
|
use wasip3::random::{insecure_seed::get_insecure_seed, random::get_random_bytes};
|
||||||
|
|
||||||
|
pub fn fill_bytes(bytes: &mut [u8]) {
|
||||||
|
bytes.copy_from_slice(&get_random_bytes(u64::try_from(bytes.len()).unwrap()));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn hashmap_random_keys() -> (u64, u64) {
|
||||||
|
get_insecure_seed()
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
pub fn fill_bytes(bytes: &mut [u8]) {
|
|
||||||
bytes.copy_from_slice(&wasip2::random::random::get_random_bytes(
|
|
||||||
u64::try_from(bytes.len()).unwrap(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn hashmap_random_keys() -> (u64, u64) {
|
|
||||||
wasip2::random::insecure_seed::insecure_seed()
|
|
||||||
}
|
|
||||||
@@ -541,6 +541,7 @@ pub(crate) struct WorkspaceInfo<'a> {
|
|||||||
"vex-sdk",
|
"vex-sdk",
|
||||||
"wasip1",
|
"wasip1",
|
||||||
"wasip2",
|
"wasip2",
|
||||||
|
"wasip3",
|
||||||
"windows-link",
|
"windows-link",
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
"windows-targets",
|
"windows-targets",
|
||||||
|
|||||||
Reference in New Issue
Block a user