Skip to content

Commit 930bfcf

Browse files
committed
Pass the canonical SDK name to the frontend
The frontend will use this information to control which swiftmodule file can be loaded according to the SDK in use. Swiftmodule files should only be used in the context of the SDK used to create them. This will catch issues with roots and other configuration problems. rdar://83104265
1 parent 54450a7 commit 930bfcf

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Sources/SwiftDriver/Toolchains/DarwinToolchain.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ public final class DarwinToolchain: Toolchain {
336336
commandLine.append(.flag("-target-variant-sdk-version"))
337337
commandLine.append(.flag(sdkInfo.sdkVersion(for: targetVariantTriple).description))
338338
}
339+
340+
commandLine.append(.flag("-target-sdk-name"))
341+
commandLine.append(.flag(sdkInfo.canonicalName))
342+
339343
// We should be able to pass down prebuilt module dir for all other SDKs.
340344
// For macCatalyst, doing so is specifically necessary because -target-sdk-version
341345
// doesn't always match the macosx sdk version so the compiler may fail to find

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,6 +2955,10 @@ final class SwiftDriverTests: XCTestCase {
29552955
.flag("-target-sdk-version"),
29562956
.flag("10.15.0")
29572957
]))
2958+
XCTAssertTrue(frontendJobs[0].commandLine.contains(subsequence: [
2959+
.flag("-target-sdk-name"),
2960+
.flag("macosx10.15"),
2961+
]))
29582962
XCTAssertEqual(frontendJobs[1].kind, .link)
29592963
XCTAssertTrue(frontendJobs[1].commandLine.contains(subsequence: [
29602964
.flag("-platform_version"),
@@ -2977,6 +2981,8 @@ final class SwiftDriverTests: XCTestCase {
29772981
.flag("10.15.0"),
29782982
.flag("-target-variant-sdk-version"),
29792983
.flag("13.1.0"),
2984+
.flag("-target-sdk-name"),
2985+
.flag("macosx10.15"),
29802986
]))
29812987
XCTAssertEqual(frontendJobs[1].kind, .link)
29822988
XCTAssertTrue(frontendJobs[1].commandLine.contains(subsequence: [
@@ -3003,7 +3009,9 @@ final class SwiftDriverTests: XCTestCase {
30033009
.flag("-target-sdk-version"),
30043010
.flag("10.15.4"),
30053011
.flag("-target-variant-sdk-version"),
3006-
.flag("13.4.0")
3012+
.flag("13.4.0"),
3013+
.flag("-target-sdk-name"),
3014+
.flag("macosx10.15.4"),
30073015
]))
30083016
XCTAssertEqual(frontendJobs[1].kind, .link)
30093017
XCTAssertTrue(frontendJobs[1].commandLine.contains(subsequence: [
@@ -3030,7 +3038,9 @@ final class SwiftDriverTests: XCTestCase {
30303038
.flag("-target-sdk-version"),
30313039
.flag("13.4.0"),
30323040
.flag("-target-variant-sdk-version"),
3033-
.flag("10.15.4")
3041+
.flag("10.15.4"),
3042+
.flag("-target-sdk-name"),
3043+
.flag("macosx10.15.4"),
30343044
]))
30353045
XCTAssertEqual(frontendJobs[1].kind, .link)
30363046
XCTAssertTrue(frontendJobs[1].commandLine.contains(subsequence: [

0 commit comments

Comments
 (0)