Repository navigation
Add WASI Threads thread-spawn support - #423
Conversation
| |---------|--------|-----------------| | ||
| | [WASI 0.1](https://github.com/WebAssembly/WASI/tree/wasi-0.1) | 🚧 [Majority of syscalls implemented](https://github.com/swiftwasm/WasmKit/blob/d9b56a7b3f979a72682c0d37f6cc71b3493dae65/Tests/WASITests/IntegrationTests.swift#L31) | [0.0.2] | | ||
| | [WASI Threads](https://github.com/WebAssembly/wasi-threads) | ❌ Not implemented | | | ||
| | [WASI Threads](https://github.com/WebAssembly/wasi-threads) | ✅ Implemented | `wasmkit-cli run --feature threads --wasi-threads` | |
There was a problem hiding this comment.
Do you think that passing both should be required? I feel like --feature threads should be enough, and we can detect that it's WASIp1 threads from the list of imports?
| @Flag(name: .customLong("wasi-threads"), help: "Enable WASI Threads") | ||
| var wasiThreads = false |
There was a problem hiding this comment.
Same as README.md comment below: I feel this is redundant, we can auto-detect if from imports when --feature threads is passed.
| @Flag(name: .customLong("wasi-threads"), help: "Enable WASI Threads") | |
| var wasiThreads = false |
There was a problem hiding this comment.
I think auto-enabling --feature threads based on --wasi-threads makes sense but not the opposite side, because wasi-threads depends on core threads proposal but not the other way.
| name: .customLong("feature"), | ||
| help: "Enable a WebAssembly proposal feature (memory64, reference-types, threads, tail-call, simd, exception-handling)" | ||
| ) | ||
| var features: [Feature] = [] |
There was a problem hiding this comment.
Did we not have any of these enabled by default previously? It would be confusing if CLI supported EH or SIMD by default, and in the new release we'd start requiring explicit options for it.
There was a problem hiding this comment.
Good point. We should keep the default feature set consistent with the one in WasmParser.
Co-authored-by: Max Desiatov <[email protected]>
| } | ||
| } | ||
|
|
||
| private func terminateProcess(_ code: Int32) -> Never { |
There was a problem hiding this comment.
fatalError("WASI Threads is unavailable on this platform") in this body makes this function specific to the threads implementation, which IMO should be reflected in its name. The current name seems too general.
| private func terminateProcess(_ code: Int32) -> Never { | |
| private func wasiThreadsTerminateProcess(_ code: Int32) -> Never { |
wasi-threads depends on the core threads proposal, so opting into the former now enables the latter instead of erroring out. Also rename the CLI-local exit helper to reflect that it is WASI-Threads specific.
The valid values are already rendered by ArgumentParser from CaseIterable, and the default-enabled subset is now computed from WasmFeatureSet.default instead of being spelled out again in the help string.
WasmFeatureSet now enumerates its proposals as cases, and its flags and `all` are derived from them. The CLI no longer keeps a parallel list; it only spells each proposal for the command line in an exhaustive switch, so a new proposal fails to build until it is named.
Start distributing the `wasip1-threads` triple in Swift SDKs for evaluation in `main` development snapshots. WasmKit gained WASI Threads thread-spawn support in swiftwasm/WasmKit#423, so the TODO deferring this no longer applies.
Summary
Rework #386
--feature threadsproposal gatingValidation
swift build --product wasmkit-cliswift test --filter RunOptionsTestsswift test --filter WASIThreadsTestsswift test --filter WASIThreadsSubprocessTests