Duckdb wasm in rust

Hello everyone,

I’m developing a Rust library with DuckDB as a key dependency. The library successfully cross-compiles for various platforms like Windows, macOS, and Android. However, I’m encountering errors while trying to build it for WebAssembly (WASM).

Could you please help me resolve these issues or share any insights on building DuckDB with Rust for WASM?

Thank you in advance for your assistance!

Hello, probably we can. Can you please describe the issue?

cargo.toml:
[dependencies]
duckdb = "1.0.0"
flatbuffers = "24.3.25"
indexmap = "2.6.0"
regex = "1.11.0"
cpu-time = "1.0.0"
sysinfo = "0.31.4"
rand = "0.8.5"
uuid = { version = "1.11.0", features = ["v4"] }
env_logger = "0.11.5"
log = "0.4.22"
getrandom = { version = "0.2", features = ["js"] }

[lib]
crate-type = ["lib", "staticlib", "cdylib"]

[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
strip = true

Command used:
wasm-pack build --target web

Issue i'm getting:
error: linking with rust-lld failed
/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-534e57744aebda0e.rlib: archive member '45c91108d938afe8-ucmpti2.o' is neither Wasm object file nor LLVM bitcode

rust-lld: error: unable to find library -lduckdb

This topic has an OP identical to yours, by an account that made that topic and did nothing else. The answer from that topic should still apply[1]: Cross-Compiling a Rust Library with DuckDB for WebAssembly (WASM) - #2 by hax10.

Also, you could try using the "bundled" feature to compile DuckDB from source, but I don't know whether it would work compiling to WASM.


  1. since it's the same question ↩︎

2 Likes