Skip to content

Commit 63bd1d9

Browse files
committed
Enable '-clang-target' by-default
This will result in the driver passing down '-clang-target' flag to the frontend, which will then ensure that all downstream module (Swift and Clang) compilation compiler sub-invocations are consistent with respect to the target triple used by their underlying instances of Clang. Resulting in all Clang module dependencies being built against the main module's target triple.
1 parent cee8c66 commit 63bd1d9

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ extension Driver {
7474

7575
// Pass down -clang-target.
7676
// If not specified otherwise, we should use the same triple as -target
77-
// TODO: enable -clang-target for implicit module build as well.
7877
if !parsedOptions.hasArgument(.disableClangTarget) &&
79-
isFrontendArgSupported(.clangTarget) &&
80-
parsedOptions.contains(.driverExplicitModuleBuild) {
78+
isFrontendArgSupported(.clangTarget) {
8179
let clangTriple = parsedOptions.getLastArgument(.clangTarget)?.asSingle ?? targetTriple.triple
8280
commandLine.appendFlag(.clangTarget)
8381
commandLine.appendFlag(clangTriple)

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3622,7 +3622,7 @@ final class SwiftDriverTests: XCTestCase {
36223622
#endif
36233623
}
36243624

3625-
func testDisableClangTargetForImplicitModule() throws {
3625+
func testEnableClangTargetForImplicitModule() throws {
36263626
var envVars = ProcessEnv.vars
36273627
envVars["SWIFT_DRIVER_LD_EXEC"] = ld.nativePathString(escaped: false)
36283628

@@ -3632,7 +3632,7 @@ final class SwiftDriverTests: XCTestCase {
36323632
let plannedJobs = try driver.planBuild()
36333633
XCTAssertEqual(plannedJobs.count, 2)
36343634
XCTAssert(plannedJobs[0].commandLine.contains(.flag("-target")))
3635-
XCTAssertFalse(plannedJobs[0].commandLine.contains(.flag("-clang-target")))
3635+
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-clang-target")))
36363636
}
36373637

36383638
func testPCHasCompileInput() throws {

0 commit comments

Comments
 (0)