Skip to content

Commit

Permalink
fix: enable wasip2 feature for wasm32-wasip2 target (#305)
Browse files Browse the repository at this point in the history
- wasip2 will require +nightly until rust-lang/rust#130323 is resolved and/or std::os::wasip2 is available in stable.
- Support was added to rustix for version 0.38.39 bytecodealliance/rustix#1205

Signed-off-by: Colin Murphy <cdmurph32@gmail.com>
Co-authored-by: Steven Allen <steven@stebalien.com>
  • Loading branch information
cdmurph32 and Stebalien authored Nov 8, 2024
1 parent f162807 commit a23f396
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit a23f396

Please sign in to comment.