@@ -336,7 +336,13 @@ public struct Driver {
336
336
let importedObjCHeader : VirtualPath . Handle ?
337
337
338
338
/// The path to the pch for the imported Objective-C header.
339
- let bridgingPrecompiledHeader : VirtualPath . Handle ?
339
+ lazy var bridgingPrecompiledHeader : VirtualPath . Handle ? = {
340
+ Self . computeBridgingPrecompiledHeader ( & parsedOptions,
341
+ compilerMode: compilerMode,
342
+ importedObjCHeader: importedObjCHeader,
343
+ outputFileMap: outputFileMap,
344
+ planner: explicitDependencyBuildPlanner)
345
+ } ( )
340
346
341
347
/// Path to the dependencies file.
342
348
let dependenciesFilePath : VirtualPath . Handle ?
@@ -801,10 +807,6 @@ public struct Driver {
801
807
recordedInputModificationDates: recordedInputModificationDates)
802
808
803
809
self . importedObjCHeader = try Self . computeImportedObjCHeader ( & parsedOptions, compilerMode: compilerMode, diagnosticEngine: diagnosticEngine)
804
- self . bridgingPrecompiledHeader = try Self . computeBridgingPrecompiledHeader ( & parsedOptions,
805
- compilerMode: compilerMode,
806
- importedObjCHeader: importedObjCHeader,
807
- outputFileMap: outputFileMap)
808
810
809
811
self . supportedFrontendFlags =
810
812
try Self . computeSupportedCompilerArgs ( of: self . toolchain,
@@ -829,7 +831,7 @@ public struct Driver {
829
831
diagnosticsEngine. emit ( . warning( " -cache-compile-job cannot be used without explicit module build, turn off caching " ) ,
830
832
location: nil )
831
833
self . enableCaching = false
832
- } else if importedObjCHeader != nil && bridgingPrecompiledHeader == nil {
834
+ } else if importedObjCHeader != nil , !parsedOptions . hasFlag ( positive : . enableBridgingPch , negative : . disableBridgingPch , default : true ) {
833
835
diagnosticsEngine. emit ( . warning( " -cache-compile-job cannot be used with -disable-bridging-pch, turn off caching " ) ,
834
836
location: nil )
835
837
self . enableCaching = false
@@ -1779,7 +1781,7 @@ extension Driver {
1779
1781
/// The swift-driver doesn't have actions, so the logic here takes the jobs and tries
1780
1782
/// to mimic the actions that would be created by the C++ driver and
1781
1783
/// prints them in *hopefully* the same order.
1782
- private func printActions( _ jobs: [ Job ] ) {
1784
+ private mutating func printActions( _ jobs: [ Job ] ) {
1783
1785
defer {
1784
1786
stdoutStream. flush ( )
1785
1787
}
@@ -2872,23 +2874,29 @@ extension Driver {
2872
2874
static func computeBridgingPrecompiledHeader( _ parsedOptions: inout ParsedOptions ,
2873
2875
compilerMode: CompilerMode ,
2874
2876
importedObjCHeader: VirtualPath . Handle ? ,
2875
- outputFileMap: OutputFileMap ? ) throws -> VirtualPath . Handle ? {
2877
+ outputFileMap: OutputFileMap ? ,
2878
+ planner: ExplicitDependencyBuildPlanner ? ) -> VirtualPath . Handle ? {
2876
2879
guard compilerMode. supportsBridgingPCH,
2877
2880
let input = importedObjCHeader,
2878
2881
parsedOptions. hasFlag ( positive: . enableBridgingPch, negative: . disableBridgingPch, default: true ) else {
2879
2882
return nil
2880
2883
}
2881
2884
2882
- if let outputPath = try outputFileMap? . existingOutput ( inputFile: input, outputType: . pch) {
2885
+ if let outputPath = try ? outputFileMap? . existingOutput ( inputFile: input, outputType: . pch) {
2883
2886
return outputPath
2884
2887
}
2885
2888
2886
- let inputFile = VirtualPath . lookup ( input)
2887
- let pchFileName = inputFile. basenameWithoutExt. appendingFileTypeExtension ( . pch)
2889
+ let pchFile : String
2890
+ var baseName = VirtualPath . lookup ( input) . basenameWithoutExt
2891
+ if let contextHash = try ? planner? . getMainModuleContextHash ( ) {
2892
+ pchFile = baseName + " - " + contextHash + " .pch "
2893
+ } else {
2894
+ pchFile = baseName. appendingFileTypeExtension ( . pch)
2895
+ }
2888
2896
if let outputDirectory = parsedOptions. getLastArgument ( . pchOutputDir) ? . asSingle {
2889
- return try VirtualPath ( path: outputDirectory) . appending ( component: pchFileName ) . intern ( )
2897
+ return try ? VirtualPath ( path: outputDirectory) . appending ( component: pchFile ) . intern ( )
2890
2898
} else {
2891
- return try VirtualPath . createUniqueTemporaryFile ( RelativePath ( validating: pchFileName ) ) . intern ( )
2899
+ return try ? VirtualPath . temporary ( RelativePath ( validating: pchFile ) ) . intern ( )
2892
2900
}
2893
2901
}
2894
2902
}
0 commit comments