@@ -314,7 +314,7 @@ extension IncrementalCompilationState {
314314 alwaysRebuildDependents: Bool ,
315315 reportIncrementalDecision: ( ( String , TypedVirtualPath ? ) -> Void ) ?
316316 ) -> Set < TypedVirtualPath > {
317- let changedInputs : [ ( TypedVirtualPath , InputInfo . Status ) ] =
317+ let changedInputs : [ ( TypedVirtualPath , InputInfo . Status , datesMatch : Bool ) ] =
318318 computeChangedInputs (
319319 groups: allGroups,
320320 buildRecordInfo: buildRecordInfo,
@@ -353,6 +353,7 @@ extension IncrementalCompilationState {
353353 let speculativeInputs = computeSpeculativeInputs (
354354 changedInputs: changedInputs,
355355 externalDependents: externalDependents,
356+ inputsMissingOutputs: Set ( inputsMissingOutputs) ,
356357 moduleDependencyGraph: moduleDependencyGraph,
357358 alwaysRebuildDependents: alwaysRebuildDependents,
358359 reportIncrementalDecision: reportIncrementalDecision)
@@ -383,7 +384,7 @@ extension IncrementalCompilationState {
383384 outOfDateBuildRecord: BuildRecord ,
384385 fileSystem: FileSystem ,
385386 reportIncrementalDecision: ( ( String , TypedVirtualPath ? ) -> Void ) ?
386- ) -> [ ( TypedVirtualPath , InputInfo . Status ) ] {
387+ ) -> [ ( TypedVirtualPath , InputInfo . Status , datesMatch : Bool ) ] {
387388 groups. compactMap { group in
388389 let input = group. primaryInput
389390 let modDate = buildRecordInfo. compilationInputModificationDates [ input]
@@ -414,7 +415,7 @@ extension IncrementalCompilationState {
414415 case . needsNonCascadingBuild:
415416 reportIncrementalDecision ? ( " Scheduling noncascading build " , input)
416417 }
417- return ( input, previousCompilationStatus)
418+ return ( input, previousCompilationStatus, datesMatch )
418419 }
419420 }
420421
@@ -450,35 +451,43 @@ extension IncrementalCompilationState {
450451 /// TODO: something better, e.g. return nothing here, but process changed swiftDeps
451452 /// before the whole frontend job finished.
452453 private static func computeSpeculativeInputs(
453- changedInputs: [ ( TypedVirtualPath , InputInfo . Status ) ] ,
454+ changedInputs: [ ( TypedVirtualPath , InputInfo . Status , datesMatch : Bool ) ] ,
454455 externalDependents: [ TypedVirtualPath ] ,
456+ inputsMissingOutputs: Set < TypedVirtualPath > ,
455457 moduleDependencyGraph: ModuleDependencyGraph ,
456458 alwaysRebuildDependents: Bool ,
457459 reportIncrementalDecision: ( ( String , TypedVirtualPath ? ) -> Void ) ?
458460 ) -> Set < TypedVirtualPath > {
459461 // Collect the files that will be compiled whose dependents should be schedule
460- let cascadingChangedInputs : [ TypedVirtualPath ] = changedInputs. compactMap { input, status in
462+ let cascadingChangedInputs : [ TypedVirtualPath ] = changedInputs. compactMap {
463+ input, status, datesMatch in
461464 let basename = input. file. basename
462- switch ( status, alwaysRebuildDependents) {
465+ switch ( status, alwaysRebuildDependents,
466+ datesMatch && !inputsMissingOutputs. contains ( input) ) {
463467
464- case ( _, true ) :
468+ case ( _, true , false ) :
465469 reportIncrementalDecision ? (
466470 " scheduling dependents of \( basename) ; -driver-always-rebuild-dependents " , nil )
467471 return input
468- case ( . needsCascadingBuild, false ) :
472+ case ( _, true , true ) :
473+ reportIncrementalDecision ? (
474+ " not scheduling dependents of \( basename) despite -driver-always-rebuild-dependents because is up to date " , nil )
475+ return nil
476+
477+ case ( . needsCascadingBuild, false , _) :
469478 reportIncrementalDecision ? (
470479 " scheduling dependents of \( basename) ; needed cascading build " , nil )
471480 return input
472481
473- case ( . upToDate, false ) : // was up to date, but changed
482+ case ( . upToDate, false , _ ) : // was up to date, but changed
474483 reportIncrementalDecision ? (
475484 " not scheduling dependents of \( basename) ; unknown changes " , nil )
476485 return nil
477- case ( . newlyAdded, false ) :
486+ case ( . newlyAdded, false , _ ) :
478487 reportIncrementalDecision ? (
479488 " not scheduling dependents of \( basename) : no entry in build record or dependency graph " , nil )
480489 return nil
481- case ( . needsNonCascadingBuild, false ) :
490+ case ( . needsNonCascadingBuild, false , _ ) :
482491 reportIncrementalDecision ? (
483492 " not scheduling dependents of \( basename) : does not need cascading build " , nil )
484493 return nil
0 commit comments