Skip to content

Commit 842b81c

Browse files
committed
Wasm: Compile as reactor module
1 parent 719fde0 commit 842b81c

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ jobs:
176176

177177
- name: Web tests
178178
run: |
179-
curl https://storage.googleapis.com/simon-public-euw3/assets/sqlite3/wasm/2.4.3/sqlite3.wasm -o example/web/sqlite3.wasm
179+
curl https://storage.googleapis.com/simon-public-euw3/assets/sqlite3/wasm/2.4.6/sqlite3.wasm -o example/web/sqlite3.wasm
180180
dart test -P web -r expanded
181181
# If browsers behave differently on different platforms, surely that's not our fault...
182182
# So, only run browser tests on Linux to be faster.

sqlite3/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.4.6
2+
3+
- WebAssembly: Call `_initialize` function of sqlite3 module if one is present.
4+
15
## 2.4.5
26

37
- Fix a bug in the OPFS-locks implementation causing a deadlock when the `xSleep`

sqlite3/assets/wasm/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ macro(base_sqlite3_target name)
3232
helpers.c
3333
)
3434

35-
target_link_options(${name} PRIVATE -nostartfiles -Wl,--import-memory -Wl,--no-entry -Wl,--export-dynamic)
35+
target_link_options(${name} PRIVATE -mexec-model=reactor -mcpu=generic -Wl,--import-memory -Wl,--no-entry -Wl,--export-dynamic)
36+
target_compile_options(${name} PRIVATE -std=c23 -mcpu=generic)
3637
target_include_directories(${name} PRIVATE "${PROJECT_SOURCE_DIR}/")
3738
target_include_directories(${name} PRIVATE ${sqlite3_SOURCE_DIR})
3839
target_compile_definitions(${name} PRIVATE

sqlite3/lib/src/wasm/js_interop/wasm.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ class WasmInstance {
5454
});
5555

5656
final native = await _instantiateStreaming(response, importsJs).toDart;
57+
58+
// If the module has an `_initialize` export, it needs to be called to run
59+
// C constructors and set up memory.
60+
final exports = native.instance.exports;
61+
if (exports.has('_initialize')) {
62+
(exports['_initialize'] as JSFunction).callAsFunction();
63+
}
64+
5765
return WasmInstance._(native.instance);
5866
}
5967
}

sqlite3/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: sqlite3
22
description: Provides lightweight yet convenient bindings to SQLite by using dart:ffi
3-
version: 2.4.5
3+
version: 2.4.6-dev
44
homepage: https://github.com/simolus3/sqlite3.dart/tree/main/sqlite3
55
issue_tracker: https://github.com/simolus3/sqlite3.dart/issues
66

0 commit comments

Comments
 (0)