@@ -1571,20 +1571,46 @@ namespace driver {
1571
1571
if (!ScheduledCommands.count (Cmd))
1572
1572
continue ;
1573
1573
1574
- // Be conservative, in case we use ranges this time but not next.
1575
- bool mightBeCascading = true ;
1576
- if (Comp.getIncrementalBuildEnabled ()) {
1577
- const bool forRanges = Comp.getEnableSourceRangeDependencies ();
1578
- mightBeCascading = Comp.getEnableFineGrainedDependencies ()
1579
- ? getFineGrainedDepGraph (forRanges)
1580
- .haveAnyNodesBeenTraversedIn (Cmd)
1581
- : getDepGraph (forRanges).isMarked (Cmd);
1582
- }
1583
- UnfinishedCommands.insert ({Cmd, mightBeCascading});
1574
+ const bool needsCascadingBuild =
1575
+ computeNeedsCascadingBuildForUnfinishedCommand (Cmd);
1576
+ UnfinishedCommands.insert ({Cmd, needsCascadingBuild});
1584
1577
}
1585
1578
}
1586
1579
}
1587
1580
1581
+ // / When the driver next runs, it will read the build record, and the
1582
+ // / unfinished job status will be set to either \c NeedsCascading... or
1583
+ // / \c NeedsNonCascading...
1584
+ // / Decide which it will be.
1585
+ // / As far as I can tell, the only difference the result of this function
1586
+ // / makes is how soon
1587
+ // / required dependents are recompiled. Here's my reasoning:
1588
+ // /
1589
+ // / When the driver next runs, the condition will be filtered through
1590
+ // / \c loadDependenciesAndComputeCondition .
1591
+ // / Then, the cascading predicate is returned from
1592
+ // / \c isCompileJobInitiallyNeededForDependencyBasedIncrementalCompilation
1593
+ // / and \c computeShouldInitiallyScheduleJobAndDependendents Then, in \c
1594
+ // / computeDependenciesAndGetNeededCompileJobs if the job needs a cascading
1595
+ // / build, it's dependents will be scheduled immediately.
1596
+ // / After the job finishes, it's dependencies will be processed again.
1597
+ // / If a non-cascading job failed, the driver will schedule all of its
1598
+ // / dependents. (All of its dependents are assumed to have already been
1599
+ // / scheduled.) If the job succeeds, the revised dependencies are consulted
1600
+ // / to schedule any needed jobs.
1601
+
1602
+ bool computeNeedsCascadingBuildForUnfinishedCommand (const Job *Cmd) {
1603
+ if (!Comp.getIncrementalBuildEnabled ())
1604
+ return true ;
1605
+ const bool forRanges = Comp.getEnableSourceRangeDependencies ();
1606
+ if (!Comp.getEnableFineGrainedDependencies ()) {
1607
+ // Mysterious legacy code
1608
+ return getDepGraph (forRanges).isMarked (Cmd);
1609
+ }
1610
+ // See the comment on the whole function above
1611
+ return false ;
1612
+ }
1613
+
1588
1614
public:
1589
1615
void populateInputInfoMap (InputInfoMap &inputs) const {
1590
1616
for (auto &entry : UnfinishedCommands) {
0 commit comments