All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sven Peter" <sven@svenpeter.dev>
To: "Arnd Bergmann" <arnd@arndb.de>
Cc: "kernel test robot" <lkp@intel.com>,
	"Linux I2C" <linux-i2c@vger.kernel.org>,
	kbuild-all@lists.01.org,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Wolfram Sang" <wsa-dev@sang-engineering.com>,
	"Hector Martin" <marcan@marcan.st>,
	"Alyssa Rosenzweig" <alyssa@rosenzweig.io>
Subject: Re: powerpc64-linux-ld: drivers/i2c/busses/i2c-pasemi-core.o:undefined reference to `__this_module'
Date: Mon, 06 Dec 2021 21:38:25 +0100	[thread overview]
Message-ID: <3538e879-8548-4727-b397-c385295316c4@www.fastmail.com> (raw)
In-Reply-To: <CAK8P3a2Ag60Dw1mbTsj7XVanT6u8kQW5vqK3hAD-yon1G8qKXw@mail.gmail.com>



On Mon, Dec 6, 2021, at 20:47, Arnd Bergmann wrote:
> On Mon, Dec 6, 2021 at 6:02 PM Sven Peter <sven@svenpeter.dev> wrote:
>> On Mon, Dec 6, 2021, at 11:10, kernel test robot wrote:
>
>> > If you fix the issue, kindly add following tag as appropriate
>> > Reported-by: kernel test robot <lkp@intel.com>
>> >
>> > All error/warnings (new ones prefixed by >>):
>> >
>> >>> powerpc64-linux-ld: warning: orphan section `.stubs' from `drivers/i2c/busses/i2c-pasemi-core.o' being placed in section `.stubs'
>> >>> powerpc64-linux-ld: drivers/i2c/busses/i2c-pasemi-core.o:(.toc+0x0): undefined reference to `__this_module'
>>
>> This seems to be triggered by compiling one of {pci,platform} as a module and the
>> other one as built-in. That setup can only happen with COMPILE_TEST since -pci
>> is otherwise only compiled for powerpc and -platform for arm64.
>>
>> -core.c is only built once with THIS_MODULE expanding to __this_module. That will
>> fail when linking the built-in driver where THIS_MODULE should've been NULL instead.
>>
>> The most simple fix (that also has no chance of breaking anything) is probably to
>> just move
>>
>>   smbus->adapter.owner = THIS_MODULE;
>>
>> from core to both apple.c and pci.c. I'll prepare a patch later this week.
>
> I'd prefer fixing this in a better way, linking an object file into
> both vmlinux and a loadable
> module is not supported at all. 

Make sense, I didn't know that.

> Other options are:
>
> - #include the common .c file from the individual drivers (not great)
> - use Kconfig logic to prevent the broken configuration
> - use Makefile tricks to make both drivers built-in when this happens
> - make the common part a separate loadable module, exporting all the
>   global symbols.
>
> Out of these, I would prefer the last option.

Sure, I'll see when I can spare some time to do that since testing that
is going to be a bit more annoying with my current setup.

Fwiw, I2C_OCTEON and I2C_THUNDERX might have the same issue as well
with i2c-octeon-core.o. It just won't result in the same compile error
because i2c-octeon-core.c doesn't use THIS_MODULE.
It's also nothing that is likely to ever happen since those two drivers
are also never used on the same arch and it should only be possible to
create a broken configuration with COMPILE_TEST as well.



Sven

WARNING: multiple messages have this Message-ID (diff)
From: Sven Peter <sven@svenpeter.dev>
To: kbuild-all@lists.01.org
Subject: Re: powerpc64-linux-ld: drivers/i2c/busses/i2c-pasemi-core.o:undefined reference to `__this_module'
Date: Mon, 06 Dec 2021 21:38:25 +0100	[thread overview]
Message-ID: <3538e879-8548-4727-b397-c385295316c4@www.fastmail.com> (raw)
In-Reply-To: <CAK8P3a2Ag60Dw1mbTsj7XVanT6u8kQW5vqK3hAD-yon1G8qKXw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2380 bytes --]



On Mon, Dec 6, 2021, at 20:47, Arnd Bergmann wrote:
> On Mon, Dec 6, 2021 at 6:02 PM Sven Peter <sven@svenpeter.dev> wrote:
>> On Mon, Dec 6, 2021, at 11:10, kernel test robot wrote:
>
>> > If you fix the issue, kindly add following tag as appropriate
>> > Reported-by: kernel test robot <lkp@intel.com>
>> >
>> > All error/warnings (new ones prefixed by >>):
>> >
>> >>> powerpc64-linux-ld: warning: orphan section `.stubs' from `drivers/i2c/busses/i2c-pasemi-core.o' being placed in section `.stubs'
>> >>> powerpc64-linux-ld: drivers/i2c/busses/i2c-pasemi-core.o:(.toc+0x0): undefined reference to `__this_module'
>>
>> This seems to be triggered by compiling one of {pci,platform} as a module and the
>> other one as built-in. That setup can only happen with COMPILE_TEST since -pci
>> is otherwise only compiled for powerpc and -platform for arm64.
>>
>> -core.c is only built once with THIS_MODULE expanding to __this_module. That will
>> fail when linking the built-in driver where THIS_MODULE should've been NULL instead.
>>
>> The most simple fix (that also has no chance of breaking anything) is probably to
>> just move
>>
>>   smbus->adapter.owner = THIS_MODULE;
>>
>> from core to both apple.c and pci.c. I'll prepare a patch later this week.
>
> I'd prefer fixing this in a better way, linking an object file into
> both vmlinux and a loadable
> module is not supported at all. 

Make sense, I didn't know that.

> Other options are:
>
> - #include the common .c file from the individual drivers (not great)
> - use Kconfig logic to prevent the broken configuration
> - use Makefile tricks to make both drivers built-in when this happens
> - make the common part a separate loadable module, exporting all the
>   global symbols.
>
> Out of these, I would prefer the last option.

Sure, I'll see when I can spare some time to do that since testing that
is going to be a bit more annoying with my current setup.

Fwiw, I2C_OCTEON and I2C_THUNDERX might have the same issue as well
with i2c-octeon-core.o. It just won't result in the same compile error
because i2c-octeon-core.c doesn't use THIS_MODULE.
It's also nothing that is likely to ever happen since those two drivers
are also never used on the same arch and it should only be possible to
create a broken configuration with COMPILE_TEST as well.



Sven

  reply	other threads:[~2021-12-06 20:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06 10:10 powerpc64-linux-ld: drivers/i2c/busses/i2c-pasemi-core.o:undefined reference to `__this_module' kernel test robot
2021-12-06 10:10 ` kernel test robot
2021-12-06 17:02 ` Sven Peter
2021-12-06 17:02   ` Sven Peter
2021-12-06 19:47   ` Arnd Bergmann
2021-12-06 19:47     ` Arnd Bergmann
2021-12-06 20:38     ` Sven Peter [this message]
2021-12-06 20:38       ` Sven Peter
2022-02-10  2:43 kernel test robot
2022-02-10  2:43 ` kernel test robot
2022-03-26  7:19 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3538e879-8548-4727-b397-c385295316c4@www.fastmail.com \
    --to=sven@svenpeter.dev \
    --cc=alyssa@rosenzweig.io \
    --cc=arnd@arndb.de \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=marcan@marcan.st \
    --cc=wsa-dev@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.