Skip to content

Pass the canonical SDK name to the frontend for swiftmodule checking #838

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
merged 2 commits into from
Oct 22, 2021
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
3 changes: 2 additions & 1 deletion Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ extension Driver {

try toolchain.addPlatformSpecificCommonFrontendOptions(commandLine: &commandLine,
inputs: &inputs,
frontendTargetInfo: frontendTargetInfo)
frontendTargetInfo: frontendTargetInfo,
driver: self)
}

mutating func addFrontendSupplementaryOutputArguments(commandLine: inout [Job.ArgTemplate],
Expand Down
9 changes: 8 additions & 1 deletion Sources/SwiftDriver/Toolchains/DarwinToolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ public final class DarwinToolchain: Toolchain {
public func addPlatformSpecificCommonFrontendOptions(
commandLine: inout [Job.ArgTemplate],
inputs: inout [TypedVirtualPath],
frontendTargetInfo: FrontendTargetInfo
frontendTargetInfo: FrontendTargetInfo,
driver: Driver
) throws {
guard let sdkPath = frontendTargetInfo.sdkPath?.path,
let sdkInfo = getTargetSDKInfo(sdkPath: sdkPath) else { return }
Expand All @@ -351,6 +352,12 @@ public final class DarwinToolchain: Toolchain {
commandLine.append(.flag("-target-variant-sdk-version"))
commandLine.append(.flag(sdkInfo.sdkVersion(for: targetVariantTriple).description))
}

if driver.isFrontendArgSupported(.targetSdkName) {
commandLine.append(.flag(Option.targetSdkName.spelling))
commandLine.append(.flag(sdkInfo.canonicalName))
}

// We should be able to pass down prebuilt module dir for all other SDKs.
// For macCatalyst, doing so is specifically necessary because -target-sdk-version
// doesn't always match the macosx sdk version so the compiler may fail to find
Expand Down
6 changes: 4 additions & 2 deletions Sources/SwiftDriver/Toolchains/Toolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public protocol Toolchain {
func addPlatformSpecificCommonFrontendOptions(
commandLine: inout [Job.ArgTemplate],
inputs: inout [TypedVirtualPath],
frontendTargetInfo: FrontendTargetInfo
frontendTargetInfo: FrontendTargetInfo,
driver: Driver
) throws

var dummyForTestingObjectFormat: Triple.ObjectFormat {get}
Expand Down Expand Up @@ -220,7 +221,8 @@ extension Toolchain {
public func addPlatformSpecificCommonFrontendOptions(
commandLine: inout [Job.ArgTemplate],
inputs: inout [TypedVirtualPath],
frontendTargetInfo: FrontendTargetInfo
frontendTargetInfo: FrontendTargetInfo,
driver: Driver
) throws {}
}

Expand Down
12 changes: 12 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3091,6 +3091,12 @@ final class SwiftDriverTests: XCTestCase {
.flag("-target-sdk-version"),
.flag("10.15.0")
]))
if driver.isFrontendArgSupported(.targetSdkName) {
XCTAssertTrue(frontendJobs[0].commandLine.contains(subsequence: [
.flag("-target-sdk-name"),
.flag("macosx10.15"),
]))
}
XCTAssertEqual(frontendJobs[1].kind, .link)
XCTAssertTrue(frontendJobs[1].commandLine.contains(subsequence: [
.flag("-platform_version"),
Expand Down Expand Up @@ -3141,6 +3147,12 @@ final class SwiftDriverTests: XCTestCase {
.flag("-target-variant-sdk-version"),
.flag("13.4.0")
]))
if driver.isFrontendArgSupported(.targetSdkName) {
XCTAssertTrue(frontendJobs[0].commandLine.contains(subsequence: [
.flag("-target-sdk-name"),
.flag("macosx10.15.4"),
]))
}
XCTAssertEqual(frontendJobs[1].kind, .link)
XCTAssertTrue(frontendJobs[1].commandLine.contains(subsequence: [
.flag("-platform_version"),
Expand Down