Skip to content

Commit 06d4c79

Browse files
Merge pull request #1619 from kateinoigakukun/yt/supress-sdk-settings-warning
2 parents d072c0c + ed6b47f commit 06d4c79

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2805,7 +2805,7 @@ extension Driver {
28052805

28062806
if !fileSystem.exists(path) {
28072807
diagnosticsEngine.emit(.warning_no_such_sdk(sdkPath))
2808-
} else if !(targetTriple?.isWindows ?? (defaultToolchainType == WindowsToolchain.self)) {
2808+
} else if (targetTriple?.isDarwin ?? (defaultToolchainType == DarwinToolchain.self)) {
28092809
if isSDKTooOld(sdkPath: path, fileSystem: fileSystem,
28102810
diagnosticsEngine: diagnosticsEngine) {
28112811
diagnosticsEngine.emit(.error_sdk_too_old(sdkPath))

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4457,6 +4457,29 @@ final class SwiftDriverTests: XCTestCase {
44574457
}
44584458
}
44594459

4460+
func testNonDarwinSDK() throws {
4461+
try withTemporaryDirectory { tmpDir in
4462+
let sdk = tmpDir.appending(component: "NonDarwin.sdk")
4463+
// SDK without SDKSettings.json should be ok for non-Darwin platforms
4464+
try localFileSystem.createDirectory(sdk, recursive: true)
4465+
for triple in ["x86_64-unknown-linux-gnu", "wasm32-unknown-wasi"] {
4466+
try assertDriverDiagnostics(args: "swiftc", "-target", triple, "foo.swift", "-sdk", sdk.pathString) {
4467+
$1.forbidUnexpected(.error, .warning)
4468+
}
4469+
}
4470+
}
4471+
}
4472+
4473+
func testDarwinSDKWithoutSDKSettings() throws {
4474+
try withTemporaryDirectory { tmpDir in
4475+
let sdk = tmpDir.appending(component: "MacOSX10.15.sdk")
4476+
try localFileSystem.createDirectory(sdk, recursive: true)
4477+
try assertDriverDiagnostics(args: "swiftc", "-target", "x86_64-apple-macosx10.15", "foo.swift", "-sdk", sdk.pathString) {
4478+
$1.expect(.warning("Could not read SDKSettings.json for SDK at: \(sdk.pathString)"))
4479+
}
4480+
}
4481+
}
4482+
44604483
func testDarwinSDKToolchainName() throws {
44614484
var envVars = ProcessEnv.vars
44624485
envVars["SWIFT_DRIVER_LD_EXEC"] = ld.nativePathString(escaped: false)

0 commit comments

Comments
 (0)