[klib] Disable ManglerChecker on K2
`ManglerChecker` is a class that verifies that for each IR declaration (except some, see its `needsChecking` property) its mangled name (computed from IR) is the same as the mangled name computed from its frontend representation — `DeclarationDescriptor` on K1 or `FirDeclaration` on K2. The way it does it is as follows. On K1, `ManglerChecker` looks if the declaration has a true, non-IR-based descriptor, it if it does, then it checks it (see ManglerChecker.Companion#hasDescriptor). On K2, since we don’t have any descriptors, `ManglerChecker` looks if the declaration’s metadata property is `null` (because the corresponding `FirDeclaration` is stored there). If it’s not, it checks it (see ManglerChecker.Companion#hasMetadata). The issue is that those two conditions are not equivalent. When the Compose compiler plugin transforms an IR function, it copies its `metadata` property (as it should, because `metadata` can contain anything, not necessarily the frontend representation), but doesn't set the descriptor. Because of that, on K1 that transformed function is skipped in `ManglerChecker`, and on K2 it’s not. The correct usage would be to properly distinguish which declarations come from the FE as is, and which are transformed/synthesized, and skip the latter. But it is unclear how to implement this. For now, the easiest way to fix this on K2 is to not run ManglerChecker at all. KT-60648 ^KT-59448 Fixed
This commit is contained in:
committed by
Space Team
parent
e8e8a26cd1
commit
f5a00c788a
-1
@@ -22,7 +22,6 @@ class ManglerChecker(
|
||||
|
||||
companion object {
|
||||
val hasDescriptor: (IrDeclarationBase) -> Boolean = { it.symbol.hasDescriptor }
|
||||
val hasMetadata: (IrDeclarationBase) -> Boolean = { (it as? IrMetadataSourceOwner)?.metadata != null }
|
||||
}
|
||||
|
||||
private val manglers = _manglers.toList()
|
||||
|
||||
+5
-1
@@ -93,7 +93,11 @@ internal fun PhaseContext.fir2Ir(
|
||||
fir2IrResultPostCompute = {
|
||||
// it's important to compare manglers before actualization, since IR will be actualized, while FIR won't
|
||||
irModuleFragment.acceptVoid(
|
||||
ManglerChecker(KonanManglerIr, Ir2FirManglerAdapter(FirNativeKotlinMangler()), needsChecking = ManglerChecker.hasMetadata)
|
||||
ManglerChecker(
|
||||
KonanManglerIr,
|
||||
Ir2FirManglerAdapter(FirNativeKotlinMangler()),
|
||||
needsChecking = { false }, // FIXME(KT-60648): Re-enable
|
||||
)
|
||||
)
|
||||
}
|
||||
).also {
|
||||
|
||||
Reference in New Issue
Block a user