Skip to content

Commit d793878

Browse files
committed
Schedule merge-modules When modulewrap Job is in the Queue
In order to unblock the SwiftWASM project, which relies on an incremental build of the Swift driver that relies on the merge-modules job always being run. The situation appears to be something like this: 1) An incremental build is run 2) Temporary swiftmodule outputs are laid down 3) merge-modules is skipped 4) modulewrap is run anyways and reads the empty temp file We should fix this by skipping modulewrap if we can skip merge-modules. But for now, be conservative and fall back to the status quo behavior of always running merge-modules whenever we encounter a modulewrap job.
1 parent c9115dc commit d793878

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/Driver/Compilation.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)