Skip to content

Commit abba523

Browse files
authored
Merge pull request #2948 from vdice/ref/wasm32-wasip1-updates
ref(*): replace wasm32-wasi with wasm32-wasip1
2 parents cda78d0 + 9ece312 commit abba523

File tree

31 files changed

+534
-87
lines changed

31 files changed

+534
-87
lines changed

.devcontainer/bootstrap.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
rustup update stable && rustup default stable && rustup component add clippy rustfmt
33

44
# Installs wasm32 compiler targets
5-
rustup target add wasm32-wasi wasm32-unknown-unknown
5+
rustup target add wasm32-wasip1 wasm32-unknown-unknown

.github/actions/spin-ci-dependencies/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ runs:
9595
rustup default ${{ inputs.rust-version }}
9696
9797
- name: "Install Wasm Rust target"
98-
run: rustup target add wasm32-wasi wasm32-wasip1 wasm32-unknown-unknown
98+
run: rustup target add wasm32-wasip1 wasm32-unknown-unknown
9999
if: ${{ inputs.rust-wasm == 'true' }}
100100
shell: bash
101101

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ jobs:
196196

197197
# Install all the toolchain dependencies
198198
- name: Install Rust wasm target
199-
run: rustup target add wasm32-wasi wasm32-wasip1 wasm32-unknown-unknown
199+
run: rustup target add wasm32-wasip1 wasm32-unknown-unknown
200200
- uses: goto-bus-stop/setup-zig@v2
201201
- uses: actions/setup-go@v4
202202
with:
@@ -281,7 +281,7 @@ jobs:
281281
run: rustup target add --toolchain ${{ env.RUST_VERSION }} ${{ matrix.config.target }}
282282

283283
- name: "Install Wasm Rust target"
284-
run: rustup target add wasm32-wasi wasm32-wasip1 wasm32-unknown-unknown --toolchain ${{ env.RUST_VERSION }}
284+
run: rustup target add wasm32-wasip1 wasm32-unknown-unknown --toolchain ${{ env.RUST_VERSION }}
285285

286286
- name: setup for cross-compiled linux aarch64 build
287287
if: matrix.config.target == 'aarch64-unknown-linux-gnu'

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
run: rustup target add --toolchain ${{ env.RUST_VERSION }} ${{ matrix.config.target }}
104104

105105
- name: "Install Wasm Rust target"
106-
run: rustup target add wasm32-wasi wasm32-wasip1 wasm32-unknown-unknown --toolchain ${{ env.RUST_VERSION }}
106+
run: rustup target add wasm32-wasip1 wasm32-unknown-unknown --toolchain ${{ env.RUST_VERSION }}
107107

108108
- name: setup for cross-compiled linux aarch64 build
109109
if: matrix.config.target == 'aarch64-unknown-linux-gnu'

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ and then follow the
3939
language guides, and the [guide on writing Spin applications](https://developer.fermyon.com/spin/configuration/).
4040

4141
## Usage
42-
Below is an example of using the `spin` CLI to create a new Spin application. To run the example you will need to install the `wasm32-wasi` target for Rust.
42+
Below is an example of using the `spin` CLI to create a new Spin application. To run the example you will need to install the `wasm32-wasip1` target for Rust.
4343

4444
```bash
45-
$ rustup target add wasm32-wasi
45+
$ rustup target add wasm32-wasip1
4646
```
4747

4848
First, run the `spin new` command to create a Spin application from a template.
@@ -55,7 +55,7 @@ Running the `spin new` command created a `hello-rust` directory with all the nec
5555
```bash
5656
# Compile to Wasm by executing the `build` command.
5757
$ spin build
58-
Executing the build command for component hello-rust: cargo build --target wasm32-wasi --release
58+
Executing the build command for component hello-rust: cargo build --target wasm32-wasip1 --release
5959
Finished release [optimized] target(s) in 0.03s
6060
Successfully ran the build command for the Spin components.
6161

build.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ fn main() {
5858

5959
println!(
6060
r#"
61-
error: the `wasm32-wasi` target is not installed
62-
= help: consider downloading the target with `rustup{} target add wasm32-wasi`"#,
61+
error: the `wasm32-wasip1` target is not installed
62+
= help: consider downloading the target with `rustup{} target add wasm32-wasip1`"#,
6363
toolchain_override
6464
);
6565
process::exit(1);
@@ -75,7 +75,7 @@ error: the `wasm32-wasi` target is not installed
7575
fn build_wasm_test_program(name: &'static str, root: &'static str) {
7676
build_target_dep(root, Path::new("target/test-programs").join(name))
7777
.release()
78-
.target("wasm32-wasi")
78+
.target("wasm32-wasip1")
7979
.build();
8080
println!("cargo:rerun-if-changed={root}/Cargo.toml");
8181
println!("cargo:rerun-if-changed={root}/Cargo.lock");
@@ -85,7 +85,7 @@ fn build_wasm_test_program(name: &'static str, root: &'static str) {
8585
fn has_wasm32_wasi_target() -> bool {
8686
// Using rustc here for systems that don't have rustup
8787
let output = run(
88-
vec!["rustc", "--print=target-libdir", "--target=wasm32-wasi"],
88+
vec!["rustc", "--print=target-libdir", "--target=wasm32-wasip1"],
8989
None,
9090
None,
9191
);
@@ -110,7 +110,7 @@ fn cargo_build(dir: &str) {
110110
"cargo",
111111
"build",
112112
"--target",
113-
"wasm32-wasi",
113+
"wasm32-wasip1",
114114
"--release",
115115
// Ensure that even if `CARGO_TARGET_DIR` is set
116116
// that we're still building into the right dir.

crates/componentize/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ the original module exported.
1212
This crate requires a [Rust](https://rustup.rs/) installation v1.68 or later and a couple of Wasm targets:
1313

1414
```shell
15-
rustup target add wasm32-wasi
15+
rustup target add wasm32-wasip1
1616
rustup target add wasm32-unknown-unknown
1717
```
1818

crates/componentize/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ mod tests {
413413
run_spin(
414414
&fs::read(concat!(
415415
env!("OUT_DIR"),
416-
"/wasm32-wasi/release/rust_case_02.wasm"
416+
"/wasm32-wasip1/release/rust_case_02.wasm"
417417
))
418418
.await?,
419419
)
@@ -426,7 +426,7 @@ mod tests {
426426
run_spin(
427427
&fs::read(concat!(
428428
env!("OUT_DIR"),
429-
"/wasm32-wasi/release/rust_case_08.wasm"
429+
"/wasm32-wasip1/release/rust_case_08.wasm"
430430
))
431431
.await?,
432432
)
@@ -458,7 +458,7 @@ mod tests {
458458
run_command(
459459
&fs::read(concat!(
460460
env!("OUT_DIR"),
461-
"/wasm32-wasi/release/rust-command.wasm"
461+
"/wasm32-wasip1/release/rust-command.wasm"
462462
))
463463
.await?,
464464
)
@@ -471,7 +471,7 @@ mod tests {
471471
cmd.arg("build")
472472
.current_dir(format!("tests/{name}"))
473473
.arg("--release")
474-
.arg("--target=wasm32-wasi")
474+
.arg("--target=wasm32-wasip1")
475475
.env("CARGO_TARGET_DIR", out_dir);
476476

477477
let status = cmd.status().unwrap();
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
spin-abi-conformance.wasm: target/wasm32-wasi/release/spin-rust.wasm
1+
spin-abi-conformance.wasm: target/wasm32-wasip1/release/spin-rust.wasm
22
cp $< $@
33

4-
target/wasm32-wasi/release/spin-rust.wasm: src/main.rs Cargo.toml
5-
cargo build --target wasm32-wasi --release
4+
target/wasm32-wasip1/release/spin-rust.wasm: src/main.rs Cargo.toml
5+
cargo build --target wasm32-wasip1 --release
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[build]
2-
target = "wasm32-wasi"
2+
target = "wasm32-wasip1"

crates/doctor/src/rustlang/target.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ async fn diagnose_rust_wasi_target() -> Result<Vec<TargetDiagnosis>> {
3737
// - if rustup is not present, check if cargo is present
3838
// - if not, return RustNotInstalled
3939
// - if so, warn but return empty list (Rust is installed but not via rustup, so we can't perform a diagnosis - bit of an edge case this one, and the user probably knows what they're doing...?)
40-
// - if rustup is present but the list does not contain wasm32-wasi, return WasmTargetNotInstalled
41-
// - if the list does contain wasm32-wasi, return an empty list
40+
// - if rustup is present but the list does not contain wasm32-wasip1, return WasmTargetNotInstalled
41+
// - if the list does contain wasm32-wasip1, return an empty list
4242
// NOTE: this does not currently check against the Rust SDK MSRV - that could
4343
// be a future enhancement or separate diagnosis, but at least the Rust compiler
4444
// should give a clear error for that!
@@ -49,7 +49,7 @@ async fn diagnose_rust_wasi_target() -> Result<Vec<TargetDiagnosis>> {
4949
RustupStatus::RustupNotInstalled => match get_cargo_status().await? {
5050
CargoStatus::Installed => {
5151
terminal::warn!(
52-
"Spin Doctor can't determine if the Rust wasm32-wasi target is installed."
52+
"Spin Doctor can't determine if the Rust wasm32-wasip1 target is installed."
5353
);
5454
vec![]
5555
}
@@ -81,7 +81,7 @@ async fn get_rustup_target_status() -> Result<RustupStatus> {
8181
}
8282
Ok(output) => {
8383
let stdout = String::from_utf8_lossy(&output.stdout);
84-
if stdout.lines().any(|line| line == "wasm32-wasi") {
84+
if stdout.lines().any(|line| line == "wasm32-wasip1") {
8585
RustupStatus::AllInstalled
8686
} else {
8787
RustupStatus::WasiNotInstalled
@@ -119,7 +119,7 @@ async fn get_cargo_status() -> Result<CargoStatus> {
119119
pub enum TargetDiagnosis {
120120
/// Rust is not installed: neither cargo nor rustup is present
121121
RustNotInstalled,
122-
/// The Rust wasm32-wasi target is not installed: rustup is present but the target isn't
122+
/// The Rust wasm32-wasip1 target is not installed: rustup is present but the target isn't
123123
WasmTargetNotInstalled,
124124
}
125125

@@ -128,7 +128,7 @@ impl Diagnosis for TargetDiagnosis {
128128
match self {
129129
Self::RustNotInstalled => "The Rust compiler isn't installed".into(),
130130
Self::WasmTargetNotInstalled => {
131-
"The required Rust target 'wasm32-wasi' isn't installed".into()
131+
"The required Rust target 'wasm32-wasip1' isn't installed".into()
132132
}
133133
}
134134
}
@@ -142,16 +142,16 @@ impl Diagnosis for TargetDiagnosis {
142142
impl Treatment for TargetDiagnosis {
143143
fn summary(&self) -> String {
144144
match self {
145-
Self::RustNotInstalled => "Install the Rust compiler and the wasm32-wasi target",
146-
Self::WasmTargetNotInstalled => "Install the Rust wasm32-wasi target",
145+
Self::RustNotInstalled => "Install the Rust compiler and the wasm32-wasip1 target",
146+
Self::WasmTargetNotInstalled => "Install the Rust wasm32-wasip1 target",
147147
}
148148
.into()
149149
}
150150

151151
async fn dry_run(&self, _patient: &PatientApp) -> Result<String> {
152152
let message = match self {
153-
Self::RustNotInstalled => "Download and run the Rust installer from https://rustup.rs, with the `--target wasm32-wasi` option",
154-
Self::WasmTargetNotInstalled => "Run the following command:\n `rustup target add wasm32-wasi`",
153+
Self::RustNotInstalled => "Download and run the Rust installer from https://rustup.rs, with the `--target wasm32-wasip1` option",
154+
Self::WasmTargetNotInstalled => "Run the following command:\n `rustup target add wasm32-wasip1`",
155155
};
156156
Ok(message.into())
157157
}
@@ -184,7 +184,7 @@ async fn run_rust_installer() -> Result<std::process::ExitStatus> {
184184
let script = resp.bytes().await?;
185185

186186
let mut cmd = std::process::Command::new("sh");
187-
cmd.args(["-s", "--", "--target", "wasm32-wasi"]);
187+
cmd.args(["-s", "--", "--target", "wasm32-wasip1"]);
188188
cmd.stdin(std::process::Stdio::piped());
189189
let mut shell = cmd.spawn()?;
190190
let mut stdin = shell.stdin.take().unwrap();
@@ -213,14 +213,14 @@ async fn run_rust_installer() -> Result<std::process::ExitStatus> {
213213
std::fs::write(&installer_path, &installer_bin)?;
214214

215215
let mut cmd = std::process::Command::new(installer_path);
216-
cmd.args(["--target", "wasm32-wasi"]);
216+
cmd.args(["--target", "wasm32-wasip1"]);
217217
let status = cmd.status()?;
218218
Ok(status)
219219
}
220220

221221
fn install_wasi_target() -> Result<()> {
222222
let mut cmd = std::process::Command::new("rustup");
223-
cmd.args(["target", "add", "wasm32-wasi"]);
223+
cmd.args(["target", "add", "wasm32-wasip1"]);
224224
let status = cmd.status()?;
225225
anyhow::ensure!(
226226
status.success(),

crates/templates/src/manager.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,8 @@ mod tests {
876876
assert!(cargo2.contains("name = \"hello-2\""));
877877

878878
let spin_toml = tokio::fs::read_to_string(&spin_toml_path).await.unwrap();
879-
assert!(spin_toml.contains("source = \"hello/target/wasm32-wasi/release/hello.wasm\""));
880-
assert!(spin_toml.contains("source = \"encore/target/wasm32-wasi/release/hello_2.wasm\""));
879+
assert!(spin_toml.contains("source = \"hello/target/wasm32-wasip1/release/hello.wasm\""));
880+
assert!(spin_toml.contains("source = \"encore/target/wasm32-wasip1/release/hello_2.wasm\""));
881881
}
882882

883883
#[tokio::test]

examples/http-rust/.cargo/config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[build]
2-
target = "wasm32-wasi"
2+
target = "wasm32-wasip1"

examples/http-rust/spin.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ route = "/hello"
1111
component = "hello"
1212

1313
[component.hello]
14-
source = "target/wasm32-wasi/release/http_rust.wasm"
14+
source = "target/wasm32-wasip1/release/http_rust.wasm"
1515
description = "A simple component that returns hello."
1616
[component.hello.build]
17-
command = "cargo build --target wasm32-wasi --release"
17+
command = "cargo build --target wasm32-wasip1 --release"
1818
watch = ["src/**/*.rs", "Cargo.toml"]

0 commit comments

Comments
 (0)