Repository navigation
Description
Generated by Claude:
Summary
Since 1.2.2, a KMP library whose @Module has includes = [...] pointing at @ComponentScan modules from other Gradle modules re-declares the componentscan_* hints of those modules in its own klib. The same hint is then declared in two klibs, and the Kotlin/Native link of the final framework fails with IrSimpleFunctionSymbolImpl is already bound.
Every compileKotlinIosSimulatorArm64 task passes; only linkDebugFrameworkIosSimulatorArm64 fails. The same sources link fine with 1.2.1. The 1.2.3 fix for #144 does not change this case.
Environment
- koin-compiler-plugin 1.2.2 and 1.2.3: link fails. 1.2.1: link OK.
- koin / koin-annotations 4.2.2
- Kotlin 2.4.21 (the plugin logs that it proceeds with the 2.4.20 adapter)
- Gradle 9.8.2, AGP 9.5.0, Compose Multiplatform 1.12.0
- Target
iosSimulatorArm64, dynamic framework (isStatic = false) compileSafety = falsein every module
Module layout
Each module below is its own Gradle module with the compiler plugin applied.
// :core:base
@Module @ComponentScan("com.example.core.base") class BaseModule
// :core:model, :core:resources, :core:network, :core:database: same shape
// :core:data
@Module(includes = [NetworkModule::class, DatabaseModule::class])
@ComponentScan("com.example.core.data")
class DataModule
// :core:viewmodel
@Module(includes = [BaseModule::class, ResourcesModule::class, ModelModule::class, DataModule::class])
@ComponentScan("com.example.core.viewmodel")
class ViewmodelModuleThe app framework (:app:mobile:shared, baseName = "Cmp") depends on all of them and exports :core:base, :core:model, :core:resources, :core:viewmodel and :core:ui.
Error
> Task :app:mobile:shared:linkDebugFrameworkIosSimulatorArm64 FAILED
e: Compilation failed: IrSimpleFunctionSymbolImpl is already bound. Signature: org.koin.plugin.hints/componentscan_com_example_core_base_di_BaseModule_single|componentscan_com_example_core_base_di_BaseModule_single(com.example.core.base.interfaces.BiometricHelper;com.example.core.base.interfaces.IBiometricHelper){}[0]. Owner: FUN name:componentscan_com_example_core_base_di_BaseModule_single visibility:public modality:FINAL <> (contributed:com.example.core.base.interfaces.BiometricHelper, binding0:com.example.core.base.interfaces.IBiometricHelper) returnType:kotlin.Unit
* Compiler version: 2.4.21
* Output kind: FRAMEWORK
e: java.lang.IllegalStateException: IrSimpleFunctionSymbolImpl is already bound. Signature: org.koin.plugin.hints/componentscan_com_example_core_base_di_BaseModule_single|…
at org.jetbrains.kotlin.ir.symbols.impl.IrSymbolBase.bind(IrSymbolImpl.kt:68)
at org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl.<init>(IrFunctionImpl.kt:70)
at org.jetbrains.kotlin.ir.declarations.IrFactory.createSimpleFunction(IrFactory.kt:212)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.deserializeIrFunction(IrDeclarationDeserializer.kt:596)
at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializerImpl.deserializeDeclaration(IrFileDeserializer.kt:81)
at org.jetbrains.kotlin.backend.common.serialization.BasicIrModuleDeserializer.deserializeReachableDeclarations(BasicIrModuleDeserializer.kt:169)
at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.deserializeAllReachableTopLevels(KotlinIrLinker.kt:176)
at org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator.generateUnboundSymbolsAsDependencies(ExternalDependenciesGenerator.kt:39)
…
BiometricHelper is a @Single class BiometricHelper : IBiometricHelper declared in iosMain of :core:base and picked up by the commonMain @ComponentScan. The linker stops at this first collision; the duplicated hints listed below have the same shape.
What the klibs declare
Counted with klib dump-ir-signatures, "Declared signatures" section, on the iosSimulatorArm64 klibs.
With 1.2.3:
| klib | hints of an included module declared again | identical to the owner's klib |
|---|---|---|
:core:viewmodel |
BaseModule × 14 |
same count as :core:base (14), the reported signature among them |
:core:viewmodel |
ModelModule × 3 |
3 / 3 |
:core:viewmodel |
ResourcesModule × 1 |
1 / 1 |
:core:viewmodel |
DataModule × 71 |
58 / 58 of :core:data's own, plus 13 for :core:network / :core:database types under the DataModule prefix |
:core:data |
NetworkModule × 5 |
5 / 5 |
:core:data |
DatabaseModule × 8 |
8 / 8 |
:core:viewmodel also declares its own 61 ViewmodelModule hints, which are not duplicated anywhere.
With 1.2.1, the same klibs declare no componentscan_* hint at all (:core:base has 3 definition_* hints, :core:data 5, :core:viewmodel none), and the framework links.
Expected
The hints of an included module are declared only in the klib of the Gradle module that owns that module, or the including module emits them under a signature of its own, so that the final link sees each signature once.
Possibly related
- commonMain @Module hints dropped from klib when a platform source set also declares a @Module → false KOIN-D002 on Kotlin/Native #105 (fixed in 1.2.2): changed how commonMain hints are written into native klibs.
- Native test compilation crashes with "Different declarations with the same signatures" on
dsl_singlehints for internal types (regression in 1.2.2) #144 (fixed in 1.2.3): "Different declarations with the same signatures", but for duplicates inside one klib.
Activity
aurimas-zarskis commentedon Nov 9, 2026
Same linker error here without
includes. The duplicated hint isconfiguration_default, coming from@Configurationmodules collected by@KoinApplication.Setup: koin-compiler-plugin 1.2.3 (1.2.1 links fine), koin/koin-annotations 4.2.2, Kotlin 2.4.21,
iosSimulatorArm64framework,compileSafety = falsein every module.Each library module has a module like this:
The app module (exported as the iOS framework) starts Koin with:
All
compileKotlinIosSimulatorArm64tasks pass.linkDebugFrameworkIosSimulatorArm64fails:klib dump-ir-signatures(Declared section) shows that the app klib re-declaresconfiguration_defaultfor every@Configurationmodule it aggregates (34 here). Each of those is alsolib:So this looks like the same relaying problem as above, triggered by
@Configurationaggregation as well asincludes.rlnt commentedon Nov 12, 2026
Running into the same issue.
MattSkala commentedon Nov 13, 2026
Same failure here. I traced it in the plugin source (1.2.3) and am posting what I found in case it shortens the fix.
Our variant
iosSimulatorArm64, static framework withexport(...).includesis involved for the failing hint.:corehas@Module @ComponentScan @Configuration class CoreModule, and the link fails oncomponentscan_…_CoreModule_factory(…).Cause
KoinAnnotationProcessor.relayIncludedModuleHintsandrelayConfigurationHints(both present since 1.2.0) re-declare another Gradle module's hints inside the current module, under the owner's hint name and with the owner's parameter types.relayConfigurationHintsrelaysconfiguration_default(Module)for every non-local@Configurationmodule it can see, then callsrelayIncludedModuleHintsfor it, so that module'scomponentscan_*hints are re-declared too. Every dependent module does this, not only the one that starts Koin.addHintFunctions, relays included.relayedIncludedModuleFqNames,relayedConfigurationModuleFqNames). A comment ingenerateModuleScanHintssays "Cross-Gradle-module duplicates are fine: separate klibs". That holds when one klib is written, but the Native linker binds the signatures of every klib it deserializes into one symbol table, so the second klib declaring the same hint fails with "already bound".Numbers (
klib dump-ir-signatures, Declared section, 23 klibs containing Koin hints)componentscan_*and 18configuration_default.dsl_*,callsite,moduledefandannotationincludeshints are not duplicated in our build.Trigger:
export()Same klibs, only the framework's
export(...)lines changed::core(ownsCoreModule)CoreModule's hintThe framework module itself relays
CoreModule's hints, so exporting any klib that declares the same signature is enough.Notes for a fix
callsite/dsl_single/dsl_factoryhints from different Gradle modules share one IR signature when libraries areexport()ed (1.2.2+) #149), so it would have to be a parameter type or the function name.playground-apps/app-kmp-klib-hintsonly runscompileKotlin*inverify.sh/verify-wide.sh, and its framework has noexport(...). AlinkDebugFramework*step with an exported library that owns a@Configurationmodule would catch this and Native framework link fails with "IrSimpleFunctionSymbolImpl is already bound":callsite/dsl_single/dsl_factoryhints from different Gradle modules share one IR signature when libraries areexport()ed (1.2.2+) #149.No workaround found other than staying on 1.2.1 or dropping
export().