diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/LinkStage.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/LinkStage.kt index 53190e5dd01..7786a3faa6f 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/LinkStage.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/LinkStage.kt @@ -55,6 +55,7 @@ internal open class MacOSPlatform(distribution: Distribution) properties.propertyList("linkerOptimizationFlags.osx") override val linkerKonanFlags = properties.propertyList("linkerKonanFlags.osx") override val linker = "${distribution.sysRoot}/usr/bin/ld" + private val dsymutil = "${distribution.llvmBin}/llvm-dsymutil" open val arch = properties.propertyString("arch.osx")!! open val osVersionMin = properties.propertyList("osVersionMin.osx") @@ -75,6 +76,14 @@ internal open class MacOSPlatform(distribution: Distribution) linkerKonanFlags + listOf("-lSystem") } + + open fun dsymutilCommand(executable: ExecutableFile): List { + return listOf(dsymutil, executable) + } + + open fun dsymutilDryRunVerboseCommand(executable: ExecutableFile): List { + return listOf(dsymutil, "-dump-debug-map" ,executable) + } } internal class IPhoneOSfromMacOSPlatform(distribution: Distribution) @@ -259,6 +268,11 @@ internal class LinkStage(val context: Context) { entryPointSelector runTool(*linkCommand.toTypedArray()) + if (platform is MacOSPlatform && context.shouldContainDebugInfo()) { + if (context.phase?.verbose ?: false) + runTool(*platform.dsymutilDryRunVerboseCommand(executable).toTypedArray()) + runTool(*platform.dsymutilCommand(executable).toTypedArray()) + } return executable }