[K/N] Add debugCompilationDir option akin to -fdebug-compilation-dir When using -Xdebug-prefix-map in K/N, Apple's linker (ld-prime) seems to discard the produced debug information because of the empty DW_AT_comp_dir value. To mitigate that, there should be a way to modify this value. This commit adds -Xbinary=debugCompilationDir=$dir option, similar to -fdebug-compilation-dir in Clang. The compiler propagates the specified value to DW_AT_comp_dir. ^KT-73306 Fixed
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BinaryOptions.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BinaryOptions.kt index 7ff5cbc..5438ccc 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BinaryOptions.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BinaryOptions.kt
@@ -96,6 +96,8 @@ val preCodegenInlineThreshold by uintOption() val enableDebugTransparentStepping by booleanOption() + + val debugCompilationDir by stringOption() } open class BinaryOption<T : Any>(
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt index 5a040d4..6bd7df8 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt
@@ -72,7 +72,7 @@ // 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. File = path.path(), - dir = "", + dir = config.configuration.get(BinaryOptions.debugCompilationDir) ?: "", producer = DWARF.producer, isOptimized = 0, flags = "",