Native: delete konan_temp right after the compilation instead of on exit
The Kotlin/Native compiler uses `.deleteOnExit()` as a substitute for "delete after the compilation". But when the compiler runs in a Gradle daemon, `.deleteOnExit()` means "delete on Gradle daemon exit", which might be not soon. If a single Gradle daemon runs the compiler many times, the remaining temporary files can consume quite a lot of disk space. For example, this is the case for the Kotlin build. Replace some of `.deleteOnExit()` calls with an explicit removal of temporary files at the end of a compilation session.
This commit is contained in:
committed by
Space
parent
ea8a05ec02
commit
4cf10686d6
@@ -85,8 +85,12 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
|
||||
try {
|
||||
val konanConfig = KonanConfig(project, configuration)
|
||||
ensureModuleName(konanConfig, environment)
|
||||
runTopLevelPhases(konanConfig, environment)
|
||||
try {
|
||||
ensureModuleName(konanConfig, environment)
|
||||
runTopLevelPhases(konanConfig, environment)
|
||||
} finally {
|
||||
konanConfig.dispose()
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
if (e is KonanCompilationException || e is CompilationErrorException)
|
||||
return ExitCode.COMPILATION_ERROR
|
||||
|
||||
Reference in New Issue
Block a user