全部配置 / KN-VERSION

version

version · KN-VERSION · 编译器参数(Native)

重要:低 · 工具/诊断 默认:—(无开关语义) 场合:排障诊断 来源:上游原样

默认值:—。无开关语义。使用场合:排障诊断。排障诊断:定位编译或运行问题时短时开启,结束后应关闭。

它是做什么的

用途。显示编译器版本。原文:Display the compiler version.

影响。主要改变诊断/日志输出;对产物行为影响通常很小。

适用场景。编译器/后端排查或信息查询;定位完成后关闭冗余输出。

取值说明

布尔 · 写法 -version(开启) · 默认 false(BooleanType.defaultFalse)

可写。(开关存在 / true) / false / 不传

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

怎么用

  1. 配置入口:build.gradle.kts → ohosArm64.binaries.all { freeCompilerArgs += "-version" }
  2. 示例
// 文件:build.gradle.kts(应用的 Kotlin 模块,例如 composeApp)
kotlin {
  ohosArm64 {  // 按实际 native target 调整
    binaries.all {
      freeCompilerArgs += "-version"
    }
  }
}
  1. 生效:Sync 后执行该目标的 compile/link。
  2. 验证:确认输出中出现预期诊断内容(不仅是命令行出现 `-version`)。
  3. 回滚:从 binaries.all 的 freeCompilerArgs 中删除该项后 Clean 并重编。
  4. 注意:按 Debug/Release 分流配置,避免公共污染。

默认行为

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

此项无开关语义(如打印帮助、列出目标),不是运行时行为开关。

无开关语义。

相关文档

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

上游 · Kotlin compiler options · Common

-verbose

Enable verbose logging output which includes details of the compilation process.

-version

Display the compiler version.

-X

Display information about the advanced options and exit. These options are currently unstable: their names and behavior may be changed without notice.

Kotlin contract options

The following options enable experimental Kotlin contract features.

-Xallow-contracts-on-more-functions

Enables contracts in additional declarations, including property accessors, specific operator functions, and type assertions on generic types.…

打开原文

溯源与对照

状态
稳定(正式选项)
版本基线
2.2.21-1.0.0
定义位置类型
编译器参数定义(arguments DSL)
源码路径
compiler/arguments/src/org/jetbrains/kotlin/arguments/description/CommonToolArguments.kt 在仓库中打开