mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-25 02:21:37 +08:00
5534eb93c6
[Starting from 3.41.0 SQLite has wasm32-wasi support out of the box.][0] - Set `-DSQLITE_THREADSAFE=0`. Fixes: ``` $ wasmtime target/wasm32-wasi/release/examples/persons.wasm Error: failed to run main module `target/wasm32-wasi/release/examples/persons.wasm` Caused by: 0: failed to instantiate "target/wasm32-wasi/release/examples/persons.wasm" 1: unknown import: `env::pthread_mutexattr_init` has not been defined ``` - Drop `-DSQLITE_OS_OTHER`. Fixes: ``` $ wasmtime target/wasm32-wasi/release/examples/persons.wasm Error: failed to run main module `target/wasm32-wasi/release/examples/persons.wasm` Caused by: 0: failed to instantiate "target/wasm32-wasi/release/examples/persons.wasm" 1: unknown import: `env::sqlite3_os_init` has not been defined ``` - [Add wasi specific build flags][1] - Add basic example - Also, add instructions how to run it against wasm32-wasi. Using of file databases is also working, though `--mapdir` arg should be provided to `wasmtime run`. [0]: https://wasmlabs.dev/articles/sqlite-wasi-support/ [1]: https://github.com/vmware-labs/webassembly-language-runtimes/blob/main/libs/sqlite/wasi-patches/wlr-build.sh#L11 |
||
---|---|---|
.. | ||
main.rs | ||
README.md |
Persons example
Run
$ cargo run --example persons
Run (wasm32-wasi)
Requisites
# Set to wasi-sdk directory
$ export WASI_SDK_PATH=`<wasi-sdk-path>`
$ export CC_wasm32_wasi="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot"
# Build
$ cargo build --example persons --target wasm32-wasi --release --features bundled
# Run
$ wasmtime target/wasm32-wasi/release/examples/persons.wasm
Found persons:
ID: 1, Name: Steven
ID: 2, Name: John
ID: 3, Name: Alex