Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
21 changes: 19 additions & 2 deletions fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<VortexSession> = LazyLock::new(VortexSession::default);
}

#[cfg(all(target_arch = "wasm32", not(target_os = "unknown")))]
pub use wasi_runtime::SESSION;
4 changes: 3 additions & 1 deletion vortex-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion vortex-io/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Loading