@@ -446,7 +446,7 @@ namespace driver {
446
446
447
447
std::vector<const Job*>
448
448
reloadAndRemarkDeps (const Job *FinishedCmd, int ReturnCode,
449
- const bool forRanges) {
449
+ const bool forRanges) {
450
450
const CommandOutput &Output = FinishedCmd->getOutput ();
451
451
StringRef DependenciesFile =
452
452
Output.getAdditionalOutputForType (file_types::TY_SwiftDeps);
@@ -458,7 +458,8 @@ namespace driver {
458
458
// coarse dependencies that always affect downstream nodes), but we're
459
459
// not using either of those right now, and this logic should probably
460
460
// be revisited when we are.
461
- assert (FinishedCmd->getCondition () == Job::Condition::Always);
461
+ assert (isa<MergeModuleJobAction>(FinishedCmd->getSource ()) ||
462
+ FinishedCmd->getCondition () == Job::Condition::Always);
462
463
return {};
463
464
}
464
465
const bool compileExitedNormally =
@@ -907,6 +908,7 @@ namespace driver {
907
908
return everyIncrementalJob;
908
909
};
909
910
911
+ const Job *mergeModulesJob = nullptr ;
910
912
CommandSet jobsToSchedule;
911
913
CommandSet initialCascadingCommands;
912
914
for (const Job *cmd : Comp.getJobs ()) {
@@ -915,6 +917,11 @@ namespace driver {
915
917
continue ;
916
918
}
917
919
920
+ if (isa<MergeModuleJobAction>(cmd->getSource ())) {
921
+ assert (!mergeModulesJob && " multiple scheduled merge-modules jobs?" );
922
+ mergeModulesJob = cmd;
923
+ }
924
+
918
925
const Optional<std::pair<bool , bool >> shouldSchedAndIsCascading =
919
926
computeShouldInitiallyScheduleJobAndDependendents (cmd, forRanges);
920
927
if (!shouldSchedAndIsCascading)
@@ -936,6 +943,15 @@ namespace driver {
936
943
collectIncrementalExternallyDependentJobsFromDependencyGraph (
937
944
forRanges))
938
945
jobsToSchedule.insert (cmd);
946
+
947
+ // The merge-modules job is special: it *must* be scheduled if any other
948
+ // job has been scheduled because any other job can influence the
949
+ // structure of the resulting module. Additionally, the initial scheduling
950
+ // predicate above is only aware of intra-module changes. External
951
+ // dependencies changing *must* cause merge-modules to be scheduled.
952
+ if (!jobsToSchedule.empty () && mergeModulesJob) {
953
+ jobsToSchedule.insert (mergeModulesJob);
954
+ }
939
955
return jobsToSchedule;
940
956
}
941
957
@@ -1031,6 +1047,13 @@ namespace driver {
1031
1047
// / But returns None if there was a dependency read error.
1032
1048
Optional<std::pair<Job::Condition, bool >>
1033
1049
loadDependenciesAndComputeCondition (const Job *const Cmd, bool forRanges) {
1050
+ // merge-modules Jobs do not have .swiftdeps files associated with them,
1051
+ // however, their compilation condition is computed as a function of their
1052
+ // inputs, so their condition can be used as normal.
1053
+ if (isa<MergeModuleJobAction>(Cmd->getSource ())) {
1054
+ return std::make_pair (Cmd->getCondition (), true );
1055
+ }
1056
+
1034
1057
// Try to load the dependencies file for this job. If there isn't one, we
1035
1058
// always have to run the job, but it doesn't affect any other jobs. If
1036
1059
// there should be one but it's not present or can't be loaded, we have to
@@ -1163,7 +1186,12 @@ namespace driver {
1163
1186
continue ;
1164
1187
}
1165
1188
1166
- // Can we run a cross-module incremental build at all? If not, fallback.
1189
+ // Is this module out of date? If not, just keep searching.
1190
+ if (Comp.getLastBuildTime () >= depStatus.getLastModificationTime ())
1191
+ continue ;
1192
+
1193
+ // Can we run a cross-module incremental build at all?
1194
+ // If not, fall back.
1167
1195
if (!Comp.getEnableCrossModuleIncrementalBuild ()) {
1168
1196
fallbackToExternalBehavior (external);
1169
1197
continue ;
@@ -1609,8 +1637,8 @@ namespace driver {
1609
1637
CompileJobAction::InputInfo info;
1610
1638
info.previousModTime = entry.first ->getInputModTime ();
1611
1639
info.status = entry.second ?
1612
- CompileJobAction::InputInfo::NeedsCascadingBuild :
1613
- CompileJobAction::InputInfo::NeedsNonCascadingBuild;
1640
+ CompileJobAction::InputInfo::Status:: NeedsCascadingBuild :
1641
+ CompileJobAction::InputInfo::Status:: NeedsNonCascadingBuild;
1614
1642
inputs[&inputFile->getInputArg ()] = info;
1615
1643
}
1616
1644
}
@@ -1627,7 +1655,7 @@ namespace driver {
1627
1655
1628
1656
CompileJobAction::InputInfo info;
1629
1657
info.previousModTime = entry->getInputModTime ();
1630
- info.status = CompileJobAction::InputInfo::UpToDate;
1658
+ info.status = CompileJobAction::InputInfo::Status:: UpToDate;
1631
1659
inputs[&inputFile->getInputArg ()] = info;
1632
1660
}
1633
1661
}
0 commit comments