diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/IrProviderForCEnumAndCStructStubs.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/IrProviderForCEnumAndCStructStubs.kt index 33ee4817532..603b88150b2 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/IrProviderForCEnumAndCStructStubs.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/IrProviderForCEnumAndCStructStubs.kt @@ -116,9 +116,13 @@ internal class IrProviderForCEnumAndCStructStubs( private fun irParentFor(descriptor: ClassDescriptor): IrDeclarationContainer { val packageFragmentDescriptor = descriptor.findPackage() return filesMap.getOrPut(packageFragmentDescriptor) { - IrFileImpl(NaiveSourceBasedFileEntryImpl("CTypeDefinitions"), packageFragmentDescriptor).also { + IrFileImpl(NaiveSourceBasedFileEntryImpl(cTypeDefinitionsFileName), packageFragmentDescriptor).also { this@IrProviderForCEnumAndCStructStubs.module?.files?.add(it) } } } + + companion object { + const val cTypeDefinitionsFileName = "CTypeDefinitions" + } } \ No newline at end of file diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrModuleSerializer.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrModuleSerializer.kt index fd73b981ca4..7a25f8b7dbe 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrModuleSerializer.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrModuleSerializer.kt @@ -3,6 +3,7 @@ package org.jetbrains.kotlin.backend.konan.serialization import org.jetbrains.kotlin.backend.common.LoggingContext import org.jetbrains.kotlin.backend.common.serialization.* import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer +import org.jetbrains.kotlin.backend.konan.ir.interop.IrProviderForCEnumAndCStructStubs import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns @@ -18,6 +19,15 @@ class KonanIrModuleSerializer( private val signaturer = IdSignatureSerializer(KonanManglerIr) private val globalDeclarationTable = KonanGlobalDeclarationTable(signaturer, irBuiltIns) + // We skip files with IR for C structs and enums because they should be + // generated anew. + // + // See [IrProviderForCEnumAndCStructStubs.kt#L31] on why we generate IR. + // We may switch from IR generation to LazyIR later (at least for structs; enums are tricky) + // without changing kotlin libraries that depend on interop libraries. + override fun backendSpecificFileFilter(file: IrFile): Boolean = + file.fileEntry.name != IrProviderForCEnumAndCStructStubs.cTypeDefinitionsFileName + override fun createSerializerForFile(file: IrFile): KonanIrFileSerializer = KonanIrFileSerializer(logger, DeclarationTable(globalDeclarationTable), expectDescriptorToSymbol, skipExpects = skipExpects) }