上游 · Compiler options in the Kotlin Gradle plugin
false
freeCompilerArgs
A list of additional compiler arguments. You can use experimental -X arguments here too. See an example
[]
全部配置 / APP-FREECOMPILERARGS
freeCompilerArgs · APP-FREECOMPILERARGS · Gradle DSL
默认值:未设置。默认为空列表,由工程追加。使用场合:开发必用。开发必用:日常开发/调试几乎都会用到。
用途。Gradle 向编译器透传额外参数的入口(如 -g、-opt、-Xbinary=…)。应按 Debug/Release 分流,避免在公共配置写入仅排障用参数。
影响。错误参数导致失败或意外行为。
适用场景。所有需透传编译器参数的场景;按 Debug/Release 分流,避免公共污染。
可写。<元素列表> (Gradle 列表属性:org.gradle.api.provider.ListProperty<kotlin.String>)
定义依据:dsl/KotlinCommonCompilerToolOptions.kt 在仓库中打开
// 文件:build.gradle.kts(应用的 Kotlin 模块,例如 composeApp)
kotlin {
ohosArm64 { // 按实际 native target 调整
binaries.all {
freeCompilerArgs += "-Xbinary=sanitizer=address" // 示例:把 Native 编译器旗标透传进去
}
}
}
不写这个配置时,编译器会怎么处理?
此选项默认未设置(空列表 / 空映射 / null)。不设置时由其他逻辑决定行为或直接跳过。
默认为空列表,由工程追加。
以下摘抄原文中与本配置最相关的段落,便于速读;完整上下文请点原文。 上游与 CPF 分栏对照。
false
freeCompilerArgs
A list of additional compiler arguments. You can use experimental -X arguments here too. See an example
[]
暂未自动定位到与本项直接相关的段落,请打开原文检索。