全部配置 / KN-XRUNTIME-LOGS

Xruntime-logs

Xruntime-logs · KN-XRUNTIME-LOGS · 编译器参数(Native)

重要:中 · 场景相关 默认:未设置(不传则空) 场合:场景可配 来源:上游原样

默认值:未设置。未指定则为空。使用场合:场景可配。场景可配:有明确目标(性能、包体、安全、兼容)时再改。

它是做什么的

用途。启用 Native runtime 内部日志。原文:Enable logging of Native runtime internals.

影响。实验/高级编译开关;默认保持关闭,改前需可复现、可回滚。

适用场景。场景可配。有明确需求再改,无需求时保持发行版默认更稳妥。改前核对目标限制与联动项,改后做冒烟。

取值说明

字符串 · 写法 -Xruntime-logs <tag1=level1,tag2=level2,...> · 默认 null / 未设置

  • 参数描述:Enable logging of Native runtime internals.

可写。<tag1=level1,tag2=level2,...> (字符串参数。valueDescription=<tag1=level1,tag2=level2,...>)

定义依据:description/NativeCompilerArguments.kt 在仓库中打开

怎么用

  1. 配置入口:build.gradle.kts → ohosArm64.binaries.all { freeCompilerArgs += "-Xruntime-logs" }
  2. 示例
// 文件:build.gradle.kts(应用的 Kotlin 模块,例如 composeApp)
kotlin {
  ohosArm64 {  // 按实际 native target 调整
    binaries.all {
      freeCompilerArgs += "-Xruntime-logs"
    }
  }
}
  1. 生效:Sync 后执行该目标的 compile/link。
  2. 验证:编译日志出现 `-Xruntime-logs`。
  3. 回滚:从 binaries.all 的 freeCompilerArgs 中删除该项后 Clean 并重编。
  4. 注意:实验项无稳定兼容保证;改前留可回滚配置。

默认行为 未设置

不写这个配置时,编译器会怎么处理?

此选项默认未设置(空列表 / 空映射 / null)。不设置时由其他逻辑决定行为或直接跳过。

未指定则为空。

相关文档

以下摘抄原文中与本配置最相关的段落,便于速读;完整上下文请点原文。

上游 · Kotlin/Native memory management

To monitor the GC performance, you can look through its logs and diagnose issues. To enable logging, set the following compiler option in your Gradle build script:

-Xruntime-logs=gc=info

Currently, the logs are only printed to stderr .

On Apple platforms, you can take advantage of the Xcode Instruments toolkit to debug iOS app performance. The garbage collector reports pauses with signposts available in Instruments. Signposts enable custom logging within your app, allowing you to check if a GC pause corresponds to an application freeze.…

打开原文

溯源与对照

状态
实验(-X,兼容性不保证)
版本基线
2.2.21-1.0.0
定义位置类型
编译器参数定义(arguments DSL)
源码路径
compiler/arguments/src/org/jetbrains/kotlin/arguments/description/NativeCompilerArguments.kt 在仓库中打开