diff --git a/Cargo.toml b/Cargo.toml index 55f622c3e2f..75353ca0b3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -315,6 +315,7 @@ unexpected_cfgs = { level = "deny", check-cfg = [ "cfg(codspeed)", "cfg(disable_loom)", "cfg(vortex_nightly)", + 'cfg(target_os, values("unknown"))', ] } warnings = "warn" diff --git a/fuzz/src/lib.rs b/fuzz/src/lib.rs index 910aa1bdc0c..f6712e3540c 100644 --- a/fuzz/src/lib.rs +++ b/fuzz/src/lib.rs @@ -64,7 +64,9 @@ pub use native_runtime::RUNTIME; #[cfg(not(target_arch = "wasm32"))] pub use native_runtime::SESSION; -#[cfg(target_arch = "wasm32")] +// target_os = "unknown" matches wasm32-unknown-unknown (browser), excluding WASI targets +// where wasm-bindgen's JS interop is not available. +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] mod wasm_runtime { use std::sync::LazyLock; @@ -77,5 +79,20 @@ mod wasm_runtime { LazyLock::new(|| VortexSession::default().with_handle(WasmRuntime::handle())); } -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] pub use wasm_runtime::SESSION; + +/// WASI targets get a session without an async runtime handle since wasm-bindgen +/// is not available. The fuzz workloads are synchronous, so this is sufficient. +#[cfg(all(target_arch = "wasm32", not(target_os = "unknown")))] +mod wasi_runtime { + use std::sync::LazyLock; + + use vortex::VortexSessionDefault; + use vortex_session::VortexSession; + + pub static SESSION: LazyLock = LazyLock::new(VortexSession::default); +} + +#[cfg(all(target_arch = "wasm32", not(target_os = "unknown")))] +pub use wasi_runtime::SESSION; diff --git a/vortex-io/Cargo.toml b/vortex-io/Cargo.toml index 7e57683b0b0..a73baec63c6 100644 --- a/vortex-io/Cargo.toml +++ b/vortex-io/Cargo.toml @@ -49,7 +49,9 @@ custom-labels = { workspace = true } # Smol is our default impl, so we don't want it to be optional, but it cannot be part of wasm smol = { workspace = true } -[target.'cfg(target_arch = "wasm32")'.dependencies] +# target_os = "unknown" matches wasm32-unknown-unknown (browser), excluding WASI targets +# where wasm-bindgen's JS interop is not available. +[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies] wasm-bindgen-futures = { workspace = true } [dev-dependencies] diff --git a/vortex-io/src/runtime/mod.rs b/vortex-io/src/runtime/mod.rs index 9caf425f472..6a294c1311d 100644 --- a/vortex-io/src/runtime/mod.rs +++ b/vortex-io/src/runtime/mod.rs @@ -29,7 +29,9 @@ pub mod single; mod smol; #[cfg(feature = "tokio")] pub mod tokio; -#[cfg(target_arch = "wasm32")] +// target_os = "unknown" matches wasm32-unknown-unknown (browser), excluding WASI targets +// where wasm-bindgen's JS interop is not available. +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] pub mod wasm; #[cfg(test)]