[K/N] Disable debug info in runtime by default

Bundle grows 200mb if debug info is enabled, it's too much.
But probably, this can be useful for debug, so we need gradle option.
This commit is contained in:
Pavel Kunyavskiy
2021-10-08 15:05:03 +03:00
committed by Space
parent 9a5058849e
commit 0bd4dbc0c1
4 changed files with 22 additions and 4 deletions
@@ -33,3 +33,6 @@ val KotlinBuildProperties.pathToYoutrackModularizedTestData: String?
val KotlinBuildProperties.isObsoleteJdkOverrideEnabled: Boolean
get() = getBoolean("kotlin.build.isObsoleteJdkOverrideEnabled", false)
val KotlinBuildProperties.isNativeRuntimeDebugInfoEnabled: Boolean
get() = getBoolean("kotlin.native.isNativeRuntimeDebugInfoEnabled", false)
+9
View File
@@ -162,6 +162,15 @@ To generate a compilation database for the Kotlin/Native runtime, run the Gradle
This task generates `<path_to_kotlin>/kotlin-native/compile_commands.json` file that should be opened in CLion as project.
Other developer tools also can use generated compilation database, but then `clangd` tool should be installed manually.
Also, it's possible to build Kotlin/Native runtime with dwarf debug information, which can be useful for debugging.
To do this you should add `kotlin.native.isNativeRuntimeDebugInfoEnabled=true` line to `local.properties` file. Note, that changing
this property requires clean compiler rebuild with gradle daemon restart.
Unfortunately, this feature works quite unstable because of using several llvm versions simultaneously,
so it's need to be additionally enabled while compiling application with `-Xbinary=stripDebugInfoFromNativeLibs=false`
compiler flag or corresponding setting in gradle build script. After doing this, Kotlin/Native runtime in application
is debuggable in CLion, with Attach to process tool.
## Performance measurement
Firstly, it's necessary to build analyzer tool to have opportunity to compare different performance results:
@@ -21,14 +21,16 @@ internal val goldValues = arrayOf(
"Exceptions.kt" to null,
"Exceptions.kt" to null,
"RuntimeUtils.kt" to null,
"Arrays.cpp" to null,
null,
"stack_trace_out_of_bounds.kt" to 7,
"stack_trace_out_of_bounds.kt" to 4,
"launcher.cpp" to null,
null,
)
internal fun checkFrame(value:String) {
val (pos, file, line) = regex.find(value)!!.destructured
val pos = value.split(" ")[0]
goldValues[pos.toInt()]?.let{
val (pos_, file, line) = regex.find(value)!!.destructured
assertEquals(pos_, pos)
assertEquals(it.first, file)
if (it.second != null) {
assertEquals(it.second, line.toInt())
@@ -16,6 +16,8 @@ import org.jetbrains.kotlin.konan.target.KonanTarget
import org.jetbrains.kotlin.konan.target.SanitizerKind
import java.io.File
import javax.inject.Inject
import kotlinBuildProperties
import isNativeRuntimeDebugInfoEnabled
open class CompileToBitcode @Inject constructor(
@Internal val srcRoot: File,
@@ -85,7 +87,9 @@ open class CompileToBitcode @Inject constructor(
@get:Input
val compilerFlags: List<String>
get() {
val commonFlags = listOf("-gdwarf-2", "-c", "-emit-llvm") + headersDirs.map { "-I$it" }
val commonFlags = listOfNotNull(
"-gdwarf-2".takeIf { project.kotlinBuildProperties.isNativeRuntimeDebugInfoEnabled },
"-c", "-emit-llvm") + headersDirs.map { "-I$it" }
val sanitizerFlags = when (sanitizer) {
null -> listOf()
SanitizerKind.ADDRESS -> listOf("-fsanitize=address")