fix: get random need special rust flag and crate flag to compile to

wasm
This commit is contained in:
Marc-Anthony Girard
2026-07-30 14:02:54 -04:00
parent 71ae6f61dd
commit 3c69a9575f
4 changed files with 21 additions and 1 deletions

View File

@@ -20,6 +20,12 @@ rustflags = [
"link-args=-Wl,-undefined,dynamic_lookup,-no_fixup_chains",
]
# getrandom 0.3 needs this cfg (https://docs.rs/getrandom/latest/getrandom/#webassembly-support)
[target.wasm32-unknown-unknown]
rustflags = [
'--cfg=getrandom_backend="wasm_js"',
]
# To be able to run unit tests on Linux, support compilation to 'x86_64-unknown-linux-gnu'.
# pthread_key_create() destructors and segfault after a DSO unloading https://sourceware.org/bugzilla/show_bug.cgi?id=21031
[target.'cfg(all(target_os = "linux", target_env = "gnu"))']
@@ -66,4 +72,4 @@ rustflags = [
"--cfg=tokio_unstable",
"-C",
"link-args=-Wl,-z,max-page-size=16384",
]
]

4
Cargo.lock generated
View File

@@ -2525,11 +2525,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"r-efi 6.0.0",
"rand_core 0.10.1",
"wasip2",
"wasip3",
"wasm-bindgen",
]
[[package]]
@@ -7330,6 +7332,8 @@ dependencies = [
"env_logger",
"fallible-iterator 0.3.0",
"fastbloom",
"getrandom 0.2.15",
"getrandom 0.3.2",
"hex",
"icu_collator",
"icu_locale",

View File

@@ -142,6 +142,13 @@ web-time = "1.1"
[target.'cfg(not(any(target_family = "wasm", all(target_os = "windows", target_arch = "aarch64"))))'.dependencies]
simsimd = "6.5.3"
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
# From fastbloom/rand
getrandom02 = { package = "getrandom", version = "0.2", features = ["js"] }
# From aes-gcm
getrandom03 = { package = "getrandom", version = "0.3", features = ["wasm_js"] }
uuid = { version = "1.11.0", features = ["js"], optional = true }
[target.'cfg(antithesis)'.dependencies]
antithesis_sdk = { workspace = true, features = ["full"] }
serde_json = { workspace = true }

View File

@@ -17,3 +17,6 @@ turso_macros = { workspace = true }
getrandom = "0.4.2"
chrono = { workspace = true, default-features = true }
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
getrandom = { version = "0.4.2", features = ["wasm_js"] }