From e92f7b5ec349e44251fb1df9235529e1228dca2e Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Fri, 11 Feb 2022 16:10:24 +0300 Subject: [PATCH] Native: don't cache Xcode.current between different compiler invocations The compiler might be executed in a Gradle daemon process, so current Xcode might actually change between different invocations. ^KT-49496 Fixed --- .../kotlin/org/jetbrains/kotlin/konan/target/Xcode.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Xcode.kt b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Xcode.kt index cacd3dcc3d8..320ba1909d9 100644 --- a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Xcode.kt +++ b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Xcode.kt @@ -54,13 +54,14 @@ interface Xcode { } companion object { - val current: Xcode by lazy { - CurrentXcode - } + // Don't cache the instance: the compiler might be executed in a Gradle daemon process, + // so current Xcode might actually change between different invocations. + val current: Xcode + get() = CurrentXcode() } } -private object CurrentXcode : Xcode { +private class CurrentXcode : Xcode { override val toolchain by lazy { val ldPath = xcrun("-f", "ld") // = $toolchain/usr/bin/ld