Clear IC caches if they were not properly closed
This commit is contained in:
+10
-5
@@ -98,10 +98,9 @@ abstract class IncrementalCompilerRunner<
|
|||||||
val allKotlinFiles = allSourceFiles.filter { it.isKotlinFile(kotlinSourceFilesExtensions) }
|
val allKotlinFiles = allSourceFiles.filter { it.isKotlinFile(kotlinSourceFilesExtensions) }
|
||||||
return compileIncrementally(args, caches, allKotlinFiles, CompilationMode.Rebuild(reason), messageCollector)
|
return compileIncrementally(args, caches, allKotlinFiles, CompilationMode.Rebuild(reason), messageCollector)
|
||||||
}
|
}
|
||||||
// attempt IC
|
|
||||||
// if OK or failed compilation - return
|
// If compilation has crashed or we failed to close caches we have to clear them
|
||||||
// internal error - clear
|
var cachesMayBeCorrupted = true
|
||||||
// failed to close - clear
|
|
||||||
return try {
|
return try {
|
||||||
val changedFiles = providedChangedFiles ?: caches.inputsCache.sourceSnapshotMap.compareAndUpdate(allSourceFiles)
|
val changedFiles = providedChangedFiles ?: caches.inputsCache.sourceSnapshotMap.compareAndUpdate(allSourceFiles)
|
||||||
val compilationMode = sourcesToCompile(caches, changedFiles, args, messageCollector)
|
val compilationMode = sourcesToCompile(caches, changedFiles, args, messageCollector)
|
||||||
@@ -116,12 +115,18 @@ abstract class IncrementalCompilerRunner<
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!caches.close(flush = true)) throw RuntimeException("Could not flush caches")
|
if (!caches.close(flush = true)) throw RuntimeException("Could not flush caches")
|
||||||
|
// Here we should analyze exit code of compiler. E.g. compiler failure should lead to caches rebuild,
|
||||||
|
// but now JsKlib compiler reports invalid exit code.
|
||||||
|
cachesMayBeCorrupted = false
|
||||||
return exitCode
|
return exitCode
|
||||||
} catch (e: Exception) { // todo: catch only cache corruption
|
} catch (e: Exception) { // todo: catch only cache corruption
|
||||||
// todo: warn?
|
// todo: warn?
|
||||||
reporter.report { "Rebuilding because of possible caches corruption: $e" }
|
reporter.report { "Rebuilding because of possible caches corruption: $e" }
|
||||||
rebuild(BuildAttribute.CACHE_CORRUPTION)
|
rebuild(BuildAttribute.CACHE_CORRUPTION)
|
||||||
|
} finally {
|
||||||
|
if (cachesMayBeCorrupted) {
|
||||||
|
clearLocalStateOnRebuild(args)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user