diff --git a/embed/build.sh b/embed/build.sh index 36183bb..0e82195 100755 --- a/embed/build.sh +++ b/embed/build.sh @@ -12,13 +12,13 @@ WASI_SDK="$ROOT/tools/wasi-sdk-22.0/bin" -o sqlite3.wasm "$ROOT/sqlite3/main.c" \ -I"$ROOT/sqlite3" \ -mexec-model=reactor \ - -msimd128 -mmutable-globals \ + -matomics -msimd128 -mmutable-globals \ -mbulk-memory -mreference-types \ -mnontrapping-fptoint -msign-ext \ -fno-stack-protector -fno-stack-clash-protection \ - -Wl,--initial-memory=327680 \ -Wl,--stack-first \ -Wl,--import-undefined \ + -Wl,--initial-memory=327680 \ -D_HAVE_SQLITE_CONFIG_H \ -DSQLITE_CUSTOM_INCLUDE=sqlite_opt.h \ $(awk '{print "-Wl,--export="$0}' exports.txt) diff --git a/embed/sqlite3.wasm b/embed/sqlite3.wasm index 569f0b3..bb4f7ea 100755 Binary files a/embed/sqlite3.wasm and b/embed/sqlite3.wasm differ diff --git a/sqlite.go b/sqlite.go index 61a0365..e698fc8 100644 --- a/sqlite.go +++ b/sqlite.go @@ -13,6 +13,7 @@ import ( "github.com/ncruces/go-sqlite3/vfs" "github.com/tetratelabs/wazero" "github.com/tetratelabs/wazero/api" + "github.com/tetratelabs/wazero/experimental" ) // Configure SQLite Wasm. @@ -44,12 +45,14 @@ var instance struct { } func compileSQLite() { - if RuntimeConfig == nil { - RuntimeConfig = wazero.NewRuntimeConfig() + ctx := context.Background() + cfg := RuntimeConfig + if cfg == nil { + cfg = wazero.NewRuntimeConfig() } - ctx := context.Background() - instance.runtime = wazero.NewRuntimeWithConfig(ctx, RuntimeConfig) + instance.runtime = wazero.NewRuntimeWithConfig(ctx, + cfg.WithCoreFeatures(api.CoreFeaturesV2|experimental.CoreFeaturesThreads)) env := instance.runtime.NewHostModuleBuilder("env") env = vfs.ExportHostFunctions(env) diff --git a/vfs/tests/mptest/mptest_test.go b/vfs/tests/mptest/mptest_test.go index a65cb45..a47133e 100644 --- a/vfs/tests/mptest/mptest_test.go +++ b/vfs/tests/mptest/mptest_test.go @@ -23,6 +23,7 @@ import ( "github.com/ncruces/go-sqlite3/vfs/memdb" "github.com/tetratelabs/wazero" "github.com/tetratelabs/wazero/api" + "github.com/tetratelabs/wazero/experimental" "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" ) @@ -40,7 +41,9 @@ var ( func TestMain(m *testing.M) { ctx := context.Background() - cfg := wazero.NewRuntimeConfig().WithMemoryLimitPages(1024) + cfg := wazero.NewRuntimeConfig(). + WithCoreFeatures(api.CoreFeaturesV2 | experimental.CoreFeaturesThreads). + WithMemoryLimitPages(1024) rt = wazero.NewRuntimeWithConfig(ctx, cfg) wasi_snapshot_preview1.MustInstantiate(ctx, rt) diff --git a/vfs/tests/mptest/testdata/build.sh b/vfs/tests/mptest/testdata/build.sh index bd2e4ba..67d6b91 100755 --- a/vfs/tests/mptest/testdata/build.sh +++ b/vfs/tests/mptest/testdata/build.sh @@ -10,7 +10,7 @@ WASI_SDK="$ROOT/tools/wasi-sdk-22.0/bin" "$WASI_SDK/clang" --target=wasm32-wasi -std=c23 -flto -g0 -O2 \ -o mptest.wasm main.c \ -I"$ROOT/sqlite3" \ - -msimd128 -mmutable-globals \ + -matomics -msimd128 -mmutable-globals \ -mbulk-memory -mreference-types \ -mnontrapping-fptoint -msign-ext \ -fno-stack-protector -fno-stack-clash-protection \ diff --git a/vfs/tests/mptest/testdata/mptest.wasm.bz2 b/vfs/tests/mptest/testdata/mptest.wasm.bz2 index a19b679..d6922d3 100644 --- a/vfs/tests/mptest/testdata/mptest.wasm.bz2 +++ b/vfs/tests/mptest/testdata/mptest.wasm.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:92c82e38e6b6d97086ef84f5cee6442ebf36ffa15629c76c31edca0592ac11fc -size 479929 +oid sha256:05dc5c2008972a605af3adec692827658255514fda73cc608856e27b4fd0e3e1 +size 479728 diff --git a/vfs/tests/speedtest1/speedtest1_test.go b/vfs/tests/speedtest1/speedtest1_test.go index b647fc9..4aa0fd3 100644 --- a/vfs/tests/speedtest1/speedtest1_test.go +++ b/vfs/tests/speedtest1/speedtest1_test.go @@ -17,6 +17,8 @@ import ( _ "embed" "github.com/tetratelabs/wazero" + "github.com/tetratelabs/wazero/api" + "github.com/tetratelabs/wazero/experimental" "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" "github.com/ncruces/go-sqlite3/internal/util" @@ -39,7 +41,9 @@ func TestMain(m *testing.M) { initFlags() ctx := context.Background() - rt = wazero.NewRuntime(ctx) + cfg := wazero.NewRuntimeConfig(). + WithCoreFeatures(api.CoreFeaturesV2 | experimental.CoreFeaturesThreads) + rt = wazero.NewRuntimeWithConfig(ctx, cfg) wasi_snapshot_preview1.MustInstantiate(ctx, rt) env := vfs.ExportHostFunctions(rt.NewHostModuleBuilder("env")) _, err := env.Instantiate(ctx) diff --git a/vfs/tests/speedtest1/testdata/build.sh b/vfs/tests/speedtest1/testdata/build.sh index 0700b8c..adbc4fb 100755 --- a/vfs/tests/speedtest1/testdata/build.sh +++ b/vfs/tests/speedtest1/testdata/build.sh @@ -10,7 +10,7 @@ WASI_SDK="$ROOT/tools/wasi-sdk-22.0/bin" "$WASI_SDK/clang" --target=wasm32-wasi -std=c23 -flto -g0 -O2 \ -o speedtest1.wasm main.c \ -I"$ROOT/sqlite3" \ - -msimd128 -mmutable-globals \ + -matomics -msimd128 -mmutable-globals \ -mbulk-memory -mreference-types \ -mnontrapping-fptoint -msign-ext \ -fno-stack-protector -fno-stack-clash-protection \ diff --git a/vfs/tests/speedtest1/testdata/speedtest1.wasm.bz2 b/vfs/tests/speedtest1/testdata/speedtest1.wasm.bz2 index 7b4b1cf..0fa7ab6 100644 --- a/vfs/tests/speedtest1/testdata/speedtest1.wasm.bz2 +++ b/vfs/tests/speedtest1/testdata/speedtest1.wasm.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc6236a295ad2b24ec21c13cbd5047817ac4c97722de6fe8b7b16d1760e398e4 -size 491989 +oid sha256:ef42f76fb3c0cf742aa3500454c7d1b2d7e13526f4c39f217c983e574683d757 +size 491674