diff --git a/Cargo.lock b/Cargo.lock index bcb3cd5862..1dc096c77a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3224,8 +3224,9 @@ name = "wasmtime-bench-api" version = "0.19.0" dependencies = [ "anyhow", + "cap-std", "shuffling-allocator", - "wasi-common", + "wasi-cap-std-sync", "wasmtime", "wasmtime-wasi", "wat", diff --git a/crates/bench-api/Cargo.toml b/crates/bench-api/Cargo.toml index c5c70bf6df..9c8fd41b3e 100644 --- a/crates/bench-api/Cargo.toml +++ b/crates/bench-api/Cargo.toml @@ -19,7 +19,8 @@ anyhow = "1.0" shuffling-allocator = { version = "1.1.1", optional = true } wasmtime = { path = "../wasmtime", default-features = false } wasmtime-wasi = { path = "../wasi" } -wasi-common = { path = "../wasi-common" } +wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync" } +cap-std = "0.12" [dev-dependencies] wat = "1.0" diff --git a/crates/bench-api/src/lib.rs b/crates/bench-api/src/lib.rs index 8923b4c788..0d99ab635d 100644 --- a/crates/bench-api/src/lib.rs +++ b/crates/bench-api/src/lib.rs @@ -83,7 +83,7 @@ use std::env; use std::os::raw::{c_int, c_void}; use std::path::Path; use std::slice; -use wasi_common::WasiCtxBuilder; +use wasi_cap_std_sync::WasiCtxBuilder; use wasmtime::{Config, Engine, Instance, Linker, Module, Store}; use wasmtime_wasi::Wasi; @@ -211,16 +211,16 @@ impl BenchState { // Create a WASI environment. let mut cx = WasiCtxBuilder::new(); - cx.inherit_stdio(); + cx = cx.inherit_stdio(); // Allow access to the working directory so that the benchmark can read // its input workload(s). - let working_dir = wasi_common::preopen_dir(working_dir) + let working_dir = unsafe { cap_std::fs::Dir::open_ambient_dir(working_dir) } .context("failed to preopen the working directory")?; - cx.preopened_dir(working_dir, "."); + cx = cx.preopened_dir(working_dir, ".")?; // Pass this env var along so that the benchmark program can use smaller // input workload(s) if it has them and that has been requested. if let Ok(val) = env::var("WASM_BENCH_USE_SMALL_WORKLOAD") { - cx.env("WASM_BENCH_USE_SMALL_WORKLOAD", &val); + cx = cx.env("WASM_BENCH_USE_SMALL_WORKLOAD", &val)?; } let cx = cx.build()?;