Skip to content

[Incremental] Don't read swiftdeps of a new input or of a crashed compile. #409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/SwiftDriver/Incremental Compilation/BuildRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public struct BuildRecord {

var serializedName: String { rawValue }
}

var allInputs: Set<VirtualPath> {
Set( inputInfos.map {$0.key} )
}
}

// MARK: - Reading the old map and deciding whether to use it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class IncrementalCompilationState {
ModuleDependencyGraph.buildInitialGraph(
diagnosticEngine: diagnosticEngine,
inputs: buildRecordInfo.compilationInputModificationDates.keys,
previousInputs: outOfDateBuildRecord.allInputs,
outputFileMap: outputFileMap,
parsedOptions: &parsedOptions,
remarkDisabled: Diagnostic.Message.remark_incremental_compilation_disabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ extension ModuleDependencyGraph {
static func buildInitialGraph<Inputs: Sequence>(
diagnosticEngine: DiagnosticsEngine,
inputs: Inputs,
previousInputs: Set<VirtualPath>,
outputFileMap: OutputFileMap?,
parsedOptions: inout ParsedOptions,
remarkDisabled: (String) -> Diagnostic.Message,
Expand All @@ -81,22 +82,27 @@ extension ModuleDependencyGraph {
)
return nil
}
let inputsWithUnreadableSwiftDeps = inputsAndSwiftdeps.compactMap {
let previousInputsWithMalformedSwiftDeps = inputsAndSwiftdeps.compactMap {
input, swiftDepsFile -> (TypedVirtualPath, VirtualPath)? in
guard let swiftDepsFile = swiftDepsFile
else {
return nil
}
let swiftDeps = SwiftDeps(swiftDepsFile)
graph.sourceSwiftDepsMap[input] = swiftDeps
guard previousInputs.contains(input.file)
else {
// do not try to read swiftdeps of a new input
return nil
}
let changes = Integrator.integrate(swiftDeps: swiftDeps,
into: graph,
input: input,
reportIncrementalDecision: reportIncrementalDecision,
diagnosticEngine: diagnosticEngine)
return changes == nil ? (input, swiftDepsFile) : nil
}
return (graph, inputsWithUnreadableSwiftDeps)
return (graph, previousInputsWithMalformedSwiftDeps)
}
}
// MARK: - Scheduling the first wave
Expand Down
4 changes: 3 additions & 1 deletion Sources/SwiftDriverExecution/MultiJobExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,9 @@ class ExecuteJobRule: LLBuildRule {
#endif
}
}
context.addRuleBeyondMandatoryCompiles(finishedJob: job, result: result)
if case .terminated = result.exitStatus {
context.addRuleBeyondMandatoryCompiles(finishedJob: job, result: result)
}

// Inform the delegate about job finishing.
context.delegateQueue.async {
Expand Down