From a23f396ede61a989ed48c1906c07f20d03d04ff2 Mon Sep 17 00:00:00 2001 From: Colin D Murphy Date: Thu, 7 Nov 2024 20:24:51 -0500 Subject: [PATCH] fix: enable wasip2 feature for wasm32-wasip2 target (#305) - wasip2 will require +nightly until https://github.com/rust-lang/rust/issues/130323 is resolved and/or std::os::wasip2 is available in stable. - Support was added to rustix for version 0.38.39 https://github.com/bytecodealliance/rustix/pull/1205 Signed-off-by: Colin Murphy Co-authored-by: Steven Allen --- .github/workflows/ci.yml | 12 ++++++++++++ Cargo.toml | 2 +- src/lib.rs | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) 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 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..4f5a8bb4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -136,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)]