Skip to content

Commit 871e531

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 94ce9d1 commit 871e531

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
@@ -351,6 +351,10 @@ public final class DarwinToolchain: Toolchain {
351351
commandLine.append(.flag("-target-variant-sdk-version"))
352352
commandLine.append(.flag(sdkInfo.sdkVersion(for: targetVariantTriple).description))
353353
}
354+
355+
commandLine.append(.flag("-target-sdk-name"))
356+
commandLine.append(.flag(sdkInfo.canonicalName))
357+
354358
// We should be able to pass down prebuilt module dir for all other SDKs.
355359
// For macCatalyst, doing so is specifically necessary because -target-sdk-version
356360
// 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
@@ -3091,6 +3091,10 @@ final class SwiftDriverTests: XCTestCase {
30913091
.flag("-target-sdk-version"),
30923092
.flag("10.15.0")
30933093
]))
3094+
XCTAssertTrue(frontendJobs[0].commandLine.contains(subsequence: [
3095+
.flag("-target-sdk-name"),
3096+
.flag("macosx10.15"),
3097+
]))
30943098
XCTAssertEqual(frontendJobs[1].kind, .link)
30953099
XCTAssertTrue(frontendJobs[1].commandLine.contains(subsequence: [
30963100
.flag("-platform_version"),
@@ -3113,6 +3117,8 @@ final class SwiftDriverTests: XCTestCase {
31133117
.flag("10.15.0"),
31143118
.flag("-target-variant-sdk-version"),
31153119
.flag("13.1.0"),
3120+
.flag("-target-sdk-name"),
3121+
.flag("macosx10.15"),
31163122
]))
31173123
XCTAssertEqual(frontendJobs[1].kind, .link)
31183124
XCTAssertTrue(frontendJobs[1].commandLine.contains(subsequence: [
@@ -3139,7 +3145,9 @@ final class SwiftDriverTests: XCTestCase {
31393145
.flag("-target-sdk-version"),
31403146
.flag("10.15.4"),
31413147
.flag("-target-variant-sdk-version"),
3142-
.flag("13.4.0")
3148+
.flag("13.4.0"),
3149+
.flag("-target-sdk-name"),
3150+
.flag("macosx10.15.4"),
31433151
]))
31443152
XCTAssertEqual(frontendJobs[1].kind, .link)
31453153
XCTAssertTrue(frontendJobs[1].commandLine.contains(subsequence: [
@@ -3166,7 +3174,9 @@ final class SwiftDriverTests: XCTestCase {
31663174
.flag("-target-sdk-version"),
31673175
.flag("13.4.0"),
31683176
.flag("-target-variant-sdk-version"),
3169-
.flag("10.15.4")
3177+
.flag("10.15.4"),
3178+
.flag("-target-sdk-name"),
3179+
.flag("macosx10.15.4"),
31703180
]))
31713181
XCTAssertEqual(frontendJobs[1].kind, .link)
31723182
XCTAssertTrue(frontendJobs[1].commandLine.contains(subsequence: [

0 commit comments

Comments
 (0)