Skip to content

Commit 528e7ba

Browse files
author
David Ungar
authored
Merge pull request #409 from davidungar/dont-read-swiftdeps
[Incremental] Don't read swiftdeps of a new input or of a crashed compile.
2 parents 76b74cc + 0b3b5d6 commit 528e7ba

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

Sources/SwiftDriver/Incremental Compilation/BuildRecord.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public struct BuildRecord {
6969

7070
var serializedName: String { rawValue }
7171
}
72+
73+
var allInputs: Set<VirtualPath> {
74+
Set( inputInfos.map {$0.key} )
75+
}
7276
}
7377

7478
// MARK: - Reading the old map and deciding whether to use it

Sources/SwiftDriver/Incremental Compilation/IncrementalCompilationState.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public class IncrementalCompilationState {
9595
ModuleDependencyGraph.buildInitialGraph(
9696
diagnosticEngine: diagnosticEngine,
9797
inputs: buildRecordInfo.compilationInputModificationDates.keys,
98+
previousInputs: outOfDateBuildRecord.allInputs,
9899
outputFileMap: outputFileMap,
99100
parsedOptions: &parsedOptions,
100101
remarkDisabled: Diagnostic.Message.remark_incremental_compilation_disabled,

Sources/SwiftDriver/Incremental Compilation/ModuleDependencyGraph.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ extension ModuleDependencyGraph {
5555
static func buildInitialGraph<Inputs: Sequence>(
5656
diagnosticEngine: DiagnosticsEngine,
5757
inputs: Inputs,
58+
previousInputs: Set<VirtualPath>,
5859
outputFileMap: OutputFileMap?,
5960
parsedOptions: inout ParsedOptions,
6061
remarkDisabled: (String) -> Diagnostic.Message,
@@ -81,22 +82,27 @@ extension ModuleDependencyGraph {
8182
)
8283
return nil
8384
}
84-
let inputsWithUnreadableSwiftDeps = inputsAndSwiftdeps.compactMap {
85+
let previousInputsWithMalformedSwiftDeps = inputsAndSwiftdeps.compactMap {
8586
input, swiftDepsFile -> (TypedVirtualPath, VirtualPath)? in
8687
guard let swiftDepsFile = swiftDepsFile
8788
else {
8889
return nil
8990
}
9091
let swiftDeps = SwiftDeps(swiftDepsFile)
9192
graph.sourceSwiftDepsMap[input] = swiftDeps
93+
guard previousInputs.contains(input.file)
94+
else {
95+
// do not try to read swiftdeps of a new input
96+
return nil
97+
}
9298
let changes = Integrator.integrate(swiftDeps: swiftDeps,
9399
into: graph,
94100
input: input,
95101
reportIncrementalDecision: reportIncrementalDecision,
96102
diagnosticEngine: diagnosticEngine)
97103
return changes == nil ? (input, swiftDepsFile) : nil
98104
}
99-
return (graph, inputsWithUnreadableSwiftDeps)
105+
return (graph, previousInputsWithMalformedSwiftDeps)
100106
}
101107
}
102108
// MARK: - Scheduling the first wave

Sources/SwiftDriverExecution/MultiJobExecutor.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,9 @@ class ExecuteJobRule: LLBuildRule {
533533
#endif
534534
}
535535
}
536-
context.addRuleBeyondMandatoryCompiles(finishedJob: job, result: result)
536+
if case .terminated = result.exitStatus {
537+
context.addRuleBeyondMandatoryCompiles(finishedJob: job, result: result)
538+
}
537539

538540
// Inform the delegate about job finishing.
539541
context.delegateQueue.async {

0 commit comments

Comments
 (0)