@@ -908,10 +908,18 @@ namespace driver {
908908 return everyIncrementalJob;
909909 };
910910
911+ bool sawModuleWrapJob = false ;
911912 const Job *mergeModulesJob = nullptr ;
912913 CommandSet jobsToSchedule;
913914 CommandSet initialCascadingCommands;
914915 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+
915923 // Skip jobs that have no associated incremental info.
916924 if (!isa<IncrementalJobAction>(cmd->getSource ())) {
917925 continue ;
@@ -949,7 +957,7 @@ namespace driver {
949957 // structure of the resulting module. Additionally, the initial scheduling
950958 // predicate above is only aware of intra-module changes. External
951959 // dependencies changing *must* cause merge-modules to be scheduled.
952- if (!jobsToSchedule.empty () && mergeModulesJob) {
960+ if (( !jobsToSchedule.empty () || sawModuleWrapJob ) && mergeModulesJob) {
953961 jobsToSchedule.insert (mergeModulesJob);
954962 }
955963 return jobsToSchedule;
0 commit comments