@@ -206,7 +206,7 @@ extension IncrementalCompilationState.IncrementalDependencyAndInputSetup {
206
206
return readPriorGraphAndCollectInputsInvalidatedByChangedOrAddedExternals ( )
207
207
}
208
208
// Every external is added, but don't want to compile an unchanged input that has an import
209
- // so just changed, not changedOrAdded
209
+ // so just changed, not changedOrAdded.
210
210
return buildInitialGraphFromSwiftDepsAndCollectInputsInvalidatedByChangedExternals ( )
211
211
}
212
212
@@ -230,7 +230,13 @@ extension IncrementalCompilationState.IncrementalDependencyAndInputSetup {
230
230
}
231
231
guard let graph = graphIfPresent
232
232
else {
233
- return buildInitialGraphFromSwiftDepsAndCollectInputsInvalidatedByChangedExternals ( )
233
+ // Do not fall back to `buildInitialGraphFromSwiftDepsAndCollectInputsInvalidatedByChangedExternals`
234
+ // because it would be unsound to read a `swiftmodule` file with only a partial set of integrated `swiftdeps`.
235
+ // A fingerprint change in such a `swiftmodule` would not be able to propagate and invalidate a use
236
+ // in a as-yet-unread swiftdeps file.
237
+ //
238
+ // Instead, just compile everything. It's OK to be unsound then because every file will be compiled anyway.
239
+ return bulidEmptyGraphAndCompileEverything ( )
234
240
}
235
241
graph. dotFileWriter? . write ( graph)
236
242
@@ -257,10 +263,7 @@ extension IncrementalCompilationState.IncrementalDependencyAndInputSetup {
257
263
private func buildInitialGraphFromSwiftDepsAndCollectInputsInvalidatedByChangedExternals( )
258
264
-> ( ModuleDependencyGraph , TransitivelyInvalidatedInputSet ) ?
259
265
{
260
- guard let graph = ModuleDependencyGraph ( self , . buildingWithoutAPrior)
261
- else {
262
- return nil
263
- }
266
+ let graph = ModuleDependencyGraph ( self , . buildingFromSwiftDeps)
264
267
var inputsInvalidatedByChangedExternals = TransitivelyInvalidatedInputSet ( )
265
268
for input in sourceFiles. currentInOrder {
266
269
guard let invalidatedInputs =
@@ -273,4 +276,10 @@ extension IncrementalCompilationState.IncrementalDependencyAndInputSetup {
273
276
reporter? . report ( " Created dependency graph from swiftdeps files " )
274
277
return ( graph, inputsInvalidatedByChangedExternals)
275
278
}
279
+
280
+ private func bulidEmptyGraphAndCompileEverything( )
281
+ -> ( ModuleDependencyGraph , TransitivelyInvalidatedInputSet ) {
282
+ let graph = ModuleDependencyGraph ( self , . buildingAfterEachCompilation)
283
+ return ( graph, TransitivelyInvalidatedInputSet ( ) )
284
+ }
276
285
}
0 commit comments