Skip to content

Commit

Permalink
Rename the wasm32-wasi target to wasm32-wasip1 (bytecodealliance#…
Browse files Browse the repository at this point in the history
…8867)

This rename is happening in upstream Rust and should be in enough places
now.

prtest:full
  • Loading branch information
alexcrichton authored Jul 25, 2024
1 parent 6d279d2 commit 05095c1
Show file tree
Hide file tree
Showing 32 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ runs:

- name: Install the WASI target
shell: bash
run: rustup target add wasm32-wasi wasm32-unknown-unknown
run: rustup target add wasm32-wasip1 wasm32-unknown-unknown
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ jobs:
toolchain: ${{ matrix.rust }}

# Install targets in order to build various tests throughout the repo
- run: rustup target add wasm32-wasi wasm32-unknown-unknown ${{ matrix.target }}
- run: rustup target add wasm32-wasip1 wasm32-unknown-unknown ${{ matrix.target }}
- run: echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
if: matrix.target != ''

Expand Down Expand Up @@ -715,7 +715,7 @@ jobs:
if: (matrix.os == 'windows-latest') && (matrix.feature == 'winml')

# Install Rust targets.
- run: rustup target add wasm32-wasi
- run: rustup target add wasm32-wasip1

# Run the tests!
- run: cargo test -p wasmtime-wasi-nn --features ${{ matrix.feature }}
Expand Down Expand Up @@ -765,7 +765,7 @@ jobs:
with:
submodules: true
- uses: ./.github/actions/install-rust
- run: rustup target add wasm32-wasi wasm32-unknown-unknown
- run: rustup target add wasm32-wasip1 wasm32-unknown-unknown
- run: |
sudo apt-get update && sudo apt-get install -y gdb lldb-15 llvm
# workaround for https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1972855
Expand Down Expand Up @@ -795,7 +795,7 @@ jobs:
with:
submodules: true
- uses: ./.github/actions/install-rust
- run: rustup target add wasm32-wasi wasm32-unknown-unknown
- run: rustup target add wasm32-wasip1 wasm32-unknown-unknown

- name: Install wasm-tools
run: |
Expand Down Expand Up @@ -881,8 +881,8 @@ jobs:
with:
submodules: true
- uses: ./.github/actions/install-rust
- run: rustup target add wasm32-wasi wasm32-unknown-unknown
- run: cargo build --target wasm32-wasi --no-default-features --features compile,cranelift,all-arch
- run: rustup target add wasm32-wasip1 wasm32-unknown-unknown
- run: cargo build --target wasm32-wasip1 --no-default-features --features compile,cranelift,all-arch
env:
VERSION: ${{ github.sha }}

Expand All @@ -903,7 +903,7 @@ jobs:
with:
submodules: true
- uses: ./.github/actions/install-rust
- run: rustup target add wasm32-wasi
- run: rustup target add wasm32-wasip1
- run: cargo test --benches --release

# common logic to cancel the entire run if this job fails
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ fn main() {
and compile/run it with:

```sh
$ rustup target add wasm32-wasi
$ rustc hello.rs --target wasm32-wasi
$ rustup target add wasm32-wasip1
$ rustc hello.rs --target wasm32-wasip1
$ wasmtime hello.wasm
Hello, world!
```
Expand Down
6 changes: 3 additions & 3 deletions benches/instantiation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,19 @@ fn build_wasi_example() {
"-p",
"example-wasi-wasm",
"--target",
"wasm32-wasi",
"wasm32-wasip1",
])
.spawn()
.expect("failed to run cargo to build WASI example")
.wait()
.expect("failed to wait for cargo to build")
.success()
{
panic!("failed to build WASI example for target `wasm32-wasi`");
panic!("failed to build WASI example for target `wasm32-wasip1`");
}

std::fs::copy(
"target/wasm32-wasi/release/wasi.wasm",
"target/wasm32-wasip1/release/wasi.wasm",
"benches/instantiation/wasi.wasm",
)
.expect("failed to copy WASI example module");
Expand Down
4 changes: 2 additions & 2 deletions crates/test-programs/artifacts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn build_and_generate_tests() {
// Build the test programs:
let mut cmd = cargo();
cmd.arg("build")
.arg("--target=wasm32-wasi")
.arg("--target=wasm32-wasip1")
.arg("--package=test-programs")
.env("CARGO_TARGET_DIR", &out_dir)
.env("CARGO_PROFILE_DEV_DEBUG", "2")
Expand Down Expand Up @@ -59,7 +59,7 @@ fn build_and_generate_tests() {
for target in targets {
let camel = target.to_shouty_snake_case();
let wasm = out_dir
.join("wasm32-wasi")
.join("wasm32-wasip1")
.join("debug")
.join(format!("{target}.wasm"));

Expand Down
4 changes: 2 additions & 2 deletions crates/wasi-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ so stay tuned!

## Development hints
When testing the crate, you may want to enable and run full wasm32 integration testsuite. This
requires `wasm32-wasi` target installed which can be done as follows using [rustup]
requires `wasm32-wasip1` target installed which can be done as follows using [rustup]

```
rustup target add wasm32-wasi
rustup target add wasm32-wasip1
```

[rustup]: https://rustup.rs
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-nn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ To use the WIT-based ABI, compile with `--features component-model` and use `was

An end-to-end example demonstrating ML classification is included in [examples]:
`examples/classification-example` contains a standalone Rust project that uses
the [wasi-nn] APIs and is compiled to the `wasm32-wasi` target using the
the [wasi-nn] APIs and is compiled to the `wasm32-wasip1` target using the
high-level `wasi-nn` [bindings].
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ndarray = "0.15.3"



# This crate is built with the wasm32-wasi target, so it's separate
# This crate is built with the wasm32-wasip1 target, so it's separate
# from the main Wasmtime build, so use this directive to exclude it
# from the parent directory's workspace.
[workspace]
10 changes: 5 additions & 5 deletions crates/wasi-nn/examples/classification-component-onnx/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Onnx Backend Classification Component Example

This example demonstrates how to use the `wasi-nn` crate to run a classification using the
This example demonstrates how to use the `wasi-nn` crate to run a classification using the
[ONNX Runtime](https://onnxruntime.ai/) backend from a WebAssembly component.

## Build
Expand All @@ -15,9 +15,9 @@ In the wasmtime root directory, run the following command to build the wasmtime
cargo build --features component-model,wasi-nn,wasmtime-wasi-nn/onnx

# run the component with wasmtime
./target/debug/wasmtime run \
--wasm-features component-model \
./target/debug/wasmtime run \
--wasm-features component-model \
--wasi-modules=experimental-wasi-nn \
--mapdir fixture::./crates/wasi-nn/examples/classification-component-onnx/fixture \
./crates/wasi-nn/examples/classification-component-onnx/target/wasm32-wasi/debug/classification_component_onnx.wasm
```
./crates/wasi-nn/examples/classification-component-onnx/target/wasm32-wasip1/debug/classification_component_onnx.wasm
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false
[dependencies]
wasi-nn = "0.5.0"

# This crate is built with the wasm32-wasi target, so it's separate
# This crate is built with the wasm32-wasip1 target, so it's separate
# from the main Wasmtime build, so use this directive to exclude it
# from the parent directory's workspace.
[workspace]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This example project demonstrates using the `wasi-nn` API to perform ML inference. It consists of Rust code that is
built using the `wasm32-wasi` target. See `ci/run-wasi-nn-example.sh` for how this is used.
This example project demonstrates using the `wasi-nn` API to perform ML inference. It consists of Rust code that is
built using the `wasm32-wasip1` target. See `ci/run-wasi-nn-example.sh` for how this is used.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ wasi-nn = "0.6.0"
image = { version = "0.24.6", default-features = false, features = ["png"] }
ndarray = "0.15.3"

# This crate is built with the wasm32-wasi target, so it's separate
# This crate is built with the wasm32-wasip1 target, so it's separate
# from the main Wasmtime build, so use this directive to exclude it
# from the parent directory's workspace.
[workspace]
10 changes: 5 additions & 5 deletions crates/wasi-nn/examples/classification-example-winml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ To run this example, perform the following steps on Windows 10 v1803 and later:
set PROJECT_DIR=%CD%
cd crates\wasi-nn\examples\classification-example-winml
```
1. Install the `wasm32-wasi` Rust target:
1. Install the `wasm32-wasip1` Rust target:
```
rustup target add wasm32-wasi
rustup target add wasm32-wasip1
```
1. Compile this example; the `wasm32-wasi` output is a WebAssembly file:
1. Compile this example; the `wasm32-wasip1` output is a WebAssembly file:
```
cargo build --release --target=wasm32-wasi
cargo build --release --target=wasm32-wasip1
```
1. Run the sample; the fixture directory containing the model and image must be
mapped in to be accessible to WebAssembly.
```
%PROJECT_DIR%\target\release\wasmtime.exe --dir fixture::fixture -S nn target\wasm32-wasi\release\wasi-nn-example-winml.wasm
%PROJECT_DIR%\target\release\wasmtime.exe --dir fixture::fixture -S nn target\wasm32-wasip1\release\wasi-nn-example-winml.wasm
```
1. The example will print the top 5 classification results. To run with a
different image or ONNX model, modify the files in the `fixture` directory
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-nn/examples/classification-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false
[dependencies]
wasi-nn = "0.1.0"

# This crate is built with the wasm32-wasi target, so it's separate
# This crate is built with the wasm32-wasip1 target, so it's separate
# from the main Wasmtime build, so use this directive to exclude it
# from the parent directory's workspace.
[workspace]
4 changes: 2 additions & 2 deletions crates/wasi-nn/examples/classification-example/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This example project demonstrates using the `wasi-nn` API to perform ML inference. It consists of Rust code that is
built using the `wasm32-wasi` target. See `ci/run-wasi-nn-example.sh` for how this is used.
This example project demonstrates using the `wasi-nn` API to perform ML inference. It consists of Rust code that is
built using the `wasm32-wasip1` target. See `ci/run-wasi-nn-example.sh` for how this is used.
2 changes: 1 addition & 1 deletion crates/wasi-preview1-component-adapter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $ cat foo.rs
fn main() {
println!("Hello, world!");
}
$ rustc foo.rs --target wasm32-wasi
$ rustc foo.rs --target wasm32-wasip1
$ wasm-tools print foo.wasm | grep '(import'
(import "wasi_snapshot_preview1" "fd_write" (func ...
(import "wasi_snapshot_preview1" "environ_get" (func ...
Expand Down
8 changes: 4 additions & 4 deletions docs/WASI-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ Let's put this source in the main file of our crate `src/main.rs`.
In order to build it, we first need to install a WASI-enabled Rust toolchain:

```
$ rustup target add wasm32-wasi
$ cargo build --target wasm32-wasi
$ rustup target add wasm32-wasip1
$ cargo build --target wasm32-wasip1
```

We should now have the WebAssembly module created in `target/wasm32-wasi/debug`:
We should now have the WebAssembly module created in `target/wasm32-wasip1/debug`:

```
$ file target/wasm32-wasi/debug/demo.wasm
$ file target/wasm32-wasip1/debug/demo.wasm
demo.wasm: WebAssembly (wasm) binary module version 0x1 (MVP)
```

Expand Down
6 changes: 3 additions & 3 deletions docs/contributing-implementing-wasm-proposals.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ The [cap-std](https://github.com/bytecodealliance/cap-std) repository contains
crates which implement the capability-based version of the Rust standard library
and extensions to that functionality. Once the functionality has been added to
the relevant crates of that repository, they can be added into wasmtime by
including them in the preview2 directory of the [wasi crate](https://github.com/bytecodealliance/wasmtime/tree/main/crates/wasi).
including them in the preview2 directory of the [wasi crate](https://github.com/bytecodealliance/wasmtime/tree/main/crates/wasi).

Currently, WebAssembly modules which rely on preview2 ABI cannot be directly
executed by the wasmtime command. The following steps allow for testing such
Expand All @@ -139,11 +139,11 @@ changes.
1. Build wasmtime with the changes `cargo build --release`

2. Create a simple Webassembly module to test the new component functionality by
compiling your test code to the `wasm32-wasi` build target.
compiling your test code to the `wasm32-wasip1` build target.

3. Build the [wasi-preview1-component-adapter](https://github.com/bytecodealliance/wasmtime/tree/main/crates/wasi-preview1-component-adapter)
as a command adapter. `cargo build -p wasi-preview1-component-adapter --target
wasm32-wasi --release --features command --no-default-features`
wasm32-wasip1 --release --features command --no-default-features`

4. Use [wasm-tools](https://github.com/bytecodealliance/wasm-tools) to convert
the test module to a component. `wasm-tools component new --adapt
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ can't build it!

## Installing `wasm32` Targets

To compile the tests, you'll need the `wasm32-wasi` and
To compile the tests, you'll need the `wasm32-wasip1` and
`wasm32-unknown-unknown` targets installed, which, assuming you're using
[rustup.rs](https://rustup.rs) to manage your Rust versions, can be done as
follows:

```shell
rustup target add wasm32-wasi wasm32-unknown-unknown
rustup target add wasm32-wasip1 wasm32-unknown-unknown
```

## Running All Tests
Expand Down
2 changes: 1 addition & 1 deletion docs/examples-coredump.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The following steps describe how to debug using Wasm coredump in Wasmtime:
1. Compile your WebAssembly with debug info enabled; for example:

```sh
$ rustc foo.rs --target=wasm32-wasi -C debuginfo=2
$ rustc foo.rs --target=wasm32-wasip1 -C debuginfo=2
```

<details>
Expand Down
2 changes: 1 addition & 1 deletion docs/examples-debugging-core-dumps.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn baz(x: u32) {
We can compile it to Wasm with the following command:

```shell-session
$ rustc --target wasm32-wasi -o ./trap.wasm ./trap.rs
$ rustc --target wasm32-wasip1 -o ./trap.wasm ./trap.rs
```

Next, we can run it in Wasmtime and capture a core dump when it traps:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples-profiling-perf.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn fib(n: u32) -> u32 {
To collect perf information for this wasm module we'll execute:

```sh
$ rustc --target wasm32-wasi fib.rs -O
$ rustc --target wasm32-wasip1 fib.rs -O
$ perf record -k mono wasmtime --profile=jitdump fib.wasm
fib(42) = 267914296
[ perf record: Woken up 1 times to write data ]
Expand Down
4 changes: 2 additions & 2 deletions docs/examples-profiling-vtune.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn fib(n: u32) -> u32 {
We compile the example to Wasm:

```sh
$ rustc --target wasm32-wasi fib.rs -C opt-level=z -C lto=yes
$ rustc --target wasm32-wasip1 fib.rs -C opt-level=z -C lto=yes
```

Then we execute the Wasmtime runtime (built with the `vtune` feature and
Expand All @@ -101,7 +101,7 @@ application, `vtune`, which must already be installed and available on the
path. To collect hot spot profiling information, we execute:

```sh
$ rustc --target wasm32-wasi fib.rs -C opt-level=z -C lto=yes
$ rustc --target wasm32-wasip1 fib.rs -C opt-level=z -C lto=yes
$ vtune -run-pass-thru=--no-altstack -v -collect hotspots target/debug/wasmtime --profile=vtune fib.wasm
fib(45) = 1134903170
amplxe: Collection stopped.
Expand Down
6 changes: 3 additions & 3 deletions docs/examples-rust-wasi.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ WebAssembly module.

### WebAssembly module source code

For this WASI example, this Hello World program is compiled to a WebAssembly module using the WASI Preview 1 API.
For this WASI example, this Hello World program is compiled to a WebAssembly module using the WASI Preview 1 API.

`wasi.rs`
```rust
{{#include ../examples/wasi/wasm/wasi.rs}}
```

Building this program generates `target/wasm32-wasi/debug/wasi.wasm`, used below.
Building this program generates `target/wasm32-wasip1/debug/wasi.wasm`, used below.

### Invoke the WASM module

Expand Down Expand Up @@ -98,4 +98,4 @@ This does not require any change to the WebAssembly module, it's just the WASI A
```

You can also [browse this source code online][code2] and clone the wasmtime
repository to run the example locally.
repository to run the example locally.
2 changes: 1 addition & 1 deletion docs/stability-tiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ For explanations of what each tier means see below.
|----------------------|-----------------------------------|-----------------------------|
| Target | `aarch64-pc-windows-msvc` | CI testing, unwinding, full-time maintainer |
| Target | `riscv64gc-unknown-linux-gnu` | full-time maintainer |
| Target | `wasm32-wasi` [^3] | Supported but not tested |
| Target | `wasm32-wasip1` [^3] | Supported but not tested |
| Target | `aarch64-linux-android` | CI testing, full-time maintainer |
| Target | `x86_64-linux-android` | CI testing, full-time maintainer |
| Target | `x86_64-unknown-linux-musl` [^4] | CI testing, full-time maintainer |
Expand Down
4 changes: 2 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ create_target(wasi wasi/main.c)
# Add rust tests
create_rust_test(anyref)
create_rust_wasm(fib-debug wasm32-unknown-unknown)
create_rust_wasm(tokio wasm32-wasi)
create_rust_wasm(wasi wasm32-wasi)
create_rust_wasm(tokio wasm32-wasip1)
create_rust_wasm(wasi wasm32-wasip1)
create_rust_wasm(component wasm32-unknown-unknown)
create_rust_test(epochs)
create_rust_test(externref)
Expand Down
2 changes: 1 addition & 1 deletion examples/component/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() -> Result<()> {
let engine = Engine::new(Config::new().wasm_component_model(true))?;

// NOTE: The wasm32-unknown-unknown target is used here for simplicity, real world use cases
// should probably use the wasm32-wasi target, and enable wasi preview2 within the component
// should probably use the wasm32-wasip1 target, and enable wasi preview2 within the component
// model.
let component = convert_to_component("target/wasm32-unknown-unknown/debug/guest.wasm")?;

Expand Down
Loading

0 comments on commit 05095c1

Please sign in to comment.