Skip to content

Commit 4ac219f

Browse files
authored
Rename "preview{0,1}" in wasmtime-wasi to "p{0,1}" (#11380)
* Rename "preview{0,1}" in `wasmtime-wasi` to "p{0,1}" This commit renames the `preview1` module and features to `p1` and does the same for `preview0`. This additionally cleans up the test suite a bit to share more code amongst all the implementaitons and to also move the p1 tests out of the p2 folder. This additionally adds a `p2` feature to the `wasmtime-wasi` crate but it does not currently gate the `p2` module because that'll require some more refactoring an annotations to get that working. * Fix build of the CLI * Fix build of the C API * Fix bench-api build * Fix build of examples * More renamings
1 parent d526299 commit 4ac219f

35 files changed

Lines changed: 282 additions & 274 deletions

File tree

.github/workflows/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,14 @@ jobs:
398398
- name: wasmtime-wasi-http
399399
checks: |
400400
-p wasmtime-wasi-http --no-default-features
401+
402+
- name: wasmtime-wasi
403+
checks: |
404+
-p wasmtime-wasi --no-default-features
405+
-p wasmtime-wasi --no-default-features --features p0
406+
-p wasmtime-wasi --no-default-features --features p1
407+
-p wasmtime-wasi --no-default-features --features p2
408+
-p wasmtime-wasi --no-default-features --features p3
401409
runs-on: ubuntu-latest
402410
steps:
403411
- uses: actions/checkout@v4

benches/instantiation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::sync::Arc;
77
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst};
88
use std::thread;
99
use wasmtime::*;
10-
use wasmtime_wasi::{WasiCtx, preview1::WasiP1Ctx};
10+
use wasmtime_wasi::{WasiCtx, p1::WasiP1Ctx};
1111

1212
fn store(engine: &Engine) -> Store<WasiP1Ctx> {
1313
let wasi = WasiCtx::builder().build_p1();
@@ -49,7 +49,7 @@ fn bench_sequential(c: &mut Criterion, path: &Path) {
4949
// benchmark programs.
5050
linker.func_wrap("bench", "start", || {}).unwrap();
5151
linker.func_wrap("bench", "end", || {}).unwrap();
52-
wasmtime_wasi::preview1::add_to_linker_sync(&mut linker, |cx| cx).unwrap();
52+
wasmtime_wasi::p1::add_to_linker_sync(&mut linker, |cx| cx).unwrap();
5353
let pre = linker
5454
.instantiate_pre(&module)
5555
.expect("failed to pre-instantiate");
@@ -83,7 +83,7 @@ fn bench_parallel(c: &mut Criterion, path: &Path) {
8383
// benchmark programs.
8484
linker.func_wrap("bench", "start", || {}).unwrap();
8585
linker.func_wrap("bench", "end", || {}).unwrap();
86-
wasmtime_wasi::preview1::add_to_linker_sync(&mut linker, |cx| cx).unwrap();
86+
wasmtime_wasi::p1::add_to_linker_sync(&mut linker, |cx| cx).unwrap();
8787
let pre = Arc::new(
8888
linker
8989
.instantiate_pre(&module)

benches/wasi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use criterion::{Criterion, criterion_group, criterion_main};
44
use std::{fs::File, path::Path, time::Instant};
55
use wasmtime::{Engine, Linker, Module, Store, TypedFunc};
6-
use wasmtime_wasi::{DirPerms, FilePerms, WasiCtx, preview1::WasiP1Ctx};
6+
use wasmtime_wasi::{DirPerms, FilePerms, WasiCtx, p1::WasiP1Ctx};
77

88
criterion_group!(benches, bench_wasi);
99
criterion_main!(benches);
@@ -53,7 +53,7 @@ fn instantiate(wat: &[u8]) -> (Store<WasiP1Ctx>, TypedFunc<u64, u64>) {
5353
let mut store = Store::new(&engine, wasi);
5454
let module = Module::new(&engine, wat).unwrap();
5555
let mut linker = Linker::new(&engine);
56-
wasmtime_wasi::preview1::add_to_linker_sync(&mut linker, |cx| cx).unwrap();
56+
wasmtime_wasi::p1::add_to_linker_sync(&mut linker, |cx| cx).unwrap();
5757
let instance = linker.instantiate(&mut store, &module).unwrap();
5858
let run = instance.get_typed_func(&mut store, "run").unwrap();
5959
(store, run)

crates/bench-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ wasmtime = { workspace = true, default-features = true, features = ["winch", "pu
2626
wasmtime-cli-flags = { workspace = true, default-features = true, features = [
2727
"cranelift",
2828
] }
29-
wasmtime-wasi = { workspace = true, features = ['preview1'] }
29+
wasmtime-wasi = { workspace = true, features = ['p1'] }
3030
wasmtime-wasi-nn = { workspace = true, optional = true }
3131
cap-std = { workspace = true }
3232
clap = { workspace = true }

crates/bench-api/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ use std::{env, path::PathBuf};
144144
use wasmtime::{Engine, Instance, Linker, Module, Store};
145145
use wasmtime_cli_flags::CommonOptions;
146146
use wasmtime_wasi::cli::{InputFile, OutputFile};
147-
use wasmtime_wasi::{DirPerms, FilePerms, I32Exit, WasiCtx, preview1::WasiP1Ctx};
147+
use wasmtime_wasi::{DirPerms, FilePerms, I32Exit, WasiCtx, p1::WasiP1Ctx};
148148

149149
pub type ExitCode = c_int;
150150
pub const OK: ExitCode = 0;
@@ -445,7 +445,7 @@ impl BenchState {
445445
let fuel = options.wasm.fuel;
446446

447447
if options.wasi.common != Some(false) {
448-
wasmtime_wasi::preview1::add_to_linker_sync(&mut linker, |cx| &mut cx.wasi)?;
448+
wasmtime_wasi::p1::add_to_linker_sync(&mut linker, |cx| &mut cx.wasi)?;
449449
}
450450

451451
#[cfg(feature = "wasi-nn")]

crates/c-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ wat = { workspace = true, optional = true }
3333
# Optional dependencies for the `wasi` feature
3434
cap-std = { workspace = true, optional = true }
3535
tokio = { workspace = true, optional = true, features = ["fs"] }
36-
wasmtime-wasi = { workspace = true, optional = true, features = ["preview1"] }
36+
wasmtime-wasi = { workspace = true, optional = true, features = ["p1"] }
3737

3838
# Optional dependencies for the `async` feature
3939
futures = { workspace = true, optional = true }

crates/c-api/src/linker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub extern "C" fn wasmtime_linker_define_wasi(
112112
linker: &mut wasmtime_linker_t,
113113
) -> Option<Box<wasmtime_error_t>> {
114114
handle_result(
115-
wasmtime_wasi::preview1::add_to_linker_sync(&mut linker.linker, |ctx| {
115+
wasmtime_wasi::p1::add_to_linker_sync(&mut linker.linker, |ctx| {
116116
ctx.wasi.as_mut().expect("wasi context must be populated")
117117
}),
118118
|_linker| (),

crates/c-api/src/store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ wasmtime_c_api_macros::declare_own!(wasmtime_store_t);
8383
pub struct WasmtimeStoreData {
8484
foreign: crate::ForeignData,
8585
#[cfg(feature = "wasi")]
86-
pub(crate) wasi: Option<wasmtime_wasi::preview1::WasiP1Ctx>,
86+
pub(crate) wasi: Option<wasmtime_wasi::p1::WasiP1Ctx>,
8787

8888
/// Temporary storage for usage during a wasm->host call to store values
8989
/// in a slice we pass to the C API.

crates/c-api/src/wasi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::fs::File;
77
use std::path::Path;
88
use std::slice;
99
use wasmtime_wasi::WasiCtxBuilder;
10-
use wasmtime_wasi::preview1::WasiP1Ctx;
10+
use wasmtime_wasi::p1::WasiP1Ctx;
1111

1212
unsafe fn cstr_to_path<'a>(path: *const c_char) -> Option<&'a Path> {
1313
CStr::from_ptr(path).to_str().map(Path::new).ok()

crates/wasi-nn/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ walkdir = { workspace = true }
5959
cap-std = { workspace = true }
6060
libtest-mimic = { workspace = true }
6161
test-programs-artifacts = { workspace = true }
62-
wasmtime-wasi = { workspace = true, features = ["preview1"] }
62+
wasmtime-wasi = { workspace = true, features = ["p1"] }
6363
wasmtime = { workspace = true, features = ["cranelift"] }
6464
tracing-subscriber = { workspace = true }
6565

0 commit comments

Comments
 (0)