diff --git a/IOS_SYMBOLICATION.md b/IOS_SYMBOLICATION.md index 51e2aa4b1e7..c7d58ec0cc1 100644 --- a/IOS_SYMBOLICATION.md +++ b/IOS_SYMBOLICATION.md @@ -9,21 +9,21 @@ symbolication turns machine code addresses into human-readable source locations. The document below describes some specific details of symbolicating crash reports from iOS applications using Kotlin. -## Enable .dSYM for release Kotlin binaries +## Producing .dSYM for release Kotlin binaries To symbolicate addresses in Kotlin code (e.g. for stack trace elements corresponding to Kotlin code) `.dSYM` bundle for Kotlin code is required. -By default Kotlin/Native compiler doesn't produce `.dSYM` for release -(i.e. optimized) binaries. This can be changed with `-Xg0` experimental -compiler flag: it enables debug info and `.dSYM` bundle generation for produced -release binaries. To enable it in Gradle, use +By default Kotlin/Native compiler produces `.dSYM` for release +(i.e. optimized) binaries on Darwin platforms. This can be disabled with `-Xadd-light-debug=disable` +compiler flag. At the same time this option is disabled by default for other platforms, to enable it use `-Xadd-light-debug=enable`. +To control option in Gradle, use ```kotlin kotlin { targets.withType { binaries.all { - freeCompilerArgs += "-Xg0" + freeCompilerArgs += "-Xadd-light-debug={enable|disable}" } } } diff --git a/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt b/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt index 92bc57bb478..aff46f4fba7 100644 --- a/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt +++ b/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt @@ -152,7 +152,21 @@ class K2Native : CLICompiler() { put(LIST_TARGETS, arguments.listTargets) put(OPTIMIZATION, arguments.optimization) put(DEBUG, arguments.debug) - put(LIGHT_DEBUG, arguments.lightDebug) + // TODO: remove after 1.4 release. + if (arguments.lightDebugDeprecated) { + configuration.report(WARNING, + "-Xg0 is now deprecated and skipped by compiler. Light debug information is enabled by default for Darwin platforms." + + " For other targets, please, use `-Xadd-light-debug=enable` instead.") + } + putIfNotNull(LIGHT_DEBUG, when (val it = arguments.lightDebugString) { + "enable" -> true + "disable" -> false + null -> null + else -> { + configuration.report(ERROR, "Unsupported -Xadd-light-debug= value: $it. Possible values are 'enable'/'disable'") + null + } + }) put(STATIC_FRAMEWORK, selectFrameworkType(configuration, arguments, outputKind)) put(OVERRIDE_CLANG_OPTIONS, arguments.clangOptions.toNonNullList()) put(ALLOCATION_MODE, arguments.allocator) diff --git a/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt b/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt index 3bf62fe3c97..b3ad1c1be4d 100644 --- a/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt +++ b/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt @@ -152,8 +152,18 @@ class K2NativeCompilerArguments : CommonCompilerArguments() { ) var frameworkImportHeaders: Array? = null - @Argument(value = "-Xg0", description = "Add light debug information") - var lightDebug: Boolean = false + @Argument( + value = "-Xadd-light-debug", + valueDescription = "{disable|enable}", + description = "Add light debug information for optimized builds. This option is skipped in debug builds.\n" + + "It's enabled by default on Darwin platforms where collected debug information is stored in .dSYM file.\n" + + "Currently option is disabled by default on other platforms." + ) + var lightDebugString: String? = null + + // TODO: remove after 1.4 release. + @Argument(value = "-Xg0", description = "Add light debug information. Deprecated option. Please use instead -Xadd-light-debug=enable") + var lightDebugDeprecated: Boolean = false @Argument( value = MAKE_CACHE, diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt index 945eb25cf66..f9b58ae3309 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfig.kt @@ -37,7 +37,8 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration // TODO: debug info generation mode and debug/release variant selection probably requires some refactoring. val debug: Boolean get() = configuration.getBoolean(KonanConfigKeys.DEBUG) - val lightDebug: Boolean get() = configuration.getBoolean(KonanConfigKeys.LIGHT_DEBUG) + val lightDebug: Boolean = configuration.get(KonanConfigKeys.LIGHT_DEBUG) + ?: target.family.isAppleFamily // Default is true for Apple targets. val memoryModel: MemoryModel get() = configuration.get(KonanConfigKeys.MEMORY_MODEL)!! diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfigurationKeys.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfigurationKeys.kt index e6fa6e8ad09..9718a1e8058 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfigurationKeys.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanConfigurationKeys.kt @@ -52,7 +52,7 @@ class KonanConfigKeys { = CompilerConfigurationKey.create("library file paths") val LIBRARY_VERSION: CompilerConfigurationKey = CompilerConfigurationKey.create("library version") - val LIGHT_DEBUG: CompilerConfigurationKey + val LIGHT_DEBUG: CompilerConfigurationKey = CompilerConfigurationKey.create("add light debug information") val LINKER_ARGS: CompilerConfigurationKey> = CompilerConfigurationKey.create("additional linker arguments") diff --git a/performance/build.gradle b/performance/build.gradle index 3f4ed5ee9a2..86cb5b0ebaf 100644 --- a/performance/build.gradle +++ b/performance/build.gradle @@ -37,10 +37,26 @@ task clean { defaultTasks 'konanRun' +private static String getAnalyzerTargetName() { + // Copy-pasted from tools/benchmarksAnalyzer/build.gradle. + String target = System.getProperty("os.name") + if (target == 'Linux') return 'linux' + if (target.startsWith('Windows')) return 'windows' + if (target.startsWith('Mac')) return 'macos' + return 'unknown' +} + +private String findAnalyzerBinary() { + String result = "${rootProject.projectDir}/${analyzerToolDirectory}/${getAnalyzerTargetName()}/" + + "${analyzerTool}ReleaseExecutable/${analyzerTool}${MPPTools.getNativeProgramExtension()}" + + if (file(result).exists()) return result + else return null +} + // Produce and send slack report. task slackReport(type: RegressionsReporter) { - def analyzerBinary = MPPTools.findFile("${analyzerTool}${MPPTools.getNativeProgramExtension()}", - "${rootBuildDirectory}/${analyzerToolDirectory}") + def analyzerBinary = findAnalyzerBinary() def teamcityConfig = System.getenv("TEAMCITY_BUILD_PROPERTIES_FILE") if (teamcityConfig && analyzerBinary != null) { // Create folder for report (root Kotlin project settings make create report in separate folder). @@ -143,8 +159,7 @@ task registerExternalBenchmarks { } task registerBuild(type: BuildRegister) { - def analyzerBinary = MPPTools.findFile("${analyzerTool}${MPPTools.getNativeProgramExtension()}", - "${rootBuildDirectory}/${analyzerToolDirectory}") + def analyzerBinary = findAnalyzerBinary() if (analyzerBinary != null) { onlyBranch = project.findProperty('kotlin.register.branch') // Get bundle size. @@ -194,8 +209,7 @@ subprojects.each { } task teamCityStat(type:Exec) { - def extension = MPPTools.getNativeProgramExtension() - def analyzer = MPPTools.findFile("${analyzerTool}${extension}", "${rootBuildDirectory}/${analyzerToolDirectory}") + def analyzer = findAnalyzerBinary() if (analyzer != null) { commandLine "${analyzer}", "-r", "teamcity", "${buildDir.absolutePath}/${nativeJson}" } else {