You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add Swift WebAssembly compilation support to swift-distributed-tracing (#174)
# Summary
This PR adds support for compiling swift-distributed-tracing to wasm
using the [Swift SDK for
WebAssembly](https://www.swift.org/documentation/articles/wasm-getting-started.html).
This PR is [part of a larger
effort](PassiveLogic/swift-web-examples#1) 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.
- Removed unused `import Dispatch` imports. The Swift SDK for
WebAssembly doesn't currently include GCD. Luckily, all usage of GCD was
unused.
- Added some missing wasi-libc and pthread imports
- Add shim to allow wrapped access to CLOCK_REALTIME struct from
WASILibc. This is a critical piece of distributed tracing to acquire
timestamps that needed some manual shim code to map to the matching API
in WASI.
# Testing done
- [x] Cleaned up swiftformat lint on modified lines of change.
- [x] Verified unit tests still pass with these changes
- [x] Verified `swift build` completes without errors
- [x] Verified no new compiler warnings are added with these changes
- [x] Verified `swift build --swift-sdk wasm32-unknown-wasi` completes
without errors
- [x] Verified `swift build --swift-sdk wasm32-unknown-wasip1-threads`
completes without errors
- [x] Verified a third-party executable can build this library as part
of a larger wasm executable using the command `swift 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.
0 commit comments