Skip to content

Commit e02fad1

Browse files
Merge pull request #1808 from cachemeifyoucan/eng/PR-fix-auto-bridging-chaining
[BridgingHeader] Pass bridging header chaining flag for all jobs
2 parents 115874c + cc66043 commit e02fad1

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ public struct Driver {
338338
/// Original ObjC Header passed from command-line
339339
let originalObjCHeaderFile: VirtualPath.Handle?
340340

341+
342+
/// Enable bridging header chaining.
343+
let bridgingHeaderChaining: Bool
344+
341345
/// The path to the imported Objective-C header.
342346
lazy var importedObjCHeader: VirtualPath.Handle? = {
343347
assert(explicitDependencyBuildPlanner != nil ||
@@ -1126,6 +1130,19 @@ public struct Driver {
11261130
self.originalObjCHeaderFile = nil
11271131
}
11281132

1133+
if parsedOptions.hasFlag(positive: .autoBridgingHeaderChaining,
1134+
negative: .noAutoBridgingHeaderChaining,
1135+
default: false) || cachingEnabled {
1136+
if producePCHJob {
1137+
self.bridgingHeaderChaining = true
1138+
} else {
1139+
diagnosticEngine.emit(.warning("-auto-bridging-header-chaining requires generatePCH job, no chaining will be performed"))
1140+
self.bridgingHeaderChaining = false
1141+
}
1142+
} else {
1143+
self.bridgingHeaderChaining = false
1144+
}
1145+
11291146
self.useClangIncludeTree = !parsedOptions.hasArgument(.noClangIncludeTree) && !env.keys.contains("SWIFT_CACHING_USE_CLANG_CAS_FS")
11301147
self.scannerPrefixMap = try Self.computeScanningPrefixMapper(&parsedOptions)
11311148
if let sdkMapping = parsedOptions.getLastArgument(.scannerPrefixMapSdk)?.asSingle {

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,15 @@ extension Driver {
495495
}
496496
}
497497

498+
// Pass bridging header chaining options.
499+
if isFrontendArgSupported(.autoBridgingHeaderChaining) {
500+
if bridgingHeaderChaining {
501+
commandLine.appendFlag(.autoBridgingHeaderChaining)
502+
} else {
503+
commandLine.appendFlag(.noAutoBridgingHeaderChaining)
504+
}
505+
}
506+
498507
// Pass along -no-verify-emitted-module-interface only if it's effective.
499508
// Assume verification by default as we want to know only when the user skips
500509
// the verification.

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
464464
guard driver.isFrontendArgSupported(.autoBridgingHeaderChaining) else { return }
465465

466466
// Warn if -disable-bridging-pch is used with auto bridging header chaining.
467-
driver = try Driver(args: ["swiftc", "-v",
467+
driver = try Driver(args: ["swiftc",
468468
"-I", FooInstallPath.nativePathString(escaped: true),
469469
"-explicit-module-build", "-auto-bridging-header-chaining", "-disable-bridging-pch",
470470
"-pch-output-dir", FooInstallPath.nativePathString(escaped: true),

0 commit comments

Comments
 (0)