From 94e50002c0d3691f54ad370eb2d10ddad4c2777b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 24 Jun 2024 13:10:43 -0500 Subject: [PATCH] Rename `wasm32-wasi` to `wasm32-wasip1` (#93) Update CI and a few strings of documentation here and there. --- .github/workflows/main.yml | 18 +++++++++--------- README.md | 22 ++++++++++------------ src/lib.rs | 15 +++++++-------- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 26524c5..936a634 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,11 +12,11 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }} && rustup component add rustfmt - - run: rustup target add wasm32-wasi wasm32-unknown-unknown + - run: rustup target add wasm32-wasip1 wasm32-unknown-unknown - run: cargo build --workspace - run: cargo build --workspace --no-default-features - - run: cargo build --workspace --target wasm32-wasi - - run: cargo build --workspace --target wasm32-wasi --no-default-features + - run: cargo build --workspace --target wasm32-wasip1 + - run: cargo build --workspace --target wasm32-wasip1 --no-default-features - run: cargo test --workspace --doc - name: Install Wasmtime uses: bytecodealliance/actions/wasmtime/setup@v1 @@ -28,9 +28,9 @@ jobs: version: "1.202.0" - run: curl -LO https://github.com/bytecodealliance/wasmtime/releases/download/v19.0.0/wasi_snapshot_preview1.command.wasm - - run: cargo build --examples --target wasm32-wasi --no-default-features + - run: cargo build --examples --target wasm32-wasip1 --no-default-features - - run: wasm-tools component new ./target/wasm32-wasi/debug/examples/hello-world-no_std.wasm --adapt ./wasi_snapshot_preview1.command.wasm -o component.wasm + - run: wasm-tools component new ./target/wasm32-wasip1/debug/examples/hello-world-no_std.wasm --adapt ./wasi_snapshot_preview1.command.wasm -o component.wasm - run: wasmtime run component.wasm - run: cargo build --examples --target wasm32-unknown-unknown --no-default-features @@ -41,9 +41,9 @@ jobs: - run: wasm-tools component new ./target/wasm32-unknown-unknown/debug/examples/http_proxy_no_std.wasm -o component.wasm - run: wasm-tools component targets wit component.wasm -w wasi:http/proxy - - run: cargo build --examples --target wasm32-wasi + - run: cargo build --examples --target wasm32-wasip1 - - run: wasm-tools component new ./target/wasm32-wasi/debug/examples/hello-world.wasm --adapt ./wasi_snapshot_preview1.command.wasm -o component.wasm + - run: wasm-tools component new ./target/wasm32-wasip1/debug/examples/hello-world.wasm --adapt ./wasi_snapshot_preview1.command.wasm -o component.wasm - run: wasmtime run component.wasm - run: cargo build --examples --target wasm32-unknown-unknown @@ -54,9 +54,9 @@ jobs: - run: wasm-tools component new ./target/wasm32-unknown-unknown/debug/examples/http_proxy.wasm -o component.wasm - run: wasm-tools component targets wit component.wasm -w wasi:http/proxy - - run: cargo build --examples --workspace --target wasm32-wasi --features rand + - run: cargo build --examples --workspace --target wasm32-wasip1 --features rand - - run: wasm-tools component new ./target/wasm32-wasi/debug/examples/rand.wasm --adapt ./wasi_snapshot_preview1.command.wasm -o component.wasm + - run: wasm-tools component new ./target/wasm32-wasip1/debug/examples/rand.wasm --adapt ./wasi_snapshot_preview1.command.wasm -o component.wasm - run: wasmtime run component.wasm rustfmt: diff --git a/README.md b/README.md index 45b0a79..0914bb6 100644 --- a/README.md +++ b/README.md @@ -47,11 +47,11 @@ fn main() { ``` This crate is intended to target [components] but today you need to go through -the intermediate build step of a core WebAssembly module using the `wasm32-wasi` +the intermediate build step of a core WebAssembly module using the `wasm32-wasip1` target: ``` -$ cargo build --target wasm32-wasi +$ cargo build --target wasm32-wasip1 ``` Next you'll want an "adapter" to convert the Rust standard library's usage of @@ -67,7 +67,7 @@ component: ``` $ cargo install wasm-tools -$ wasm-tools component new target/wasm32-wasi/debug/foo.wasm \ +$ wasm-tools component new target/wasm32-wasip1/debug/foo.wasm \ --adapt ./wasi_snapshot_preview1.command.wasm \ -o component.wasm ``` @@ -109,19 +109,17 @@ want to support. Rust WebAssembly targets include: * `wasm32-unknown-unknown` - do not use this crate because this target indicates that WASI is not desired. -* `wasm32-wasi` or `wasm32-wasip1` - this target has been present in Rust for - quite some time and is recently being renamed from `wasm32-wasi` to - `wasm32-wasip1`. The two targets have the same definition, it's just the name - that's changing. For this target you probably want the 0.11.0 track of this - crate. +* `wasm32-wasip1` - this target has been present in Rust for quite some time and + was previously known as `wasm32-wasi`. For this target you probably want the + 0.11.0 track of this crate. * `wasm32-wasip2` - this target is a recent addition to rustc (as of the time of this writing it's not merged yet into rustc). This is what the 0.12.0 version of the crate is intended for. -Note that if you use `wasm32-wasi` or `wasm32-wasip1` it's not necessarily -guaranteed you want 0.11.0 of this crate. If your users are producing components -then you probably want 0.12.0 instead. If you don't know what your users are -producing then you should probably stick with 0.11.0. +Note that if you use `wasm32-wasip1` it's not necessarily guaranteed you want +0.11.0 of this crate. If your users are producing components then you probably +want 0.12.0 instead. If you don't know what your users are producing then you +should probably stick with 0.11.0. Long story short, it's a bit complicated. We're in a transition period from WASIp1 to WASIp2 and things aren't going to be perfect every step of the way, so diff --git a/src/lib.rs b/src/lib.rs index 7b829c8..03cc388 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -127,14 +127,13 @@ //! //! This crate is intended to be easiest to use with a future //! `wasm32-wasip2` target added to the Rust compiler. In the meantime -//! it's recommended to use the `wasm32-wasi` target (soon to be renamed to -//! `wasm32-wasip1`) instead: +//! it's recommended to use the `wasm32-wasip1` target instead: //! //! ```sh -//! $ cargo build --target wasm32-wasi +//! $ cargo build --target wasm32-wasip1 //! ``` //! -//! Note that the output of the `wasm32-wasi` target is a core wasm module, not +//! Note that the output of the `wasm32-wasip1` target is a core wasm module, not //! a component, so to turn it into a component you can use the [`wasm-tools`] //! CLI in combination with an "adapter module" for the `wasi_snapshot_preview1` //! APIs that the Rust standard library uses (example adapters can be found on @@ -142,7 +141,7 @@ //! [`wasi_snapshot_preview1.command.wasm`] for example) //! //! ```sh -//! $ wasm-tools component new ./target/wasm32-wasi/debug/my-app.wasm \ +//! $ wasm-tools component new ./target/wasm32-wasip1/debug/my-app.wasm \ //! --adapt ./wasi_snapshot_preview1.command.wasm \ //! -o my-component.wasm //! ``` @@ -221,10 +220,10 @@ pub mod cli { /// wasi::cli::command::export!(MyCliRunner); /// ``` /// - /// ## Compatibility with `wasm32-wasi` targets + /// ## Compatibility with `wasm32-wasip1` targets /// - /// This macro is not compatible with `wasm32-wasi` `bin` targets which - /// instead use a `fn main()` with the + /// This macro is not compatible with `wasm32-wasip1` `bin` targets + /// which instead use a `fn main()` with the /// `wasi_snapshot_preview1.command.wasm` adapter. This macro _can_ be /// used with the `reactor` or `proxy` adapters. ///