Skip to content

Commit

Permalink
chore: switch from wasm32-wasi to wasm32-wasip1 target
Browse files Browse the repository at this point in the history
In rust 1.78 `wasm32-wasi` target is renamed to `wasm32-wasip1`.
See https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html
  • Loading branch information
greenhat committed Jul 31, 2024
1 parent 5c098e7 commit c31a0d2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ args = ["target", "add", "wasm32-unknown-unknown"]
category = "Test"
description = "Install wasm32-wasi target"
command = "rustup"
args = ["target", "add", "wasm32-wasi"]
# `wasm32-wasi` target is renamed to `wasm32-wasip1`
# https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html
args = ["target", "add", "wasm32-wasip1"]

[tasks.install-rust-src]
category = "Test"
Expand Down
2 changes: 1 addition & 1 deletion sdk/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build]
target = "wasm32-wasi"
target = "wasm32-wasip1"
6 changes: 4 additions & 2 deletions tests/integration/src/compiler_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use crate::cargo_proj::project;

type LinkMasmModules = Vec<(LibraryPath, String)>;

pub const WASM32_WASI_TARGET: &str = "wasm32-wasip1";

pub enum CompilerTestSource {
Rust(String),
RustCargo {
Expand Down Expand Up @@ -213,7 +215,7 @@ impl CompilerTest {
.arg("--manifest-path")
.arg(manifest_path)
.arg("--release")
.arg("--target=wasm32-wasi");
.arg(format!("--target={}", WASM32_WASI_TARGET));
if is_build_std {
// compile std as part of crate graph compilation
// https://doc.rust-lang.org/cargo/reference/unstable.html#build-std
Expand Down Expand Up @@ -630,7 +632,7 @@ fn wasm_artifact_path(cargo_project_folder: &Path, artifact_name: &str) -> PathB
cargo_project_folder
.to_path_buf()
.join("target")
.join("wasm32-wasi")
.join(WASM32_WASI_TARGET)
.join("release")
.join(artifact_name)
.with_extension("wasm")
Expand Down
12 changes: 6 additions & 6 deletions tools/cargo-miden/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ use std::{

use anyhow::{bail, Result};

pub const WASM32_WASI_TARGET: &str = "wasm32-wasi";
pub const WASM32_WASI_TARGET: &str = "wasm32-wasip1";

pub fn install_wasm32_wasi() -> Result<()> {
log::info!("Installing {WASM32_WASI_TARGET} target");
let sysroot = get_sysroot()?;
if sysroot.join("lib/rustlib/wasm32-wasi").exists() {
if sysroot.join(format!("lib/rustlib/{}", WASM32_WASI_TARGET)).exists() {
return Ok(());
}

if env::var_os("RUSTUP_TOOLCHAIN").is_none() {
bail!(
"failed to find the `wasm32-wasi` target and `rustup` is not available. If you're \
using rustup make sure that it's correctly installed; if not, make sure to install \
the `wasm32-wasi` target before using this command"
"failed to find the `{WASM32_WASI_TARGET}` target and `rustup` is not available. If \
you're using rustup make sure that it's correctly installed; if not, make sure to \
install the `{WASM32_WASI_TARGET}` target before using this command",
);
}

Expand All @@ -32,7 +32,7 @@ pub fn install_wasm32_wasi() -> Result<()> {
.output()?;

if !output.status.success() {
bail!("failed to install the `wasm32-wasi` target");
bail!("failed to install the `{WASM32_WASI_TARGET}` target");
}

Ok(())
Expand Down

0 comments on commit c31a0d2

Please sign in to comment.