From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C59ECC433E0 for ; Sat, 16 Jan 2021 17:55:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F41F2245C for ; Sat, 16 Jan 2021 17:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727708AbhAPRzP (ORCPT ); Sat, 16 Jan 2021 12:55:15 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:44757 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727328AbhAPRzP (ORCPT ); Sat, 16 Jan 2021 12:55:15 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4DJ5KC2LfLz1qrf4; Sat, 16 Jan 2021 18:54:23 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4DJ5KC1X7Wz1tSQn; Sat, 16 Jan 2021 18:54:23 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id GTIdQNdWleqH; Sat, 16 Jan 2021 18:54:21 +0100 (CET) X-Auth-Info: q4PGtmWcEz+TJIq87TKtaqTAN+gpSdtTaxrSUrD/pTA= Received: from [IPv6:::1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sat, 16 Jan 2021 18:54:21 +0100 (CET) Subject: Re: [PATCH net-next V2] net: ks8851: Fix mixed module/builtin build To: Arnd Bergmann Cc: Networking , Andrew Lunn , Arnd Bergmann , Heiner Kallweit , Jakub Kicinski , Lukas Wunner References: <20210116164828.40545-1-marex@denx.de> From: Marek Vasut Message-ID: Date: Sat, 16 Jan 2021 18:54:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 1/16/21 6:04 PM, Arnd Bergmann wrote: > On Sat, Jan 16, 2021 at 5:48 PM Marek Vasut wrote: >> >> 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 >> Cc: Andrew Lunn >> Cc: Arnd Bergmann >> Cc: Heiner Kallweit >> Cc: Jakub Kicinski >> Cc: Lukas Wunner > > 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 ?