-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
Is it reproducible with SwiftPM command-line tools: swift build
, swift test
, swift package
etc?
- Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands,
swift build
,swift test
,swift package
etc.
Description
Builds will fail to find standard C++ headers when using a WebAssembly Swift SDK.
This is due to the following code in SwiftPM passing a hardcoded sysroot (using --sysroot
) for WASM triples:
/// Returns a default Swift SDK of a given target environment.
public static func defaultSwiftSDK(
for targetTriple: Triple,
hostSDK: SwiftSDK,
environment: Environment = .current
) -> SwiftSDK? {
if targetTriple.isWASI() {
let wasiSysroot = hostSDK.toolset.rootPaths.first?
.parentDirectory // usr
.appending(components: "share", "wasi-sysroot")
return SwiftSDK(
targetTriple: targetTriple,
toolset: hostSDK.toolset,
pathsConfiguration: .init(sdkRootPath: wasiSysroot)
)
}
On my system, that expands to:
$HOME/Library/Developer/Toolchains/swift-6.1-RELEASE.xctoolchain/usr/share/wasi-sysroot
which does not exist. The actual path should be:
$HOME/Library/org.swift.swiftpm/swift-sdks/swift-wasm-6.1-RELEASE-wasm32-unknown-wasi.artifactbundle/6.1-RELEASE-wasm32-unknown-wasi/wasm32-unknown-wasi
Expected behavior
No response
Actual behavior
No response
Steps to reproduce
git clone https://github.com/swiftlang/swift-build
cd swift-build
swift build --triple wasm32-unknown-wasi --swift-sdk swift-wasm-6.1-RELEASE-wasm32-unknown-wasi
Swift Package Manager version/commit hash
6.1-RELEASE
Swift & OS version (output of swift --version ; uname -a
)
Apple Swift version 6.1 (swift-6.1-RELEASE)
Target: arm64-apple-macosx15.0