@@ -617,7 +617,7 @@ constructDetailedTaskDescription(const CompilerInvocation &Invocation,
617
617
Outputs};
618
618
}
619
619
620
- static void emitReferenceDependenciesForAllPrimaryInputsIfNeeded (
620
+ static void emitSwiftdepsForAllPrimaryInputsIfNeeded (
621
621
CompilerInstance &Instance) {
622
622
const auto &Invocation = Instance.getInvocation ();
623
623
if (Invocation.getFrontendOptions ()
@@ -627,6 +627,22 @@ static void emitReferenceDependenciesForAllPrimaryInputsIfNeeded(
627
627
SourceLoc (), diag::emit_reference_dependencies_without_primary_file);
628
628
return ;
629
629
}
630
+
631
+ // Do not write out swiftdeps for any primaries if we've encountered an
632
+ // error. Without this, the driver will attempt to integrate swiftdeps
633
+ // from broken swift files. One way this could go wrong is if a primary that
634
+ // fails to build in an early wave has dependents in a later wave. The
635
+ // driver will not schedule those later dependents after this batch exits,
636
+ // so they will have no opportunity to bring their swiftdeps files up to
637
+ // date. With this early exit, the driver sees the same priors in the
638
+ // swiftdeps files from before errors were introduced into the batch, and
639
+ // integration therefore always hops from "known good" to "known good" states.
640
+ //
641
+ // FIXME: It seems more appropriate for the driver to notice the early-exit
642
+ // and react by always enqueuing the jobs it dropped in the other waves.
643
+ if (Instance.getDiags ().hadAnyError ())
644
+ return ;
645
+
630
646
for (auto *SF : Instance.getPrimarySourceFiles ()) {
631
647
const std::string &referenceDependenciesFilePath =
632
648
Invocation.getReferenceDependenciesFilePathForPrimary (
@@ -1035,8 +1051,10 @@ static void performEndOfPipelineActions(CompilerInstance &Instance) {
1035
1051
emitIndexData (Instance);
1036
1052
}
1037
1053
1038
- // Emit dependencies.
1039
- emitReferenceDependenciesForAllPrimaryInputsIfNeeded (Instance);
1054
+ // Emit Swiftdeps for every file in the batch.
1055
+ emitSwiftdepsForAllPrimaryInputsIfNeeded (Instance);
1056
+
1057
+ // Emit Make-style dependencies.
1040
1058
emitMakeDependenciesIfNeeded (Instance.getDiags (),
1041
1059
Instance.getDependencyTracker (), opts);
1042
1060
0 commit comments