feat: Enable WebAssembly compilation#2
Merged
Conversation
krodak
force-pushed
the
feat/wasm-compilation
branch
from
July 21, 2026 10:11
28cc0ab to
f77b2b7
Compare
krodak
force-pushed
the
feat/wasm-compilation
branch
from
July 21, 2026 16:43
f77b2b7 to
fc5cfd4
Compare
scottmarchant
self-requested a review
July 21, 2026 16:44
scottmarchant
approved these changes
Jul 21, 2026
Add wasm (wasm32-unknown-wasip1) support: depend on upstream apple/swift-nio plus the standalone PassiveLogic/nio-async-runtime for the wasi event loop, and gate NIOPosix to non-wasi. NIOCore stays shared. Dispatch-based connection-pool shutdown falls back to structured concurrency (Task / withTaskGroup) where Dispatch is unavailable, and the blocking syncShutdownGracefully() is compiled out on wasi. Non-wasm builds compile the same NIOPosix code as before. Co-authored-by: Scott Marchant <scottm@passivelogic.com>
krodak
force-pushed
the
feat/wasm-compilation
branch
from
July 21, 2026 16:55
fc5cfd4 to
db3a187
Compare
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 AsyncKit. On wasi it builds on upstreamapple/swift-nio(NIOCore) plus the standalonePassiveLogic/nio-async-runtimefor the event loop, gating outNIOPosix. Non-wasm platforms compile the sameNIOPosixcode as before, soswift-niostays vanilla for consumers.The one runtime adaptation is connection-pool shutdown: where
Dispatchis unavailable (wasm), theDispatchQueue/DispatchGrouppath falls back to structured concurrency (Task/withTaskGroup), and the blockingsyncShutdownGracefully()is compiled out.Links
What changed
Package.swift- depend on upstreamapple/swift-nio(from 2.89.0) +PassiveLogic/nio-async-runtime; gateNIOPosixto non-wasi andNIOAsyncRuntimeto wasi on theAsyncKitand test targets.Sources/AsyncKit/ConnectionPool/EventLoopGroupConnectionPool.swift-#if canImport(Dispatch)guards; aTask/withTaskGroupshutdown fallback for wasm;syncShutdownGracefully()compiled out whereDispatchis absent.Sources/AsyncKit/ConnectionPool/EventLoopConnectionPool.swift- explicitDequeModule/OrderedCollectionsimports (required by theMemberImportVisibilityupcoming feature).Sources/AsyncKit/Exports.swift- re-exportMultiThreadedEventLoopGroupfromNIOAsyncRuntimeon wasi andNIOPosixelsewhere; gateNIOEmbeddedoff wasi.Tests/AsyncKitTests/ConnectionPoolTests.swift- explicitNIOPosix.MultiThreadedEventLoopGroupimport (previously came via the re-export)..github/workflows/test.yml- enable the wasm job (with_wasm: true).Tested
swift buildswift build --swift-sdk swift-6.3-RELEASE_wasm