[KLIB] Use -Xmetadata-klib to produce metadata KLIBs
With this change a new `-Xmetadata-klib` CLI flag becomes the preferable way to instruct K2MetadataCompiler to produce metadata KLIBs. The old `-Xexpect-actual-linker` flag still works for K2MetadataCompiler, but that would last just for a short transition period until the necessary changes are made in the Gradle plugin. The K2NativeCompiler does not work anymore with `-Xexpect-actual-linker` and respects only the `-Xmetadata-klib` flag. This is not an issue since the Gradle plugin anyway supplies both flags for Native metadata compilations. ^KT-61136
This commit is contained in:
committed by
Space Team
parent
848c88b1a5
commit
38a67f3d30
+1
-1
@@ -818,7 +818,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
)
|
||||
}
|
||||
put(AnalysisFlags.optIn, useExperimentalFqNames + optIn?.toList().orEmpty())
|
||||
put(AnalysisFlags.skipExpectedActualDeclarationChecker, expectActualLinker)
|
||||
put(AnalysisFlags.skipExpectedActualDeclarationChecker, expectActualLinker || metadataKlib) // TODO (KT-61136): drop `expectActualLinker` later, after the appropriate changes in the Gradle plugin
|
||||
put(AnalysisFlags.explicitApiVersion, apiVersion != null)
|
||||
put(AnalysisFlags.allowResultReturnType, allowResultReturnType)
|
||||
ExplicitApiMode.fromString(explicitApi)?.also { put(AnalysisFlags.explicitApiMode, it) } ?: collector.report(
|
||||
|
||||
@@ -101,7 +101,8 @@ class K2MetadataCompiler : CLICompiler<K2MetadataCompilerArguments>() {
|
||||
val environment =
|
||||
KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.METADATA_CONFIG_FILES)
|
||||
|
||||
val mode = if(arguments.expectActualLinker) "KLib" else "metadata"
|
||||
// TODO (KT-61136): drop `expectActualLinker` later, after the appropriate changes in the Gradle plugin
|
||||
val mode = if (arguments.expectActualLinker || arguments.metadataKlib) "KLib" else "metadata"
|
||||
|
||||
val sourceFiles = environment.getSourceFiles()
|
||||
performanceManager.notifyCompilerInitialized(sourceFiles.size, environment.countLinesOfCode(sourceFiles), "$mode mode for $moduleName module")
|
||||
@@ -120,7 +121,8 @@ class K2MetadataCompiler : CLICompiler<K2MetadataCompilerArguments>() {
|
||||
val useFir = configuration.getBoolean(CommonConfigurationKeys.USE_FIR)
|
||||
val metadataSerializer = when {
|
||||
useFir -> FirMetadataSerializer(configuration, environment)
|
||||
arguments.expectActualLinker -> K2MetadataKlibSerializer(configuration, environment)
|
||||
// TODO (KT-61136): drop `expectActualLinker` later, after the appropriate changes in the Gradle plugin
|
||||
arguments.expectActualLinker || arguments.metadataKlib -> K2MetadataKlibSerializer(configuration, environment)
|
||||
else -> MetadataSerializer(configuration, environment, dependOnOldBuiltIns = true)
|
||||
}
|
||||
metadataSerializer.analyzeAndSerialize()
|
||||
|
||||
+2
-2
@@ -686,14 +686,14 @@ abstract class AbstractCompileKotlinAgainstCustomBinariesTest : AbstractKotlinCo
|
||||
fun testAnonymousObjectTypeMetadataKlib() {
|
||||
val klibLibrary = compileCommonLibrary(
|
||||
libraryName = "library",
|
||||
listOf("-Xexpect-actual-linker"),
|
||||
listOf("-Xmetadata-klib"),
|
||||
)
|
||||
compileKotlin(
|
||||
"anonymousObjectTypeMetadata.kt",
|
||||
tmpdir,
|
||||
listOf(klibLibrary),
|
||||
K2MetadataCompiler(),
|
||||
listOf("-Xexpect-actual-linker")
|
||||
listOf("-Xmetadata-klib")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user