Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename wasm32-wasi to wasm32-wasip1 #93

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
Expand Down Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,21 @@
//!
//! 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
//! [Wasmtime's release page][adapters] as
//! [`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
//! ```
Expand Down Expand Up @@ -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.
///
Expand Down