Skip to content

feat: Enable WebAssembly compilation#3

Merged
krodak merged 1 commit into
mainfrom
feat/wasm-compilation
Jul 23, 2026
Merged

feat: Enable WebAssembly compilation#3
krodak merged 1 commit into
mainfrom
feat/wasm-compilation

Conversation

@krodak

@krodak krodak commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Overview

Add WebAssembly (wasm32-unknown-wasip1) support to SQLiteNIO. On wasi it builds on upstream apple/swift-nio (NIOCore) plus the standalone PassiveLogic/nio-async-runtime for the event loop and thread pool, gating out NIOPosix. Non-wasm platforms compile the same NIOPosix code as before.

SQLiteData stores INTEGER affinity as a SQLiteInt64 (Int64 on 32-bit) so 64-bit SQLite integers do not truncate on wasm32.

Draft: pins PassiveLogic/nio-async-runtime, which has a pending low-level wasm fix. Final version + tag once that lands.

Links

What changed

  • Package.swift - add PassiveLogic/nio-async-runtime; take NIOAsyncRuntime from it on wasi and gate NIOPosix to non-wasi on the SQLiteNIO target.
  • Sources/SQLiteNIO/SQLiteConnection.swift - #if os(WASI) import NIOAsyncRuntime (drop-in MultiThreadedEventLoopGroup / NIOThreadPool), NIOPosix elsewhere.
  • Sources/SQLiteNIO/Exports.swift - re-export NIOThreadPool and MultiThreadedEventLoopGroup from NIOAsyncRuntime on wasi.
  • Sources/SQLiteNIO/SQLiteData.swift, Sources/SQLiteNIO/SQLiteStatement.swift - SQLiteInt64 typealias so INTEGER values stay 64-bit on 32-bit platforms (wasm32).
  • .github/workflows/test.yml - enable the wasm job (with_wasm: true).

Tested

  • swift build
  • swift build --swift-sdk <wasm> --explicit-target-dependency-import-check error

Add wasm (wasm32-unknown-wasip1) support: depend on upstream apple/swift-nio
plus the standalone PassiveLogic/nio-async-runtime, importing NIOAsyncRuntime's
NIOThreadPool and MultiThreadedEventLoopGroup on wasi and NIOPosix elsewhere,
gated on os(WASI). SQLiteData now stores INTEGER affinity as a SQLiteInt64
(Int64 on 32-bit) so 64-bit SQLite integers do not truncate on wasm32. NIOPosix
is gated to non-wasi in the manifest; non-wasm builds are unchanged.

Co-authored-by: Scott Marchant <scottm@passivelogic.com>
@krodak
krodak marked this pull request as ready for review July 22, 2026 19:13
@krodak krodak self-assigned this Jul 22, 2026
@krodak
krodak requested a review from scottmarchant July 22, 2026 20:26
@krodak

krodak commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

Merging this to unblock the sqlite-kit wasm PR (PassiveLogic/sqlite-kit#3). All green (wasm + linux + macOS + android). @scottmarchant flagging for visibility 🙏

@krodak
krodak merged commit 4bcd748 into main Jul 23, 2026
50 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant