[klib tool] Return unbound symbols for dump-ir mode

This is more convenient behaviour for debugging with klib-tool than
just failing.

Note that enabling Partial Linkage globally in klib-tool is undesirable,
as it can auto-tweak IR (e.g. when overrides do not match), thus
distorting the rendered IR

^KT-61143 Fixed
This commit is contained in:
Dmitry Savvinov
2023-12-18 18:29:24 +01:00
committed by Space Team
parent fcfc2446cf
commit 77ebe1085d
2 changed files with 8 additions and 1 deletions
@@ -57,6 +57,9 @@ abstract class KotlinIrLinker(
open val partialLinkageSupport: PartialLinkageSupportForLinker get() = PartialLinkageSupportForLinker.DISABLED open val partialLinkageSupport: PartialLinkageSupportForLinker get() = PartialLinkageSupportForLinker.DISABLED
open val returnUnboundSymbolsIfSignatureNotFound: Boolean
get() = partialLinkageSupport.isEnabled
protected open val userVisibleIrModulesSupport: UserVisibleIrModulesSupport get() = UserVisibleIrModulesSupport.DEFAULT protected open val userVisibleIrModulesSupport: UserVisibleIrModulesSupport get() = UserVisibleIrModulesSupport.DEFAULT
fun deserializeOrReturnUnboundIrSymbolIfPartialLinkageEnabled( fun deserializeOrReturnUnboundIrSymbolIfPartialLinkageEnabled(
@@ -77,7 +80,7 @@ abstract class KotlinIrLinker(
val symbol: IrSymbol? = actualModuleDeserializer?.tryDeserializeIrSymbol(idSignature, symbolKind) val symbol: IrSymbol? = actualModuleDeserializer?.tryDeserializeIrSymbol(idSignature, symbolKind)
return symbol ?: run { return symbol ?: run {
if (partialLinkageSupport.isEnabled) if (returnUnboundSymbolsIfSignatureNotFound)
referenceDeserializedSymbol(symbolTable, null, symbolKind, idSignature) referenceDeserializedSymbol(symbolTable, null, symbolKind, idSignature)
else else
SignatureIdNotFoundInModuleWithDependencies( SignatureIdNotFoundInModuleWithDependencies(
@@ -274,6 +274,10 @@ class Library(val libraryNameOrPath: String, val requestedRepository: String?) {
friendModules = emptyMap(), friendModules = emptyMap(),
partialLinkageSupport = PartialLinkageSupportForLinker.DISABLED, partialLinkageSupport = PartialLinkageSupportForLinker.DISABLED,
) )
override val returnUnboundSymbolsIfSignatureNotFound: Boolean
get() = true
override val translationPluginContext: TranslationPluginContext override val translationPluginContext: TranslationPluginContext
get() = TODO("Not needed for ir dumping") get() = TODO("Not needed for ir dumping")