Skip to content

Commit 830b882

Browse files
committed
Pass-down -clang-target to all frontend jobs
1 parent d93db4a commit 830b882

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ extension Driver {
6666
}
6767
}
6868

69+
// Pass down -clang-target.
70+
// If not specified otherwise, we should use the same triple as -target
71+
if isFrontendArgSupported(.clangTarget) {
72+
let clangTriple = parsedOptions.getLastArgument(.clangTarget)?.asSingle ?? targetTriple.triple
73+
commandLine.appendFlag(.clangTarget)
74+
commandLine.appendFlag(clangTriple)
75+
}
76+
6977
// If in ExplicitModuleBuild mode and the dependency graph has been computed, add module
7078
// dependencies.
7179
// May also be used for generation of the dependency graph itself in ExplicitModuleBuild mode.

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,6 +2439,15 @@ final class SwiftDriverTests: XCTestCase {
24392439
}
24402440
}
24412441

2442+
func testClangTarget() throws {
2443+
var driver = try Driver(args: ["swiftc", "foo.swift"])
2444+
let plannedJobs = try driver.planBuild()
2445+
XCTAssertEqual(plannedJobs.count, 2)
2446+
XCTAssert(plannedJobs[0].commandLine.contains(.flag("-target")))
2447+
XCTAssert(plannedJobs[0].commandLine.contains(.flag("-clang-target")))
2448+
XCTAssert(plannedJobs[1].commandLine.contains(.flag("-target")))
2449+
XCTAssert(plannedJobs[1].commandLine.contains(.flag("-clang-target")))
2450+
}
24422451

24432452
func testPCHasCompileInput() throws {
24442453
var driver = try Driver(args: ["swiftc", "-target", "x86_64-apple-macosx10.14", "-enable-bridging-pch", "-import-objc-header", "TestInputHeader.h", "foo.swift"])

0 commit comments

Comments
 (0)