[IR, Native] Add compiler flag for partial linkage mode
^KT-50775
This commit is contained in:
@@ -386,6 +386,7 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
|||||||
putIfNotNull(RUNTIME_LOGS, arguments.runtimeLogs)
|
putIfNotNull(RUNTIME_LOGS, arguments.runtimeLogs)
|
||||||
putIfNotNull(BUNDLE_ID, parseBundleId(arguments, outputKind, configuration))
|
putIfNotNull(BUNDLE_ID, parseBundleId(arguments, outputKind, configuration))
|
||||||
put(MEANINGFUL_BRIDGE_NAMES, arguments.meaningfulBridgeNames)
|
put(MEANINGFUL_BRIDGE_NAMES, arguments.meaningfulBridgeNames)
|
||||||
|
put(PARTIAL_LINKAGE, arguments.partialLinkage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -364,6 +364,9 @@ class K2NativeCompilerArguments : CommonCompilerArguments() {
|
|||||||
@Argument(value = "-Xlazy-ir-for-caches", valueDescription = "{disable|enable}", description = "Use lazy IR for cached libraries")
|
@Argument(value = "-Xlazy-ir-for-caches", valueDescription = "{disable|enable}", description = "Use lazy IR for cached libraries")
|
||||||
var lazyIrForCaches: String? = null
|
var lazyIrForCaches: String? = null
|
||||||
|
|
||||||
|
@Argument(value = "-Xpartial-linkage", description = "Allow unlinked symbols")
|
||||||
|
var partialLinkage: Boolean = false
|
||||||
|
|
||||||
override fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap<AnalysisFlag<*>, Any> =
|
override fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap<AnalysisFlag<*>, Any> =
|
||||||
super.configureAnalysisFlags(collector, languageVersion).also {
|
super.configureAnalysisFlags(collector, languageVersion).also {
|
||||||
val optInList = it[AnalysisFlags.optIn] as List<*>
|
val optInList = it[AnalysisFlags.optIn] as List<*>
|
||||||
|
|||||||
+2
-1
@@ -6,8 +6,8 @@
|
|||||||
package org.jetbrains.kotlin.backend.konan
|
package org.jetbrains.kotlin.backend.konan
|
||||||
|
|
||||||
import org.jetbrains.kotlin.config.CompilerConfigurationKey
|
import org.jetbrains.kotlin.config.CompilerConfigurationKey
|
||||||
import org.jetbrains.kotlin.serialization.js.ModuleKind
|
|
||||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||||
|
import org.jetbrains.kotlin.serialization.js.ModuleKind
|
||||||
|
|
||||||
class KonanConfigKeys {
|
class KonanConfigKeys {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -171,6 +171,7 @@ class KonanConfigKeys {
|
|||||||
val RUNTIME_LOGS: CompilerConfigurationKey<String> = CompilerConfigurationKey.create("enable runtime logging")
|
val RUNTIME_LOGS: CompilerConfigurationKey<String> = CompilerConfigurationKey.create("enable runtime logging")
|
||||||
val LAZY_IR_FOR_CACHES: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("use lazy IR for cached libraries")
|
val LAZY_IR_FOR_CACHES: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("use lazy IR for cached libraries")
|
||||||
val MEANINGFUL_BRIDGE_NAMES: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("enable meaningful bridge names")
|
val MEANINGFUL_BRIDGE_NAMES: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("enable meaningful bridge names")
|
||||||
|
val PARTIAL_LINKAGE: CompilerConfigurationKey<Boolean> = CompilerConfigurationKey.create("allows some symbols in klibs be missed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+19
-16
@@ -39,10 +39,12 @@ internal fun Context.psiToIr(
|
|||||||
useLinkerWhenProducingLibrary: Boolean
|
useLinkerWhenProducingLibrary: Boolean
|
||||||
) {
|
) {
|
||||||
// Translate AST to high level IR.
|
// Translate AST to high level IR.
|
||||||
val expectActualLinker = config.configuration.get(CommonConfigurationKeys.EXPECT_ACTUAL_LINKER)?:false
|
val expectActualLinker = config.configuration[CommonConfigurationKeys.EXPECT_ACTUAL_LINKER] ?: false
|
||||||
val messageLogger = config.configuration.get(IrMessageLogger.IR_MESSAGE_LOGGER) ?: IrMessageLogger.None
|
val messageLogger = config.configuration[IrMessageLogger.IR_MESSAGE_LOGGER] ?: IrMessageLogger.None
|
||||||
|
|
||||||
val translator = Psi2IrTranslator(config.configuration.languageVersionSettings, Psi2IrConfiguration(false))
|
val allowUnboundSymbols = config.configuration[KonanConfigKeys.PARTIAL_LINKAGE] ?: false
|
||||||
|
|
||||||
|
val translator = Psi2IrTranslator(config.configuration.languageVersionSettings, Psi2IrConfiguration(ignoreErrors = false, allowUnboundSymbols = allowUnboundSymbols))
|
||||||
val generatorContext = translator.createGeneratorContext(moduleDescriptor, bindingContext, symbolTable)
|
val generatorContext = translator.createGeneratorContext(moduleDescriptor, bindingContext, symbolTable)
|
||||||
|
|
||||||
val pluginExtensions = IrGenerationExtension.getInstances(config.project)
|
val pluginExtensions = IrGenerationExtension.getInstances(config.project)
|
||||||
@@ -105,19 +107,20 @@ internal fun Context.psiToIr(
|
|||||||
).associateWith { friendModules }
|
).associateWith { friendModules }
|
||||||
|
|
||||||
KonanIrLinker(
|
KonanIrLinker(
|
||||||
moduleDescriptor,
|
currentModule = moduleDescriptor,
|
||||||
translationContext,
|
translationPluginContext = translationContext,
|
||||||
messageLogger,
|
messageLogger = messageLogger,
|
||||||
generatorContext.irBuiltIns,
|
builtIns = generatorContext.irBuiltIns,
|
||||||
symbolTable,
|
symbolTable = symbolTable,
|
||||||
friendModulesMap,
|
friendModules = friendModulesMap,
|
||||||
forwardDeclarationsModuleDescriptor,
|
forwardModuleDescriptor = forwardDeclarationsModuleDescriptor,
|
||||||
stubGenerator,
|
stubGenerator = stubGenerator,
|
||||||
irProviderForCEnumsAndCStructs,
|
cenumsProvider = irProviderForCEnumsAndCStructs,
|
||||||
exportedDependencies,
|
exportedDependencies = exportedDependencies,
|
||||||
config.cachedLibraries,
|
cachedLibraries = config.cachedLibraries,
|
||||||
config.lazyIrForCaches,
|
lazyIrForCaches = config.lazyIrForCaches,
|
||||||
config.userVisibleIrModulesSupport
|
userVisibleIrModulesSupport = config.userVisibleIrModulesSupport,
|
||||||
|
allowUnboundSymbols = allowUnboundSymbols
|
||||||
).also { linker ->
|
).also { linker ->
|
||||||
|
|
||||||
// context.config.librariesWithDependencies could change at each iteration.
|
// context.config.librariesWithDependencies could change at each iteration.
|
||||||
|
|||||||
+2
-1
@@ -322,7 +322,8 @@ internal class KonanIrLinker(
|
|||||||
private val cachedLibraries: CachedLibraries,
|
private val cachedLibraries: CachedLibraries,
|
||||||
private val lazyIrForCaches: Boolean,
|
private val lazyIrForCaches: Boolean,
|
||||||
override val userVisibleIrModulesSupport: UserVisibleIrModulesSupport,
|
override val userVisibleIrModulesSupport: UserVisibleIrModulesSupport,
|
||||||
) : KotlinIrLinker(currentModule, messageLogger, builtIns, symbolTable, exportedDependencies) {
|
allowUnboundSymbols: Boolean
|
||||||
|
) : KotlinIrLinker(currentModule, messageLogger, builtIns, symbolTable, exportedDependencies, allowUnboundSymbols) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val C_NAMES_NAME = Name.identifier("cnames")
|
private val C_NAMES_NAME = Name.identifier("cnames")
|
||||||
|
|||||||
Reference in New Issue
Block a user