Skip to content

Conversation

@MaxDesiatov
Copy link
Contributor

@MaxDesiatov MaxDesiatov commented May 14, 2025

As WasmKit is included in recent development snapshots of the swift.org toolchain, we should select it as a default debugger and test runner when a Wasm triple is selected. User toolsets can still override it if needed through toolset merging algorithm described in SE-0387.

This allows swift run and swift test to delegate to WasmKit when cross-compiling for any Wasm triple.

rdar://150382758

As WasmKit is included in recent development snapshots of the swift.org toolchain, we should select it as a default debugger and test runner when a Wasm triple is selected. User toolsets can still override it if needed through toolset merging algorithm described in SE-0387.
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test windows

1 similar comment
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test windows

@MaxDesiatov
Copy link
Contributor Author

@swift-ci please test self hosted windows

@kateinoigakukun
Copy link
Member

I think it would be nice if we can generalize it by introducing a way to express a toolchain binary path in toolset.json like { "testRunner": "path": { "type": "toolchain-lookup", "name": "wasmkit" } }, but let's leave it as a future work.

@dschaefer2
Copy link
Member

I think it would be nice if we can generalize it by introducing a way to express a toolchain binary path in toolset.json like { "testRunner": "path": { "type": "toolchain-lookup", "name": "wasmkit" } }, but let's leave it as a future work.

Agreed. We need to stop hardcoding so much stuff. We need to allow for someone to come along and change these things without having to put up a PR.

@MaxDesiatov
Copy link
Contributor Author

MaxDesiatov commented May 14, 2025

I think it would be nice if we can generalize it by introducing a way to express a toolchain binary path in toolset.json like { "testRunner": "path": { "type": "toolchain-lookup", "name": "wasmkit" } }, but let's leave it as a future work.

Agreed. We need to stop hardcoding so much stuff. We need to allow for someone to come along and change these things without having to put up a PR.

As I've mentioned in the PR description, if you need to override things you can just apply your own toolset on top of the default toolset, which is the mechanism I've explicitly described in the Swift SDKs proposal foreseeing this use case.

You don't need any PR to change or override this for your own needs. We're only providing a default here.

What's hardcoded here is the toolchain default. Since WasmKit ships with the toolchain, it's toolchain's job to know it is there and available. If it shipped within a Swift SDK instead, then we would specify it in the Swift SDK. Since Swift SDK has no control over the toolchain, it's natural for the toolchain stuff to be hardcoded in the toolchain itself. It's no different from Clang hardcoding wasm-ld, knowing that wasm-ld ships together with Clang.

MaxDesiatov added a commit to swiftlang/sourcekit-lsp that referenced this pull request May 14, 2025
This became a required parameter in swiftlang/swift-package-manager#8668, which can be easily computed, since the host toolchain in practice is always available when `SwiftSDKBundleStore` is initialized.
@MaxDesiatov
Copy link
Contributor Author

Copy link
Contributor

@jakepetroules jakepetroules left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this will be a great improvement to the out-of-the-box experience for using Wasm.

@MaxDesiatov MaxDesiatov merged commit 02fe923 into main May 15, 2025
6 checks passed
@MaxDesiatov MaxDesiatov deleted the maxd/wasmkit-path branch May 15, 2025 08:16
MaxDesiatov added a commit to swiftlang/sourcekit-lsp that referenced this pull request May 15, 2025
This became a required parameter in
swiftlang/swift-package-manager#8668, which can
be easily computed, since the host toolchain in practice is always available when `SwiftSDKBundleStore` is initialized.
@MaxDesiatov MaxDesiatov restored the maxd/wasmkit-path branch May 19, 2025 16:35
MaxDesiatov added a commit to swiftlang/sourcekit-lsp that referenced this pull request May 20, 2025
This became a required parameter in
swiftlang/swift-package-manager#8668, which can
be easily computed, since the host toolchain in practice is always available when `SwiftSDKBundleStore` is initialized.
dschaefer2 pushed a commit that referenced this pull request May 22, 2025
Cherry-pick of #8668, merged as 02fe923

**Explanation**: As [WasmKit](https://github.com/swiftwasm/WasmKit) is
included in recent development snapshots of the swift.org toolchain, we
should select it as a default debugger and test runner when a Wasm
triple is selected. User toolsets can still override it if needed
through toolset merging algorithm described in
[SE-0387](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md).

This allows `swift run` and `swift test` to delegate to WasmKit when
cross-compiling for any Wasm triple.

**Scope**: Limited to cross-compilation.
**Risk**: Low due to limited scope and added test coverage.
**Testing**: Add new automated test cases, manual testing with Wasm
products.
**Issue**: rdar://150382758
**Reviewer**: @kateinoigakukun @jakepetroules
@MaxDesiatov MaxDesiatov deleted the maxd/wasmkit-path branch June 13, 2025 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants