Skip to content

Commit b81420e

Browse files
authored
Fix build for wasm32-unknown-unknown without bindgen (#9480)
We shouldn't unconditionally force people to use wasm-bindgen if they're not in a js environment fix #9475 --------- Signed-off-by: Robert Kruszewski <[email protected]>
1 parent a4af10a commit b81420e

10 files changed

Lines changed: 34 additions & 6 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ tracing = { version = "0.1.41", default-features = false }
281281
tracing-perfetto = "0.1.5"
282282
tracing-subscriber = "0.3"
283283
url = "2.5.7"
284-
uuid = { version = "1.23", features = ["js"] }
284+
uuid = "1.23"
285285
wasm-bindgen-futures = "0.4.58"
286286
wkb = "0.9.2"
287287
xshell = "0.2.6"

‎fuzz/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ vortex-btrblocks = { workspace = true }
3737
vortex-buffer = { workspace = true }
3838
vortex-error = { workspace = true }
3939
vortex-fsst = { workspace = true, features = ["_test-harness"] }
40-
vortex-io = { workspace = true }
40+
vortex-io = { workspace = true, features = ["wasm-bindgen"] }
4141
vortex-mask = { workspace = true }
4242
vortex-row = { workspace = true }
4343
vortex-runend = { workspace = true, features = ["arbitrary"] }

‎vortex-file/Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ name = "split_collection"
7777
harness = false
7878

7979
[features]
80+
default = ["wasm-bindgen"]
8081
object_store = ["dep:object_store", "vortex-io/object_store", "tokio"]
8182
tokio = [
8283
"dep:tokio",
8384
"vortex-error/tokio",
8485
"vortex-io/tokio",
8586
"vortex-layout/tokio",
8687
]
88+
wasm-bindgen = ["vortex-layout/wasm-bindgen"]
8789
zstd = ["dep:vortex-zstd", "vortex-btrblocks/zstd", "vortex-btrblocks/pco"]
8890
# This feature enables unstable encodings for which we don't guarantee stability.
8991
unstable_encodings = [

‎vortex-io/Cargo.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ smol = { workspace = true }
5151
# target_os = "unknown" matches wasm32-unknown-unknown (browser), excluding WASI targets
5252
# where wasm-bindgen's JS interop is not available.
5353
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
54-
wasm-bindgen-futures = { workspace = true }
54+
wasm-bindgen-futures = { workspace = true, optional = true }
5555

5656
[dev-dependencies]
5757
anyhow = { workspace = true }
@@ -63,6 +63,7 @@ tokio = { workspace = true, features = ["full"] }
6363
[features]
6464
object_store = ["dep:object_store", "vortex-error/object_store"]
6565
tokio = ["tokio/fs", "tokio/rt-multi-thread"]
66+
wasm-bindgen = ["dep:wasm-bindgen-futures"]
6667

6768
[lints]
6869
workspace = true

‎vortex-io/src/runtime/mod.rs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
//! * Multi-threaded: work is driven on a pool of threads managed by Vortex.
1212
//! * Worker Pool: work is driven on a pool of threads provided by the caller.
1313
//! * Tokio: work is driven on a Tokio runtime provided by the caller.
14+
//! * WebAssembly: work is driven by `wasm_bindgen_futures`, behind the `wasm-bindgen` feature.
15+
//!
16+
//! Callers may also implement [`Executor`] themselves and install it with
17+
//! `RuntimeSessionExt::with_handle`, which is the only option on `wasm32-unknown-unknown`
18+
//! without the `wasm-bindgen` feature.
1419
1520
use futures::future::BoxFuture;
1621

@@ -33,7 +38,11 @@ mod smol;
3338
pub mod tokio;
3439
// target_os = "unknown" matches wasm32-unknown-unknown (browser), excluding WASI targets
3540
// where wasm-bindgen's JS interop is not available.
36-
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
41+
#[cfg(all(
42+
target_arch = "wasm32",
43+
target_os = "unknown",
44+
feature = "wasm-bindgen"
45+
))]
3746
pub mod wasm;
3847

3948
#[cfg(test)]

‎vortex-layout/Cargo.toml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,21 @@ vortex-array = { path = "../vortex-array", features = ["_test-harness"] }
6464
vortex-io = { path = "../vortex-io", features = ["tokio"] }
6565

6666
[features]
67+
default = ["wasm-bindgen"]
6768
_test-harness = []
6869
tokio = ["dep:tokio", "vortex-error/tokio"]
70+
# `moka` enables uuid's `v4`, which needs a randomness source on wasm32-unknown-unknown.
71+
# Disable this to supply your own instead, by depending on uuid from your own manifest with
72+
# one of `js`, `rng-getrandom` (plus a getrandom backend), or `rng-rand` enabled.
73+
wasm-bindgen = ["dep:uuid"]
6974

7075
[[bench]]
7176
name = "zone_map_prune"
7277
harness = false
7378

79+
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
80+
uuid = { workspace = true, features = ["js"], optional = true }
81+
7482
[lints]
7583
workspace = true
7684

‎vortex-tui/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ serde_json = { workspace = true }
5555
taffy = { workspace = true }
5656
vortex = { version = "0.1.0", path = "../vortex", default-features = false, features = [
5757
"files",
58+
"wasm-bindgen",
5859
] }
5960
vortex-arrow = { workspace = true }
6061

‎vortex-web/crate/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ serde = { workspace = true, features = ["derive"] }
1818
serde_json = { workspace = true }
1919
vortex = { path = "../../vortex", default-features = false, features = [
2020
"files",
21+
"wasm-bindgen",
2122
] }
2223
vortex-arrow = { workspace = true }
2324

‎vortex/Cargo.toml‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ vortex-decimal-byte-parts = { workspace = true }
3535
vortex-edition = { workspace = true }
3636
vortex-error = { workspace = true }
3737
vortex-fastlanes = { workspace = true }
38-
vortex-file = { workspace = true, optional = true, default-features = true }
38+
vortex-file = { workspace = true, optional = true }
3939
vortex-flatbuffers = { workspace = true }
4040
vortex-fsst = { workspace = true }
4141
vortex-io = { workspace = true }
@@ -70,7 +70,7 @@ tracing-subscriber = { workspace = true }
7070
vortex = { path = ".", features = ["tokio"] }
7171

7272
[features]
73-
default = ["files", "zstd"]
73+
default = ["files", "wasm-bindgen", "zstd"]
7474
files = ["dep:vortex-file"]
7575
memmap2 = ["vortex-buffer/memmap2"]
7676
object_store = ["vortex-file?/object_store", "vortex-io/object_store"]
@@ -88,6 +88,11 @@ tokio = [
8888
"vortex-layout/tokio",
8989
]
9090
zstd = ["dep:vortex-zstd", "vortex-file?/zstd"]
91+
wasm-bindgen = [
92+
"vortex-file?/wasm-bindgen",
93+
"vortex-io/wasm-bindgen",
94+
"vortex-layout/wasm-bindgen",
95+
]
9196
pretty = ["vortex-array/table-display"]
9297
serde = ["vortex-array/serde", "vortex-buffer/serde", "vortex-mask/serde"]
9398
# Exposes experimental row-function APIs without compatibility guarantees.

0 commit comments

Comments
 (0)