Skip to content

Suppress warning about missing SDKSettings.json for non-Darwin platforms #1619

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2805,7 +2805,7 @@ extension Driver {

if !fileSystem.exists(path) {
diagnosticsEngine.emit(.warning_no_such_sdk(sdkPath))
} else if !(targetTriple?.isWindows ?? (defaultToolchainType == WindowsToolchain.self)) {
} else if (targetTriple?.isDarwin ?? (defaultToolchainType == DarwinToolchain.self)) {
if isSDKTooOld(sdkPath: path, fileSystem: fileSystem,
diagnosticsEngine: diagnosticsEngine) {
diagnosticsEngine.emit(.error_sdk_too_old(sdkPath))
Expand Down
23 changes: 23 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4457,6 +4457,29 @@ final class SwiftDriverTests: XCTestCase {
}
}

func testNonDarwinSDK() throws {
try withTemporaryDirectory { tmpDir in
let sdk = tmpDir.appending(component: "NonDarwin.sdk")
// SDK without SDKSettings.json should be ok for non-Darwin platforms
try localFileSystem.createDirectory(sdk, recursive: true)
for triple in ["x86_64-unknown-linux-gnu", "wasm32-unknown-wasi"] {
try assertDriverDiagnostics(args: "swiftc", "-target", triple, "foo.swift", "-sdk", sdk.pathString) {
$1.forbidUnexpected(.error, .warning)
}
}
}
}

func testDarwinSDKWithoutSDKSettings() throws {
try withTemporaryDirectory { tmpDir in
let sdk = tmpDir.appending(component: "MacOSX10.15.sdk")
try localFileSystem.createDirectory(sdk, recursive: true)
try assertDriverDiagnostics(args: "swiftc", "-target", "x86_64-apple-macosx10.15", "foo.swift", "-sdk", sdk.pathString) {
$1.expect(.warning("Could not read SDKSettings.json for SDK at: \(sdk.pathString)"))
}
}
}

func testDarwinSDKToolchainName() throws {
var envVars = ProcessEnv.vars
envVars["SWIFT_DRIVER_LD_EXEC"] = ld.nativePathString(escaped: false)
Expand Down