rusqlite: Can't build for wasm target
cargo build --lib --target "wasm32-unknown-unknown"
With rusqlite = {version = "0.24.1", features = ["bundled"]}:
cargo:warning=sqlite3/sqlite3.c:14012:10: fatal error: 'stdio.h' file not found
with rusqlite = {version = "0.24.1"}:
rust-lld: error: unable to find library -lsqlite3
It also happens with 0.23.1.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 4
- Comments: 37 (14 by maintainers)
Yeah, with the changes in #1116 it works (I’m the author of that PR). I tried building a wasm32-wasi executable with bundled SQLite, and it worked when running it with wasmtime. (just copied the example in the README, nothing fancy).
I also had to set up the
ARenv var. The script I used is something like:Cargo.tomlfile:Note:
../rusqlite/compile-wasm32-wasiis a path to the branch used for #1116.Finally, run with:
@GeeWee I got the same error. (M1 Mac, tried
wasi-sdk10, 12 and 14).I started trying to compile the
sqlite3.camalgamation separately, running theclangcommand in the error message you posted (which I also got). By using theDSQLITE_THREADSAFE=0flag, thepthread.herror went away, but I got several new errors I couldn’t fix. In any case, disabling thread safety may not work, sincerusqlitedoesn’t seem to allow it: https://github.com/rusqlite/rusqlite/blob/master/tests/deny_single_threaded_sqlite_config.rs (Found it from #746).This is the command I was running:
(I included the
D_WASI_EMULATED_MMANflag following an error message fromclang).I’ll report back if I manage to fix something.
Managed to work !
With
wasi-sdk 14.0, idea from #1116just compile, no test 😉