New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve wasm32-wasi support #1332
Conversation
[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
My understanding is that these two were superseded by #1321, and though that one fixed compilation against wasm32-wasi, the resulting artifact is still failing in runtime with the errors above. This PR addresses it. Moreover, |
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## master #1332 +/- ##
==========================================
- Coverage 80.48% 80.22% -0.26%
==========================================
Files 49 50 +1
Lines 9950 9982 +32
==========================================
Hits 8008 8008
- Misses 1942 1974 +32
☔ View full report in Codecov by Sentry. |
Hello! After testing a bunch of solutions in the various issues/discussions related to rusqlite-on-WASI, this PR seems to contain the combination of tricks that work in my case. I can confirm that not only can it operate on a SQLite DB in memory, but it can also write to and read from a SQLite file on the local (host) filesystem that is then mapped into the wasmtime runtime. Given that the PR is approved, I'm curious if there is anything I can do to help get it merged into the main branch with the hope of it being available in a future release. I'm grateful to both the maintainers and the submitter, and don't want to stress anyone out if this isn't a priority at the moment. Thank you! |
My bad ! |
Thank you @gwenn! This is great! |
libsqlite3-sys v0.28.0 |
Starting from 3.41.0 SQLite has wasm32-wasi support out of the box.
-DSQLITE_THREADSAFE=0
. Fixes:-DSQLITE_OS_OTHER
. Fixes:Using of file databases is also working, though
--mapdir
arg should be provided towasmtime run
.