Skip to content

Wasm: Use -sysroot value as the clang linker sysroot if provided#2053

Merged
jakepetroules merged 1 commit intoswiftlang:mainfrom
kateinoigakukun:yt/respect-sysroot
Feb 28, 2026
Merged

Wasm: Use -sysroot value as the clang linker sysroot if provided#2053
jakepetroules merged 1 commit intoswiftlang:mainfrom
kateinoigakukun:yt/respect-sysroot

Conversation

@kateinoigakukun
Copy link
Copy Markdown
Member

For other Unix-like platforms, the driver already respects -sysroot over -sdk as the native sysroot (not Swift "SDK"). See the following PRs for reference:

For WebAssembly, this change makes the driver behave consistently with other platforms. This consistency is important for supporting swiftc as a swift-build's underlying linker driver for Wasm targets, as UnixLd.xcspec now uses -sysroot by default:
https://github.com/swiftlang/swift-build/blob/02e9f6778b621375b5a5a2fe40f9a4b55bb44ba0/Sources/SWBGenericUnixPlatform/Specs/UnixLd.xcspec#L61-L68

For other Unix-like platforms, the driver already respects `-sysroot`
over `-sdk` as the native sysroot (not Swift "SDK"). See the following
PRs for reference:
* swiftlang#1811
* swiftlang/swift#72352

For WebAssembly, this change makes the driver behave consistently with
other platforms. This consistency is important for supporting swiftc
as a swift-build's underlying linker driver for Wasm targets, as
UnixLd.xcspec now uses `-sysroot` by default:
https://github.com/swiftlang/swift-build/blob/02e9f6778b621375b5a5a2fe40f9a4b55bb44ba0/Sources/SWBGenericUnixPlatform/Specs/UnixLd.xcspec#L61-L68
kateinoigakukun added a commit to kateinoigakukun/swift-build that referenced this pull request Dec 26, 2025
…ot` for now

The override is needed because swift-driver currently does not respect
`-sysroot` for Wasm targets, but only `-sdk`. This will be fixed in
swift-driver in the change: swiftlang/swift-driver#2053
kateinoigakukun added a commit to kateinoigakukun/swift-build that referenced this pull request Dec 26, 2025
…ot` for now

The override is needed because swift-driver currently does not respect
`-sysroot` for Wasm targets, but only `-sdk`. This will be fixed in
swift-driver in the change: swiftlang/swift-driver#2053
@finagolfin
Copy link
Copy Markdown
Member

This new -sysroot approach largely doesn't work, swiftlang/swift#79657, and nobody is using it on Unix, eg in the compiler validation suite. We tried putting it in for Unix only because some Windows people were using this new flag there, and they wanted to try cross-compiling to Android from Windows, but this long command they use shows you it still requires more work.

It is possible that your Wasm work will do fine with it- I don't know- as your SDK bundle may be more self-contained, but it definitely still has problems on Unix.

@jakepetroules
Copy link
Copy Markdown
Contributor

@swift-ci test

@jakepetroules jakepetroules merged commit 95993ca into swiftlang:main Feb 28, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants