Skip to content

Commit 8167cc6

Browse files
[swift] Always emit pch output path in OutputFileMap (swiftlang#261)
Always emit pch output path in OutputfileMap to support possible chained bridging header support. In the chained bridging header support mode, swift-driver can plan a generate PCH job even when there are no explicit bridging header is passed on command-line, and it needs the path in output file map to write the PCH file into desired location. Since having additional unused entries in the output file map is not an issue, just always generate output path for PCH in the output file map. rdar://146409233
1 parent bdf7d91 commit 8167cc6

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,10 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
30763076
let emitModuleDependenciesFilePath = objectFileDir.join(masterSwiftBaseName + "-emit-module.d")
30773077
fileMapEntry.emitModuleDependencies = emitModuleDependenciesFilePath.str
30783078

3079+
// The PCH file path for generatePCH job.
3080+
let bridgingHeaderPCHPath = objectFileDir.join(masterSwiftBaseName + "-Bridging-header.pch")
3081+
fileMapEntry.pch = bridgingHeaderPCHPath.str
3082+
30793083
// Add the global entry to the map.
30803084
mapDict[""] = fileMapEntry
30813085
}
@@ -3115,11 +3119,9 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
31153119
fileMapEntry.constValues = objectFileDir.join(masterSwiftBaseName + ".swiftconstvalues").str
31163120
}
31173121

3118-
let objcBridgingHeaderPath = Path(cbc.scope.evaluate(BuiltinMacros.SWIFT_OBJC_BRIDGING_HEADER))
3119-
if !objcBridgingHeaderPath.isEmpty,
3120-
await swiftExplicitModuleBuildEnabled(cbc.producer, cbc.scope, delegate) {
3121-
fileMapEntry.pch = objectFileDir.join(masterSwiftBaseName + "-Bridging-header.pch").str
3122-
}
3122+
// The PCH file path for generatePCH job.
3123+
let bridgingHeaderPCHPath = objectFileDir.join(masterSwiftBaseName + "-Bridging-header.pch")
3124+
fileMapEntry.pch = bridgingHeaderPCHPath.str
31233125

31243126
// Add the global entry to the map.
31253127
mapDict[""] = fileMapEntry

Tests/SWBTaskConstructionTests/SwiftModuleOnlyTaskConstructionTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ fileprivate struct SwiftModuleOnlyTaskConstructionTests: CoreBasedTests {
687687
"diagnostics": .plString(archBuildDir.join("\(tpc.targetName)\(platformSuffix)-master.dia").str),
688688
"emit-module-diagnostics": .plString(archBuildDir.join("\(tpc.targetName)\(platformSuffix)-master-emit-module.dia").str),
689689
"emit-module-dependencies": .plString(archBuildDir.join("\(tpc.targetName)\(platformSuffix)-master-emit-module.d").str),
690+
"pch": .plString(archBuildDir.join("\(tpc.targetName)\(platformSuffix)-master-Bridging-header.pch").str),
690691
]))
691692
}
692693

Tests/SWBTaskConstructionTests/SwiftTaskConstructionTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
301301
"diagnostics": .plString("\(SRCROOT)/build/aProject.build/Debug/AppTarget.build/Objects-normal/x86_64/AppTarget-master.dia"),
302302
"emit-module-diagnostics": .plString("\(SRCROOT)/build/aProject.build/Debug/AppTarget.build/Objects-normal/x86_64/AppTarget-master-emit-module.dia"),
303303
"emit-module-dependencies": .plString("\(SRCROOT)/build/aProject.build/Debug/AppTarget.build/Objects-normal/x86_64/AppTarget-master-emit-module.d"),
304+
"pch": .plString("\(SRCROOT)/build/aProject.build/Debug/AppTarget.build/Objects-normal/x86_64/AppTarget-master-Bridging-header.pch"),
304305
]))
305306
}
306307
else {

0 commit comments

Comments
 (0)