From 0255a80f02ad08178083a9ef9f99989115dcf118 Mon Sep 17 00:00:00 2001 From: Colin Murphy Date: Wed, 6 Nov 2024 09:20:12 -0500 Subject: [PATCH 1/4] fix: enable wasip2 feature for wasm32-wasip2 target Signed-off-by: Colin Murphy --- Cargo.toml | 2 +- src/lib.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index dd9a0d4d4..6bc5e0d3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ fastrand = "2.1.1" once_cell = { version = "1.19.0", default-features = false, features = ["std"] } [target.'cfg(any(unix, target_os = "wasi"))'.dependencies] -rustix = { version = "0.38.37", features = ["fs"] } +rustix = { version = "0.38.39", features = ["fs"] } [target.'cfg(windows)'.dependencies.windows-sys] version = ">=0.52,<=0.59" diff --git a/src/lib.rs b/src/lib.rs index 459afbec5..ea4933856 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,6 @@ +// wasip2 conditionally gates stdlib APIs. +// https://github.com/rust-lang/rust/issues/130323 +#![cfg_attr(all(target_os = "wasi", target_env = "p2"), feature(wasip2))] //! Temporary files and directories. //! //! - Use the [`tempfile()`] function for temporary files From e88071820d964790b3aeb2055adb75cffa121e1f Mon Sep 17 00:00:00 2001 From: Colin Murphy Date: Wed, 6 Nov 2024 09:15:08 -0500 Subject: [PATCH 2/4] Add "unstable" feature for wasip2 stdlib Signed-off-by: Colin Murphy --- Cargo.toml | 1 + src/lib.rs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6bc5e0d3e..d300b3dfa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,3 +37,4 @@ doc-comment = "0.3" [features] nightly = [] +unstable = [] diff --git a/src/lib.rs b/src/lib.rs index ea4933856..ada014e20 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,9 @@ // wasip2 conditionally gates stdlib APIs. // https://github.com/rust-lang/rust/issues/130323 -#![cfg_attr(all(target_os = "wasi", target_env = "p2"), feature(wasip2))] +#![cfg_attr( + all(target_os = "wasi", target_env = "p2", feature = "unstable"), + feature(wasip2) +)] //! Temporary files and directories. //! //! - Use the [`tempfile()`] function for temporary files From 90cb622b88e647fe6729be3fcc8766842ded0688 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 7 Nov 2024 10:50:01 +0700 Subject: [PATCH 3/4] switch from unstable feature to nightly feature I forgot we had this feature already (and it's already being used for wasi-related things anyways). --- Cargo.toml | 1 - src/lib.rs | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d300b3dfa..6bc5e0d3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,4 +37,3 @@ doc-comment = "0.3" [features] nightly = [] -unstable = [] diff --git a/src/lib.rs b/src/lib.rs index ada014e20..4f5a8bb4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,3 @@ -// wasip2 conditionally gates stdlib APIs. -// https://github.com/rust-lang/rust/issues/130323 -#![cfg_attr( - all(target_os = "wasi", target_env = "p2", feature = "unstable"), - feature(wasip2) -)] //! Temporary files and directories. //! //! - Use the [`tempfile()`] function for temporary files @@ -142,6 +136,12 @@ #![cfg_attr(test, deny(warnings))] #![deny(rust_2018_idioms)] #![allow(clippy::redundant_field_names)] +// wasip2 conditionally gates stdlib APIs. +// https://github.com/rust-lang/rust/issues/130323 +#![cfg_attr( + all(feature = "nightly", target_os = "wasi", target_env = "p2"), + feature(wasip2) +)] #![cfg_attr(all(feature = "nightly", target_os = "wasi"), feature(wasi_ext))] #[cfg(doctest)] From 02887e92856ac4624e661e3971f72323f50184df Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 8 Nov 2024 08:20:02 +0700 Subject: [PATCH 4/4] ci: test wasip2 --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8975f2b94..e300a66bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,6 +57,18 @@ jobs: targets: wasm32-wasip1 - name: Build run: cargo build --target wasm32-wasip1 --features nightly + wasip2: + name: WASI P2 Test Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@nightly + with: + targets: wasm32-wasip2 + - name: Build + run: cargo build --target wasm32-wasip2 --features nightly wasm: name: WASM Test Build runs-on: ubuntu-latest