Cross-Compiling a Rust Library with DuckDB for WebAssembly (WASM)

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!

WASM apps normally run in the web browser where, for security reasons, there are restrictions on what kind of I/O (file, device and network) access your program has.

As a result, much of the Rust standard library doesn't compile for WASM (std::net, std::fs and the like). I'm not familiar with DuckDB, but drivers for database engines in particular are likely to require I/O ops from the standard library that are not supported in the WASM environment, which would cause your compilation to fail.

Now it appears that DuckDB have created a special version of their DB engine that does run as a WASM app and can be controlled via a TypeScript language API. There don't appear to be Rust bindings for this WASM-based engine. Although in theory one could be written, it appears you would have to do that yourself.

1 Like