From 6cb8b0c18ad1c3693999aa3fcae3827a3ce21136 Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Thu, 19 Nov 2020 13:45:24 +0300 Subject: [PATCH] Only llvm-link generated files in CompileToBitcode (#4536) --- .../kotlin/bitcode/CompileToBitcode.kt | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) 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