Skip to content

Commit 21e3336

Browse files
SwiftSDK: Remove hardcoded WASI sysroot path derivation (#8468)
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](swiftwasm/swift#5604) 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.
1 parent cc0b1a5 commit 21e3336

File tree

2 files changed

+0
-24
lines changed

2 files changed

+0
-24
lines changed

Sources/PackageModel/SwiftSDKs/SwiftSDK.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -691,17 +691,6 @@ public struct SwiftSDK: Equatable {
691691
hostSDK: SwiftSDK,
692692
environment: Environment = .current
693693
) -> SwiftSDK? {
694-
if targetTriple.isWASI() {
695-
let wasiSysroot = hostSDK.toolset.rootPaths.first?
696-
.parentDirectory // usr
697-
.appending(components: "share", "wasi-sysroot")
698-
return SwiftSDK(
699-
targetTriple: targetTriple,
700-
toolset: hostSDK.toolset,
701-
pathsConfiguration: .init(sdkRootPath: wasiSysroot)
702-
)
703-
}
704-
705694
#if os(macOS)
706695
if let darwinPlatform = targetTriple.darwinPlatform {
707696
// the Darwin SDKs are trivially available on macOS

Tests/PackageModelTests/SwiftSDKBundleTests.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -450,19 +450,6 @@ final class SwiftSDKBundleTests: XCTestCase {
450450
XCTAssertEqual(targetSwiftSDK.toolset.rootPaths, [toolsetRootPath] + hostSwiftSDK.toolset.rootPaths)
451451
}
452452

453-
do {
454-
let targetSwiftSDK = try SwiftSDK.deriveTargetSwiftSDK(
455-
hostSwiftSDK: hostSwiftSDK,
456-
hostTriple: hostTriple,
457-
swiftSDKSelector: "wasm32-unknown-wasi",
458-
store: store,
459-
observabilityScope: system.topScope,
460-
fileSystem: fileSystem
461-
)
462-
// Ensure that triples that have a `defaultSwiftSDK` are handled
463-
XCTAssertEqual(targetSwiftSDK.targetTriple?.triple, "wasm32-unknown-wasi")
464-
}
465-
466453
do {
467454
// Check explicit overriding options.
468455
let customCompileSDK = AbsolutePath("/path/to/sdk")

0 commit comments

Comments
 (0)