Commit Graph

6 Commits

Author SHA1 Message Date
gwenn
c2fbd167de
Merge pull request #1332 from etehtsea/wasi-example
Improve wasm32-wasi support
2023-11-25 18:03:21 +01:00
gwenn
856c94063d Try to fix windows build 2023-07-18 17:45:28 +02:00
gwenn
f9d69410ef Fix panic at 'SQLite API not initialized or SQLite feature omitted'
`to_sqlite_error` needs `sqlite3_malloc`

```
sqlite> .log on
sqlite> .load target/debug/examples/libloadable_extension.so
Error: error during initialization: SQLite version mismatch: 3014000 < 3042000
```
2023-07-14 15:56:43 +02:00
gwenn
d7f2d55bfb Add example loading extension 2023-07-14 11:07:59 +02:00
gwenn
8051b048db Add a minimal loadable extension example 2023-07-14 10:18:29 +02:00
Konstantin Shabanov
5534eb93c6
Improve wasm32-wasi support
[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
2023-05-25 22:26:56 +06:00