Linux-KBuild Archive mirror
 help / color / mirror / Atom feed
From: Marcos Paulo de Souza <mpdesouza@suse.com>
To: linux-kbuild@vger.kernel.org
Cc: Shuah Khan <skhan@linuxfoundation.org>,
	Joe Lawrence <joe.lawrence@redhat.com>,
	Petr Mladek <pmladek@suse.com>,
	mbenes@suse.com, Masahiro Yamada <masahiroy@kernel.org>
Subject: Out-of-tree module building fails with O= argument
Date: Wed, 14 Feb 2024 11:02:03 -0300	[thread overview]
Message-ID: <951fc31ee754ba86acaa9556e1d28c13075c66a2.camel@suse.com> (raw)

Hello Masahiro and Kbuild ML,

Recently we added out-of-tree module building on kselftests for the
livepatch selftests. Everything worked as expected, but kernel test
robot complained about it[1].

So far, all our tests were being done targeting different options for
kselftests, but we didn't test using the O= option. The interesting
part of it is that this can be easily reproducible with any out-of-tree
module building even on current upstream, like the code below:

$ uname -r
6.8.0-rc4+
$ make
make -C /lib/modules/6.8.0-rc4+/build M=/home/mpdesouza/test-oot
modules
make[1]: Entering directory '/home/mpdesouza/git/linux'
  CC [M]  /home/mpdesouza/test-oot/patch_1.o
  MODPOST /home/mpdesouza/test-oot/Module.symvers
  CC [M]  /home/mpdesouza/test-oot/patch_1.mod.o
  LD [M]  /home/mpdesouza/test-oot/patch_1.ko
  BTF [M] /home/mpdesouza/test-oot/patch_1.ko
make[1]: Leaving directory '/home/mpdesouza/git/linux'

But it fails when using O= argument:
$ make O=/tmp/kout
make -C /lib/modules/6.8.0-rc4+/build M=/home/mpdesouza/test-oot
modules
make[1]: Entering directory '/home/mpdesouza/git/linux'
make[2]: Entering directory '/tmp/kout'
/home/mpdesouza/git/linux/Makefile:733: include/config/auto.conf: No
such file or directory
make[2]: *** [/home/mpdesouza/git/linux/Makefile:240: __sub-make] Error
2
make[2]: Leaving directory '/tmp/kout'
make[1]: *** [Makefile:240: __sub-make] Error 2
make[1]: Leaving directory '/home/mpdesouza/git/linux'
make: *** [Makefile:6: all] Error 2

As I already described on [2], the O= argument (or KBUILD_OUTPUT) makes
the kernel to jump into the directory specified on the variabled, but
running the Makefile on /lib/modules/6.8.0-rc4+/build. The problem is
thattoplevel Makefile on /lib/modules/.../build includes files using
relative paths. In this case, the makefile tries to find
include/config/auto.conf on /tmp/kout, which obviously doesn't exists.

Do you think this can be a bug on Kbuild? Should we ignore O= when
building out-of-tree modules?

Also, as noted[3] by Petr Mladek (CCed here as well), kernel-devel
doesn't include auto.conf, so maybe kernel-devel should be patched as
well?

Thanks in advance,
  Marcos

[1]:
https://lore.kernel.org/oe-kbuild-all/202401300736.GkSZoSrA-lkp@intel.com/
[2]:
https://lore.kernel.org/oe-kbuild-all/fd027fa958a0bc65285a0c6c42e5921e7d28b0ad.camel@suse.com/
[3]: https://lore.kernel.org/oe-kbuild-all/ZbpnBqHUl3pE_3Te@alley/

             reply	other threads:[~2024-02-14 14:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 14:02 Marcos Paulo de Souza [this message]
2024-02-14 20:49 ` Out-of-tree module building fails with O= argument Masahiro Yamada
2024-02-15 13:29   ` Marcos Paulo de Souza

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=951fc31ee754ba86acaa9556e1d28c13075c66a2.camel@suse.com \
    --to=mpdesouza@suse.com \
    --cc=joe.lawrence@redhat.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=mbenes@suse.com \
    --cc=pmladek@suse.com \
    --cc=skhan@linuxfoundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).