diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/cpp/CompileToExecutable.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/cpp/CompileToExecutable.kt index 51c7cebdda3..9dd79a50276 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/cpp/CompileToExecutable.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/cpp/CompileToExecutable.kt @@ -139,7 +139,8 @@ private abstract class CompileToExecutableJob : WorkAction() + @get:Input + val platformManager = project.extensions.getByType() /** * Target for which to compile. @@ -212,23 +213,22 @@ abstract class CompileToExecutable : DefaultTask() { @get:Input abstract val linkerArgs: ListProperty - @get:Input - protected val linkCommands: Provider>> = project.provider { - // Getting link commands requires presence of a target toolchain. - // Thus we cannot get them at the configuration stage because the toolchain may be not downloaded yet. - platformManager.platform(target.get()).linker.finalLinkCommands( - listOf(compilerOutputFile.asFile.get().absolutePath), - outputFile.asFile.get().absolutePath, - listOf(), - linkerArgs.get(), - optimize = false, - debug = true, - kind = LinkerOutputKind.EXECUTABLE, - outputDsymBundle = outputFile.asFile.get().absolutePath + ".dSYM", - mimallocEnabled = mimallocEnabled.get(), - sanitizer = sanitizer.orNull - ).map { it.argsWithExecutable } - } + @Internal + fun linkCommands(): List> = + // Getting link commands requires presence of a target toolchain. + // Thus we cannot get them at the configuration stage because the toolchain may be not downloaded yet. + platformManager.platform(target.get()).linker.finalLinkCommands( + listOf(compilerOutputFile.asFile.get().absolutePath), + outputFile.asFile.get().absolutePath, + listOf(), + linkerArgs.get(), + optimize = false, + debug = true, + kind = LinkerOutputKind.EXECUTABLE, + outputDsymBundle = outputFile.asFile.get().absolutePath + ".dSYM", + mimallocEnabled = mimallocEnabled.get(), + sanitizer = sanitizer.orNull + ).map { it.argsWithExecutable } @get:Inject protected abstract val workerExecutor: WorkerExecutor @@ -253,7 +253,7 @@ abstract class CompileToExecutable : DefaultTask() { outputFile.set(this@CompileToExecutable.outputFile) targetName.set(this@CompileToExecutable.target.get().name) clangFlags.addAll(defaultClangFlags + compilerArgs.get() + sanitizerFlags) - linkCommands.set(this@CompileToExecutable.linkCommands) + linkCommands.set(this@CompileToExecutable.linkCommands()) platformManager.set(this@CompileToExecutable.platformManager) } }