@@ -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
0 commit comments