[link stage][macos] forcebly mute dsymutil warning about absence of _main symbol.
This commit is contained in:
committed by
vvlevchenko
parent
9d7e249559
commit
9fc16260c6
+21
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.util.bufferedReader
|
||||
import java.io.File
|
||||
import java.lang.ProcessBuilder
|
||||
import java.lang.ProcessBuilder.Redirect
|
||||
@@ -93,7 +94,7 @@ internal open class MacOSBasedPlatform(distribution: Distribution)
|
||||
|
||||
// TODO: move 'ld' out of the host sysroot, as it doesn't belong here.
|
||||
private val linker = "${distribution.hostSysRoot}/usr/bin/ld"
|
||||
private val dsymutil = "${distribution.llvmBin}/llvm-dsymutil"
|
||||
internal val dsymutil = "${distribution.llvmBin}/llvm-dsymutil"
|
||||
|
||||
open val osVersionMin by lazy {
|
||||
listOf(
|
||||
@@ -277,11 +278,29 @@ internal class LinkStage(val context: Context) {
|
||||
val builder = ProcessBuilder(command.asList())
|
||||
|
||||
// Inherit main process output streams.
|
||||
val isDsymUtil = platform is MacOSBasedPlatform && command[0] == platform.dsymutil
|
||||
|
||||
builder.redirectOutput(Redirect.INHERIT)
|
||||
builder.redirectInput(Redirect.INHERIT)
|
||||
builder.redirectError(Redirect.INHERIT)
|
||||
if (!isDsymUtil)
|
||||
builder.redirectError(Redirect.INHERIT)
|
||||
|
||||
|
||||
val process = builder.start()
|
||||
if (isDsymUtil) {
|
||||
/**
|
||||
* llvm-lto has option -alias that lets tool to know which symbol we use instead of _main,
|
||||
* llvm-dsym doesn't have such a option, so we ignore annoying warning manually.
|
||||
*/
|
||||
val errorStream = process.errorStream
|
||||
val outputStream = bufferedReader(errorStream)
|
||||
while (true) {
|
||||
val line = outputStream.readLine() ?: break
|
||||
if (!line.contains("warning: could not find object file symbol for symbol _main"))
|
||||
System.err.println(line)
|
||||
}
|
||||
outputStream.close()
|
||||
}
|
||||
val exitCode = process.waitFor()
|
||||
return exitCode
|
||||
}
|
||||
|
||||
+4
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.util
|
||||
|
||||
import java.io.BufferedReader
|
||||
import java.io.InputStream
|
||||
import java.io.InputStreamReader
|
||||
import java.net.URI
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Files
|
||||
@@ -118,3 +121,4 @@ fun File.copyTo(destination: File, vararg options: StandardCopyOption) {
|
||||
Files.copy(this.toPath(), destination.toPath(), *options)
|
||||
}
|
||||
|
||||
fun bufferedReader(errorStream: InputStream?) = BufferedReader(InputStreamReader(errorStream))
|
||||
Reference in New Issue
Block a user