@@ -908,10 +908,18 @@ namespace driver {
908
908
return everyIncrementalJob;
909
909
};
910
910
911
+ bool sawModuleWrapJob = false ;
911
912
const Job *mergeModulesJob = nullptr ;
912
913
CommandSet jobsToSchedule;
913
914
CommandSet initialCascadingCommands;
914
915
for (const Job *cmd : Comp.getJobs ()) {
916
+ // A modulewrap job consumes the output of merge-modules. If it is
917
+ // in the queue, we must run merge-modules or empty temporary files
918
+ // will be consumed by the job instead.
919
+ // FIXME: We should be able to ditch this if we compare the timestamps
920
+ // of the temporary file to the build record, if it exists.
921
+ sawModuleWrapJob |= isa<ModuleWrapJobAction>(cmd->getSource ());
922
+
915
923
// Skip jobs that have no associated incremental info.
916
924
if (!isa<IncrementalJobAction>(cmd->getSource ())) {
917
925
continue ;
@@ -949,7 +957,7 @@ namespace driver {
949
957
// structure of the resulting module. Additionally, the initial scheduling
950
958
// predicate above is only aware of intra-module changes. External
951
959
// dependencies changing *must* cause merge-modules to be scheduled.
952
- if (!jobsToSchedule.empty () && mergeModulesJob) {
960
+ if (( !jobsToSchedule.empty () || sawModuleWrapJob ) && mergeModulesJob) {
953
961
jobsToSchedule.insert (mergeModulesJob);
954
962
}
955
963
return jobsToSchedule;
0 commit comments