Skip to content

Commit

Permalink
Merge pull request #622 from hermit-os/wasmtime-gc
Browse files Browse the repository at this point in the history
fix(wasmtime/build.rs): unpin wasm toolchain
  • Loading branch information
mkroening authored Sep 16, 2024
2 parents 3493848 + 385d206 commit 764dcda
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 52 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ jobs:
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-07-31
targets: wasm32-wasip1
- uses: mkroening/rust-toolchain-toml@main
- run: rustup component add clippy llvm-tools
- run: |
rustup component add clippy llvm-tools
rustup target add wasm32-wasip1
- name: Clippy
run: |
cargo clippy --all-targets
Expand Down Expand Up @@ -53,12 +51,10 @@ jobs:
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-07-31
targets: wasm32-wasip1
- uses: mkroening/rust-toolchain-toml@main
- run: rustup component add llvm-tools
- run: |
rustup component add llvm-tools
rustup target add wasm32-wasip1
- name: Check docs
run: cargo doc --no-deps --document-private-items

Expand Down
3 changes: 2 additions & 1 deletion examples/wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ bitflags = "2.5"
cfg-if = "1"
log = { version = "0.4" } #, features = ["kv_unstable"]}
simple_logger = { version = "5.0", default-features = false }
wasmtime = { version = "24.0", default-features = false, features = ["std", "runtime", "cranelift", "threads", "parallel-compilation"] } #"pooling-allocator", "incremental-cache", "wat", "gc", "component-model"] }
# FIXME: remove `gc` feature once upgraded to wasmtime 25:
wasmtime = { version = "24.0", default-features = false, features = ["std", "gc", "runtime", "cranelift", "threads", "parallel-compilation"] } #"pooling-allocator", "incremental-cache", "wat", "gc", "component-model"] }
zerocopy = { version = "0.7", default-features = false, features = ["alloc", "derive", "simd-nightly"] }

[target.'cfg(target_os = "hermit")'.dependencies]
Expand Down
45 changes: 4 additions & 41 deletions examples/wasmtime/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::path::PathBuf;
use std::process::Command;
use std::{env, io};

fn main() -> io::Result<()> {
let mut cargo = cargo();
let cargo = env::var_os("CARGO").unwrap();
let out_dir = env::var_os("OUT_DIR").unwrap();

let package = if cfg!(feature = "ci") {
Expand All @@ -12,53 +11,17 @@ fn main() -> io::Result<()> {
"wasm-test"
};

cargo
.arg("+nightly-2024-07-31")
let status = Command::new(cargo)
.arg("build")
.arg("-Zunstable-options")
.arg("--target=wasm32-wasip1")
.args(["--package", package])
.arg("--release")
.arg("--target-dir=target")
.arg("--artifact-dir")
.arg(&out_dir);
let status = cargo.status()?;
.arg(&out_dir)
.status()?;
assert!(status.success());

Ok(())
}

pub fn cargo() -> Command {
sanitize("cargo")
}

fn sanitize(cmd: &str) -> Command {
let cmd = {
let exe = format!("{cmd}{}", env::consts::EXE_SUFFIX);
// On windows, the userspace toolchain ends up in front of the rustup proxy in $PATH.
// To reach the rustup proxy nonetheless, we explicitly query $CARGO_HOME.
let mut cargo_home = PathBuf::from(env::var_os("CARGO_HOME").unwrap());
cargo_home.push("bin");
cargo_home.push(&exe);
if cargo_home.exists() {
cargo_home
} else {
PathBuf::from(exe)
}
};

let mut cmd = Command::new(cmd);

// Remove rust-toolchain-specific environment variables from kernel cargo
cmd.env_remove("LD_LIBRARY_PATH");
env::vars()
.filter(|(key, _value)| {
key.starts_with("CARGO") && !key.starts_with("CARGO_HOME")
|| key.starts_with("RUST") && !key.starts_with("RUSTUP_HOME")
})
.for_each(|(key, _value)| {
cmd.env_remove(&key);
});

cmd
}

0 comments on commit 764dcda

Please sign in to comment.