Re: [PATCH net-next V2] net: ks8851: Fix mixed module/builtin build
From: Marek Vasut <marex@denx.de>
Date: 2021-01-16 17:55:16
On 1/16/21 6:04 PM, Arnd Bergmann wrote:
On Sat, Jan 16, 2021 at 5:48 PM Marek Vasut [off-list ref] wrote:quoted
When either the SPI or PAR variant is compiled as module AND the other variant is compiled as built-in, the following build error occurs: arm-linux-gnueabi-ld: drivers/net/ethernet/micrel/ks8851_common.o: in function `ks8851_probe_common': ks8851_common.c:(.text+0x1564): undefined reference to `__this_module' Fix this by passing THIS_MODULE as argument to ks8851_probe_common(), ks8851_register_mdiobus(), and ultimately __mdiobus_register() in the ks8851_common.c. Fixes: ef3631220d2b ("net: ks8851: Register MDIO bus and the internal PHY") Signed-off-by: Marek Vasut <marex@denx.de> Cc: Andrew Lunn <andrew@lunn.ch> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Heiner Kallweit <hkallweit1@gmail.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Lukas Wunner <lukas@wunner.de>I don't really like this version, as it does not actually solve the problem of linking the same object file into both vmlinux and a loadable module, which can have all kinds of side-effects besides that link failure you saw. If you want to avoid exporting all those symbols, a simpler hack would be to '#include "ks8851_common.c" from each of the two files, which then always duplicates the contents (even when both are built-in), but at least builds the file the correct way.
That's the same as V1, isn't it ?