Re: [lunn:v6.3-rc2-net-next-phy-leds 5/15] ld.lld: error: undefined symbol: devm_mdiobus_alloc_size

From: Andrew Lunn
Date: Thu Apr 20 2023 - 09:07:35 EST


On Thu, Apr 20, 2023 at 08:31:17AM +0200, Arnd Bergmann wrote:
> On Fri, Mar 24, 2023, at 12:36, kernel test robot wrote:
> >>> ld.lld: error: undefined symbol: devm_mdiobus_alloc_size
> > >>> referenced by phy.h:458 (include/linux/phy.h:458)
> > >>>
> > drivers/net/ethernet/microchip/lan743x_main.o:(lan743x_pcidev_probe) in
> > archive vmlinux.a
> > >>> referenced by phy.h:458 (include/linux/phy.h:458)
> > >>> drivers/net/ethernet/ni/nixge.o:(nixge_probe) in
> > archive vmlinux.a
> >
> > Kconfig warnings: (for reference only)
> > WARNING: unmet direct dependencies detected for PHYLIB
>
> It looks like this has hit linux-next now, I'm seeing the same problem in
> my own randconfig builds after Andrew's 01e5b728e9e4 ("net: phy: Add a
> binding for PHY LEDs").

Hi Arnd

I tried to fix this with:

commit 37f9b2a6c086bb28487a0682b8098f907861c4a1
Author: Andrew Lunn <andrew@xxxxxxx>
Date: Thu Mar 30 20:13:29 2023 -0500

net: ethernet: Add missing depends on MDIO_DEVRES

A number of MDIO drivers make use of devm_mdiobus_alloc_size(). This
is only available when CONFIG_MDIO_DEVRES is enabled. Add missing
depends or selects, depending on if there are circular dependencies or
not. This avoids linker errors, especially for randconfig builds.

All the failures i've seen have CONFIG_MDIO_DEVRES set to disabled. So
i added either depends on, or select to the drivers which use it. I
missed the LAN743x.

> The problem here is that both PHYLIB and LEDS_CLASS are user-visible
> tristate symbols that are referenced from other Kconfig symbols with
> both 'depends on' and 'select'. Having the two interact introduces a
> number of ways that lead to circular dependencies.

I was getting circular dependencies with first versions of the above
patch. I initially tried depends on everywhere, and then had to drop
back to select for a few cases.

> It might be ok to use 'select LEDS_CLASS' from PHYLIB, but I have not
> tried that yet and I expect this will result in other build failures.
>
> A better solution would be to change all drivers that currently use
> 'select PHYLIB' to 'depends on PHYLIB' and have PHYLIB itself
> 'default ETHERNET' to avoid most of the regressions, but doing this
> for 6.4 is a bit risky and can cause other problems.

For 6.4, will adding more depend on/select MDIO_DEVRES help? That
should be low risk.

Thanks
Andrew