-
Notifications
You must be signed in to change notification settings - Fork 43
feat: Add Swift WebAssembly compilation support to swift-distributed-tracing #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@FranzBusch @ktoso would either of you have a moment to review? |
@scottmarchant could you update PR description to refer to official swift.org Swift SDKs for Wasm instead of SwiftWasm? Thanks! |
@MaxDesiatov Done. I updated my other existing PR's as well. |
62ca5b1
to
bfdfbad
Compare
Note, latest push was just rebasing these changes onto the latest tip of |
@@ -35,6 +35,7 @@ let package = Package( | |||
dependencies: [ | |||
.product(name: "ServiceContextModule", package: "swift-service-context"), | |||
.target(name: "Instrumentation"), | |||
.target(name: "_CWASI", condition: .when(platforms: [.wasi])), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We seem to be getting an error on this line on 5.10
error: Target Tracing imports another target (_CWASI) in the package without declaring it a dependency.
Is this a bug in the package manager on 5.10? Can you take a look and if it is a bug we can just disable the strict dependency check on just 5.10
#else | ||
#error("Unsupported runtime") | ||
#endif | ||
|
||
#if canImport(_CWASI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if canImport(_CWASI) | |
#if os(WASI) |
@scottmarchant would you mind addressing formatting job failures per the build log? https://github.com/apple/swift-distributed-tracing/actions/runs/16578688393/job/46920017078?pr=174 |
Summary
This PR adds support for compiling swift-distributed-tracing to wasm using the Swift SDK for WebAssembly.
This PR is part of a larger effort by a company called PassiveLogic to enable broad support for Swift WebAssembly compilation.
Details
There are three changes required to enable wasm compilation for swift-distributed-tracing.
import Dispatch
imports. The Swift SDK for WebAssembly doesn't currently include GCD. Luckily, all usage of GCD was unused.Testing done
swift build
completes without errorsswift build --swift-sdk wasm32-unknown-wasi
completes without errorsswift build --swift-sdk wasm32-unknown-wasip1-threads
completes without errorsswift package --swift-sdk wasm32-unknown-wasip1-threads js --use-cdn
Impact Risk
Realistically, this change should not cause any impact or risk. Outside of wasm targets, the changes in this PR are additive.