Problem
crates/icp-sync-plugin/build.rs unconditionally calls build_test_fixture(), which runs cargo build --target wasm32-wasip2 to compile a test fixture. This fails when the wasm32-wasip2 target is not installed:
error[E0463]: can't find crate for `core`
= note: the `wasm32-wasip2` target may not be installed
thread 'main' panicked at crates/icp-sync-plugin/build.rs:33:5:
cargo build --target wasm32-wasip2 failed for test fixture
The TEST_PLUGIN_WASM env var set by this build step is only used in #[test] functions in runtime.rs, so the fixture is not needed for regular cargo build or cargo install.
Suggested fix
Gate build_test_fixture() behind a check so it only runs during test builds, e.g.:
fn main() {
println!("cargo:rerun-if-changed=sync-plugin.wit");
println!("cargo:rerun-if-changed=tests/fixtures/test-plugin/src/lib.rs");
println!("cargo:rerun-if-changed=tests/fixtures/test-plugin/Cargo.toml");
// Only build the wasm test fixture when running tests
if std::env::var("CARGO_CFG_TEST").is_ok() {
build_test_fixture();
}
}
Context
This came up while packaging icp-cli 0.2.6 for Homebrew (Homebrew/homebrew-core#280458). The Homebrew Rust toolchain does not include the wasm32-wasip2 target. We are currently working around this with an inreplace in the formula.
Problem
crates/icp-sync-plugin/build.rsunconditionally callsbuild_test_fixture(), which runscargo build --target wasm32-wasip2to compile a test fixture. This fails when thewasm32-wasip2target is not installed:The
TEST_PLUGIN_WASMenv var set by this build step is only used in#[test]functions inruntime.rs, so the fixture is not needed for regularcargo buildorcargo install.Suggested fix
Gate
build_test_fixture()behind a check so it only runs during test builds, e.g.:Context
This came up while packaging icp-cli 0.2.6 for Homebrew (Homebrew/homebrew-core#280458). The Homebrew Rust toolchain does not include the
wasm32-wasip2target. We are currently working around this with aninreplacein the formula.