diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt index 02d54101fed..4849c40a9df 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.* +import org.jetbrains.kotlin.konan.file.File import org.jetbrains.kotlin.util.OperatorNameConventions internal val contextLLVMSetupPhase = makeKonanModuleOpPhase( @@ -33,6 +34,19 @@ internal val contextLLVMSetupPhase = makeKonanModuleOpPhase( val llvmModule = LLVMModuleCreateWithNameInContext("out", llvmContext)!! context.llvmModule = llvmModule context.debugInfo.builder = LLVMCreateDIBuilder(llvmModule) + + // we don't split path to filename and directory to provide enough level uniquely for dsymutil to avoid symbol + // clashing, which happens on linking with libraries produced from intercepting sources. + context.debugInfo.compilationUnit = if (context.shouldContainLocationDebugInfo()) DICreateCompilationUnit( + builder = context.debugInfo.builder, + lang = DWARF.language(context.config), + File = File(context.config.outputFile).absolutePath, + dir = "-", + producer = DWARF.producer, + isOptimized = 0, + flags = "", + rv = DWARF.runtimeVersion(context.config)) as DIScopeOpaqueRef? + else null } ) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt index a7e23a2563b..632b9550d8d 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt @@ -66,6 +66,7 @@ internal class DebugInfo internal constructor(override val context: Context):Con val inlinedSubprograms = mutableMapOf() var builder: DIBuilderRef? = null var module: DIModuleRef? = null + var compilationUnit: DIScopeOpaqueRef? = null var objHeaderPointerType: DITypeOpaqueRef? = null var types = mutableMapOf() diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index f9f431794b4..40f70e1010b 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -504,20 +504,8 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map