[JS IR] Ignore unbound symbols in IC infrastructure

The IR linker is responsible for detecting unbound symbols,
 if it skips them for some reason, IC infrastructure must not fail
 with unbound symbols exceptions. Anyway, the IR validator
 verifies later if there are unbound symbols in
 reachable IR and generates the corresponding error.

^KT-56602 Fixed
This commit is contained in:
Alexander Korepanov
2023-02-20 11:54:47 +01:00
committed by Space Team
parent ff22f456a0
commit 3c9d653595
16 changed files with 101 additions and 13 deletions
@@ -115,7 +115,15 @@ internal sealed class FileSignatureProvider(val irFile: IrFile) {
}
override fun getImplementedSymbols(): Map<IdSignature, IrSymbol> {
return collectImplementedSymbol(fileDeserializer.symbolDeserializer.deserializedSymbols)
// Sometimes linker may leave unbound symbols in IrSymbolDeserializer::deserializedSymbols map.
// Generally, all unbound symbols must be caught in KotlinIrLinker::checkNoUnboundSymbols,
// unfortunately it does not work properly in the current implementation.
// Also, reachable unbound symbols are caught by IrValidator, it works fine, but it works after this place.
// Filter unbound symbols here, because an error from IC infrastructure about the unbound symbols looks pretty wired
// and if the unbound symbol is really reachable from IR the error will be fired from IrValidator later.
// Otherwise, the unbound symbol is unreachable, and it cannot appear in IC dependency graph, so we can ignore them.
val deserializedSymbols = fileDeserializer.symbolDeserializer.deserializedSymbols.filter { it.value.isBound }
return collectImplementedSymbol(deserializedSymbols)
}
}
@@ -48,7 +48,8 @@ class ModuleInfo(val moduleName: String) {
val dependencies: Collection<Dependency>,
val modifications: List<Modification>,
val expectedFileStats: Map<String, Set<String>>,
val expectedDTS: Set<String>
val expectedDTS: Set<String>,
val rebuildKlib: Boolean
)
val steps = mutableListOf<ModuleStep>()
@@ -67,6 +68,7 @@ private const val MODIFICATIONS = "modifications"
private const val MODIFICATION_UPDATE = "U"
private const val MODIFICATION_DELETE = "D"
private const val EXPECTED_DTS_LIST = "expected dts"
private const val REBUILD_KLIB = "rebuild klib"
private val STEP_PATTERN = Pattern.compile("^\\s*STEP\\s+(\\d+)\\.*(\\d+)?\\s*:?$")
@@ -213,6 +215,7 @@ class ModuleInfoParser(infoFile: File) : InfoParser<ModuleInfo>(infoFile) {
val friendDependencies = mutableSetOf<String>()
val modifications = mutableListOf<ModuleInfo.Modification>()
val expectedDTS = mutableSetOf<String>()
var rebuildKlib = true
loop { line ->
if (line.matches(STEP_PATTERN.toRegex()))
@@ -234,6 +237,9 @@ class ModuleInfoParser(infoFile: File) : InfoParser<ModuleInfo>(infoFile) {
FRIENDS -> getOpArgs().forEach { friendDependencies += it }
MODIFICATIONS -> modifications += parseModifications()
EXPECTED_DTS_LIST -> getOpArgs().forEach { expectedDTS += it }
REBUILD_KLIB -> getOpArgs().singleOrNull()?.toBooleanStrictOrNull()?.let {
rebuildKlib = it
} ?: error(diagnosticMessage("$op expects true or false", line))
else -> error(diagnosticMessage("Unknown op $op", line))
}
}
@@ -255,7 +261,8 @@ class ModuleInfoParser(infoFile: File) : InfoParser<ModuleInfo>(infoFile) {
dependencies = dependencies,
modifications = modifications,
expectedFileStats = expectedFileStats,
expectedDTS = expectedDTS
expectedDTS = expectedDTS,
rebuildKlib = rebuildKlib
)
}
}