[KLIB] Lift up -Xmetadata-klib CLI key from Native to Common args
This is a precondition for obsoleting and finally removing `-Xexpect-actual-linker` CLI key, which became useless since the removal of ExpectActualTable. ^KT-61136
This commit is contained in:
committed by
Space Team
parent
53f994263f
commit
848c88b1a5
+1
@@ -48,6 +48,7 @@ fun copyCommonCompilerArguments(from: CommonCompilerArguments, to: CommonCompile
|
||||
to.languageVersion = from.languageVersion
|
||||
to.legacySmartCastAfterTry = from.legacySmartCastAfterTry
|
||||
to.listPhases = from.listPhases
|
||||
to.metadataKlib = from.metadataKlib
|
||||
to.metadataVersion = from.metadataVersion
|
||||
to.multiPlatform = from.multiPlatform
|
||||
to.newInference = from.newInference
|
||||
|
||||
-1
@@ -63,7 +63,6 @@ fun copyK2NativeCompilerArguments(from: K2NativeCompilerArguments, to: K2NativeC
|
||||
to.makePerFileCache = from.makePerFileCache
|
||||
to.manifestFile = from.manifestFile
|
||||
to.memoryModel = from.memoryModel
|
||||
to.metadataKlib = from.metadataKlib
|
||||
to.moduleName = from.moduleName
|
||||
to.nativeLibraries = from.nativeLibraries?.copyOf()
|
||||
to.noObjcGenerics = from.noObjcGenerics
|
||||
|
||||
+11
@@ -572,6 +572,17 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
field = value
|
||||
}
|
||||
|
||||
@Argument(
|
||||
value = "-Xmetadata-klib",
|
||||
description = "Produce a klib that only contains the declarations metadata"
|
||||
)
|
||||
var metadataKlib: Boolean = false
|
||||
set(value) {
|
||||
checkFrozen()
|
||||
field = value
|
||||
}
|
||||
|
||||
/** TODO: replace by [metadataKlib] */
|
||||
@Argument(
|
||||
value = "-Xexpect-actual-linker",
|
||||
description = "Enable experimental expect/actual linker"
|
||||
|
||||
-3
@@ -369,9 +369,6 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(value="-Xallocator", valueDescription = "std | mimalloc | custom", description = "Allocator used in runtime")
|
||||
var allocator: String? = null
|
||||
|
||||
@Argument(value = "-Xmetadata-klib", description = "Produce a klib that only contains the declarations metadata")
|
||||
var metadataKlib: Boolean = false
|
||||
|
||||
@Argument(
|
||||
value = "-Xheader-klib-path",
|
||||
description = "Save a klib that only contains the public abi to the given path"
|
||||
|
||||
@@ -29,6 +29,7 @@ fun CompilerConfiguration.setupCommonArguments(
|
||||
put(CommonConfigurationKeys.DISABLE_INLINE, arguments.noInline)
|
||||
put(CommonConfigurationKeys.USE_FIR_EXTENDED_CHECKERS, arguments.useFirExtendedCheckers)
|
||||
put(CommonConfigurationKeys.EXPECT_ACTUAL_LINKER, arguments.expectActualLinker)
|
||||
put(CommonConfigurationKeys.METADATA_KLIB, arguments.metadataKlib)
|
||||
putIfNotNull(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, arguments.intellijPluginRoot)
|
||||
put(CommonConfigurationKeys.REPORT_OUTPUT_FILES, arguments.reportOutputFiles)
|
||||
put(CommonConfigurationKeys.INCREMENTAL_COMPILATION, incrementalCompilationIsEnabled(arguments))
|
||||
|
||||
@@ -63,6 +63,9 @@ object CommonConfigurationKeys {
|
||||
@JvmField
|
||||
val EXPECT_ACTUAL_LINKER = CompilerConfigurationKey.create<Boolean>("Experimental expect/actual linker")
|
||||
|
||||
@JvmField
|
||||
val METADATA_KLIB = CompilerConfigurationKey.create<Boolean>("Produce metadata klib")
|
||||
|
||||
@JvmField
|
||||
val USE_FIR_EXTENDED_CHECKERS = CompilerConfigurationKey.create<Boolean>("fir extended checkers")
|
||||
|
||||
|
||||
+1
@@ -109,6 +109,7 @@ where advanced options include:
|
||||
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
|
||||
-Xlegacy-smart-cast-after-try Allow var smart casts despite assignment in try block
|
||||
-Xlist-phases List backend phases
|
||||
-Xmetadata-klib Produce a klib that only contains the declarations metadata
|
||||
-Xmetadata-version Change metadata version of the generated binary files
|
||||
-Xmulti-platform Enable experimental language support for multi-platform projects
|
||||
-Xnew-inference Enable new experimental generic type inference algorithm
|
||||
|
||||
+1
@@ -200,6 +200,7 @@ where advanced options include:
|
||||
-Xintellij-plugin-root=<path> Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found
|
||||
-Xlegacy-smart-cast-after-try Allow var smart casts despite assignment in try block
|
||||
-Xlist-phases List backend phases
|
||||
-Xmetadata-klib Produce a klib that only contains the declarations metadata
|
||||
-Xmetadata-version Change metadata version of the generated binary files
|
||||
-Xmulti-platform Enable experimental language support for multi-platform projects
|
||||
-Xnew-inference Enable new experimental generic type inference algorithm
|
||||
|
||||
@@ -102,6 +102,7 @@ class CompilerArgumentsContentProspectorTest {
|
||||
CommonCompilerArguments::useFirExtendedCheckers,
|
||||
CommonCompilerArguments::disableUltraLightClasses,
|
||||
CommonCompilerArguments::useMixedNamedArguments,
|
||||
CommonCompilerArguments::metadataKlib,
|
||||
CommonCompilerArguments::expectActualLinker,
|
||||
CommonCompilerArguments::extendedCompilerChecks,
|
||||
CommonCompilerArguments::disableDefaultScriptingPlugin,
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ internal inline fun <F> PhaseContext.firFrontend(
|
||||
resolvedLibraries,
|
||||
dependencyList,
|
||||
extensionRegistrars,
|
||||
metadataCompilationMode = configuration.get(KonanConfigKeys.METADATA_KLIB) ?: false,
|
||||
metadataCompilationMode = config.metadataKlib,
|
||||
isCommonSource = isCommonSource,
|
||||
fileBelongsToModule = fileBelongsToModule,
|
||||
registerExtraComponents = {
|
||||
|
||||
+1
-1
@@ -224,7 +224,7 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
||||
|
||||
internal val produce get() = configuration.get(KonanConfigKeys.PRODUCE)!!
|
||||
|
||||
internal val metadataKlib get() = configuration.get(KonanConfigKeys.METADATA_KLIB)!!
|
||||
internal val metadataKlib get() = configuration.getBoolean(CommonConfigurationKeys.METADATA_KLIB)
|
||||
|
||||
internal val headerKlibPath get() = configuration.get(KonanConfigKeys.HEADER_KLIB)
|
||||
|
||||
|
||||
-2
@@ -73,8 +73,6 @@ class KonanConfigKeys {
|
||||
= CompilerConfigurationKey.create("list available targets")
|
||||
val MANIFEST_FILE: CompilerConfigurationKey<String?>
|
||||
= CompilerConfigurationKey.create("provide manifest addend file")
|
||||
val METADATA_KLIB: CompilerConfigurationKey<Boolean>
|
||||
= CompilerConfigurationKey.create("metadata klib")
|
||||
val HEADER_KLIB: CompilerConfigurationKey<String?>
|
||||
= CompilerConfigurationKey.create("path to file where header klib should be produced")
|
||||
val MODULE_NAME: CompilerConfigurationKey<String?>
|
||||
|
||||
-1
@@ -55,7 +55,6 @@ fun CompilerConfiguration.setupFromArguments(arguments: K2NativeCompilerArgument
|
||||
val outputKind = CompilerOutputKind.valueOf(
|
||||
(arguments.produce ?: "program").uppercase())
|
||||
put(PRODUCE, outputKind)
|
||||
put(METADATA_KLIB, arguments.metadataKlib)
|
||||
putIfNotNull(HEADER_KLIB, arguments.headerKlibPath)
|
||||
|
||||
arguments.libraryVersion?.let { put(LIBRARY_VERSION, it) }
|
||||
|
||||
+4
-3
@@ -90,7 +90,7 @@ internal class DynamicCompilerDriver : CompilerDriver() {
|
||||
|
||||
private fun produceKlib(engine: PhaseEngine<PhaseContext>, config: KonanConfig, environment: KotlinCoreEnvironment) {
|
||||
val serializerOutput = if (environment.configuration.getBoolean(CommonConfigurationKeys.USE_FIR))
|
||||
serializeKLibK2(engine, environment)
|
||||
serializeKLibK2(engine, config, environment)
|
||||
else
|
||||
serializeKlibK1(engine, config, environment)
|
||||
serializerOutput?.let { engine.writeKlib(it) }
|
||||
@@ -98,18 +98,19 @@ internal class DynamicCompilerDriver : CompilerDriver() {
|
||||
|
||||
private fun serializeKLibK2(
|
||||
engine: PhaseEngine<PhaseContext>,
|
||||
config: KonanConfig,
|
||||
environment: KotlinCoreEnvironment
|
||||
): SerializerOutput? {
|
||||
val frontendOutput = engine.runFirFrontend(environment)
|
||||
if (frontendOutput is FirOutput.ShouldNotGenerateCode) return null
|
||||
require(frontendOutput is FirOutput.Full)
|
||||
|
||||
return if (environment.configuration.getBoolean(KonanConfigKeys.METADATA_KLIB)) {
|
||||
return if (config.metadataKlib) {
|
||||
engine.runFirSerializer(frontendOutput)
|
||||
} else {
|
||||
val fir2IrOutput = engine.runFir2Ir(frontendOutput)
|
||||
|
||||
val headerKlibPath = environment.configuration.get(KonanConfigKeys.HEADER_KLIB)
|
||||
val headerKlibPath = config.headerKlibPath
|
||||
if (!headerKlibPath.isNullOrEmpty()) {
|
||||
val headerKlib = engine.runFir2IrSerializer(FirSerializerInput(fir2IrOutput, produceHeaderKlib = true))
|
||||
engine.writeKlib(headerKlib, headerKlibPath)
|
||||
|
||||
Reference in New Issue
Block a user