feat: Enable WebAssembly compilation#3
Merged
Merged
Conversation
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>
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 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Add WebAssembly (
wasm32-unknown-wasip1) support to SQLiteNIO. On wasi it builds on upstreamapple/swift-nio(NIOCore) plus the standalonePassiveLogic/nio-async-runtimefor the event loop and thread pool, gating outNIOPosix. Non-wasm platforms compile the sameNIOPosixcode as before.SQLiteDatastoresINTEGERaffinity as aSQLiteInt64(Int64on 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- addPassiveLogic/nio-async-runtime; takeNIOAsyncRuntimefrom it on wasi and gateNIOPosixto non-wasi on theSQLiteNIOtarget.Sources/SQLiteNIO/SQLiteConnection.swift-#if os(WASI)importNIOAsyncRuntime(drop-inMultiThreadedEventLoopGroup/NIOThreadPool),NIOPosixelsewhere.Sources/SQLiteNIO/Exports.swift- re-exportNIOThreadPoolandMultiThreadedEventLoopGroupfromNIOAsyncRuntimeon wasi.Sources/SQLiteNIO/SQLiteData.swift,Sources/SQLiteNIO/SQLiteStatement.swift-SQLiteInt64typealias soINTEGERvalues stay 64-bit on 32-bit platforms (wasm32)..github/workflows/test.yml- enable the wasm job (with_wasm: true).Tested
swift buildswift build --swift-sdk <wasm> --explicit-target-dependency-import-check error