Skip to content

SwiftSDK: Remove hardcoded WASI sysroot path derivation #8468

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

Merged

Conversation

kateinoigakukun
Copy link
Member

Remove hardcoded WASI sysroot path derivation just for wasi-sysroot embedded in toolchains

Motivation:

The previous implementation assumed there is $TOOLCHAIN_ROOT/share/wasi-sysroot when --triple wasm32-unknown-wasi is passed, but this is no longer the case with the deprecation of the Wasm toolchain installation in favor of Swift SDKs.

Due to this unnecessary branch, when --triple wasm32-unknown-wasi is passed together with --swift-sdk, --swift-sdk is just ignored: #8465

Modifications:

This change removes the hardcoded path derivation for the WASI sysroot from the SwiftSDK.deriveTargetSwiftSDK method.

Result:

When --triple wasm32-unknown-wasi is passed without --swift-sdk, no user visible change and they will keep getting the following:

error: emit-module command failed with exit code 1 (use -v to see invocation)
<unknown>:0: warning: libc not found for 'wasm32-unknown-wasi'; C stdlib may be unavailable
<unknown>:0: error: unable to load standard library for target 'wasm32-unknown-wasi'

When --triple wasm32-unknown-wasi is passed together with --swift-sdk, --triple is ignored and --swift-sdk is respected.

This change removes the hardcoded path derivation for the WASI sysroot
from the `SwiftSDK.deriveTargetSwiftSDK` method. The previous implementation
assumed there is $TOOLCHAIN_ROOT/share/wasi-sysroot when `--triple
wasm32-unknown-wasi` is passed, but this is no longer the case with the
[deprecation of the Wasm toolchain
installation](swiftwasm/swift#5604) in favor
of Swift SDKs.
@kateinoigakukun
Copy link
Member Author

@swift-ci test

@jakepetroules
Copy link
Contributor

Thanks! Small clarification...

When --triple wasm32-unknown-wasi is passed together with --swift-sdk, --triple is ignored and --swift-sdk is respected.

What do you mean "--triple is ignored"? Swift SDKs can support multiple triples, so it's supposed to be supported to pass both --swift-sdk and --triple at the same time. Or do you simply mean it's ignored because that Swift SDK just so happens to support only one triple, which just so happens to be the same as the given value in this case?

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.

This also seems like it'd be a good candidate for 6.1.2 if possible.

@kateinoigakukun
Copy link
Member Author

kateinoigakukun commented Apr 9, 2025

@jakepetroules

Swift SDKs can support multiple triples

Yes, Swift SDK format itself allows supporting multiple triples, but the current SwiftPM's implementation does not respect the value passed to --triple but just use --swift-sdk value when selecting a Swift SDK. See #7973 for more details

I have a plan to make a follow-up fix for it separately later.

@jakepetroules
Copy link
Contributor

@jakepetroules

Swift SDKs can support multiple triples

Yes, Swift SDK format itself allows supporting multiple triples, but the current SwiftPM's implementation does not respect the value passed to --triple but just use --swift-sdk value when selecting a Swift SDK. See #7973 for more details

I have a plan to make a follow-up fix for it separately later.

Got it, thanks for clarifying.

@jakepetroules jakepetroules linked an issue Apr 9, 2025 that may be closed by this pull request
1 task
@jakepetroules
Copy link
Contributor

@swift-ci test windows

kateinoigakukun added a commit to kateinoigakukun/sourcekit-lsp that referenced this pull request Apr 9, 2025
After swiftlang/swift-package-manager#8468, we
no longer support wasi-sysroot embedded in the Swift toolchain, so the
test no longer makes sense.
@kateinoigakukun
Copy link
Member Author

@MaxDesiatov
Copy link
Contributor

swiftlang/sourcekit-lsp#2107
@swift-ci test macos

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Thanks!

@MaxDesiatov MaxDesiatov enabled auto-merge (squash) April 9, 2025 09:28
@MaxDesiatov
Copy link
Contributor

@swift-ci test self hosted windows

@MaxDesiatov MaxDesiatov merged commit 21e3336 into swiftlang:main Apr 9, 2025
6 checks passed
@kateinoigakukun
Copy link
Member Author

Ah, we had to merge swiftlang/sourcekit-lsp#2107 before this...

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.

C++ code fails to find libc++ headers using the WebAssembly Swift SDK
3 participants