diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt index f753c99b409..1cc97443109 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt @@ -43,9 +43,6 @@ open class CompileToBitcode @Inject constructor( var srcDirs: FileCollection = project.files(srcRoot.resolve("cpp")) var headersDirs: FileCollection = project.files(srcRoot.resolve("headers")) - @Input - var skipLinkagePhase = false - @Input var language = Language.CPP @@ -92,6 +89,9 @@ open class CompileToBitcode @Inject constructor( } } + private fun outputFileForInputFile(file: File, extension: String) = objDir.resolve("${file.nameWithoutExtension}.${extension}") + private fun bitcodeFileForInputFile(file: File) = outputFileForInputFile(file, "bc") + @get:InputFiles protected val headers: Iterable get() { @@ -142,15 +142,13 @@ open class CompileToBitcode @Inject constructor( it.args = compilerFlags + inputFiles.map { it.absolutePath } } - if (!skipLinkagePhase) { - project.exec { - val llvmDir = project.findProperty("llvmDir") - it.executable = "$llvmDir/bin/llvm-link" - it.args = listOf("-o", outFile.absolutePath) + linkerArgs + - project.fileTree(objDir) { - it.include("**/*.bc") - }.files.map { it.absolutePath } - } + project.exec { + val llvmDir = project.findProperty("llvmDir") + it.executable = "$llvmDir/bin/llvm-link" + it.args = listOf("-o", outFile.absolutePath) + linkerArgs + + inputFiles.map { + bitcodeFileForInputFile(it).absolutePath + } } } } \ No newline at end of file