[KLIB] Support partially linked klibs in Ir linker

Now it's possible to compile against klib even if in there are
references to declarations from other klibs which are no longer existed

 - add switch flag to turn on/off that mode
 - pass switch flag from JS CLI to JS Linker
This commit is contained in:
Roman Artemev
2021-11-16 13:52:22 +03:00
committed by TeamCityServer
parent 650b04b4dd
commit 53a65f818f
5 changed files with 444 additions and 15 deletions
@@ -412,6 +412,8 @@ fun getIrModuleInfoForKlib(
val typeTranslator = TypeTranslatorImpl(symbolTable, configuration.languageVersionSettings, moduleDescriptor)
val irBuiltIns = IrBuiltInsOverDescriptors(moduleDescriptor.builtIns, typeTranslator, symbolTable)
val allowUnboundSymbols = configuration[JSConfigurationKeys.PARTIAL_LINKAGE] ?: false
val irLinker =
JsIrLinker(
null,
@@ -421,7 +423,8 @@ fun getIrModuleInfoForKlib(
null,
null,
loweredIcData,
friendModules
friendModules,
allowUnboundSymbols
)
val deserializedModuleFragmentsToLib = deserializeDependencies(sortedDependencies, irLinker, mainModuleLib, filesToLoad, mapping)
@@ -479,7 +482,8 @@ fun getIrModuleInfoForSourceFiles(
feContext,
null,
loweredIcData,
friendModules
friendModules,
allowUnboundSymbols
)
val deserializedModuleFragmentsToLib = deserializeDependencies(allSortedDependencies, irLinker, null,null, mapping)
val deserializedModuleFragments = deserializedModuleFragmentsToLib.keys.toList()
@@ -30,8 +30,9 @@ class JsIrLinker(
override val translationPluginContext: TranslationPluginContext?,
private val icData: ICData? = null,
private val loweredIcData: Map<ModuleDescriptor, SerializedIcData> = emptyMap(),
friendModules: Map<String, Collection<String>> = emptyMap()
) : KotlinIrLinker(currentModule, messageLogger, builtIns, symbolTable, emptyList()) {
friendModules: Map<String, Collection<String>> = emptyMap(),
allowUnboundSymbols: Boolean = false
) : KotlinIrLinker(currentModule, messageLogger, builtIns, symbolTable, emptyList(), allowUnboundSymbols) {
override val fakeOverrideBuilder = FakeOverrideBuilder(this, symbolTable, JsManglerIr, IrTypeSystemContextImpl(builtIns), friendModules)