From: Marcos Paulo de Souza <mpdesouza@suse.com>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org,
Shuah Khan <skhan@linuxfoundation.org>,
Joe Lawrence <joe.lawrence@redhat.com>,
Petr Mladek <pmladek@suse.com>,
mbenes@suse.com
Subject: Re: Out-of-tree module building fails with O= argument
Date: Thu, 15 Feb 2024 10:29:31 -0300 [thread overview]
Message-ID: <16d1430240ed96b895db40cca1c6c310f056056c.camel@suse.com> (raw)
In-Reply-To: <CAK7LNATJ+=Kd5a=wkHZDzHSEACHfYavUa4GdiSKZh5eSwMG6wA@mail.gmail.com>
On Thu, 2024-02-15 at 05:49 +0900, Masahiro Yamada wrote:
> On Wed, Feb 14, 2024 at 11:02 PM Marcos Paulo de Souza
> <mpdesouza@suse.com> wrote:
> >
> > 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?
>
>
> No.
>
> O= is not meant for the output directory for external modules.
>
> O= is supposed to point to the object tree of the kernel
> (when the kernel was built in the separate output directory)
>
>
Thanks Masahiro. AFAICS, the only way to override/unset a command-line
variable from the sub-make calls is to override it on make invocation,
like:
make -C $(BUILD_PATH) O="" M=$(PWD) modules
So it would need a fix like this for it to work. Am I right?
BTW, I just noticedthe same problem on the bpf module on kselftests,
which is also an out-of-tree module but it's KDIR is the built kernel:
make W=1 O=/tmp/kselftest -C tools/testing/selftests/bpf
make: Entering directory
'/home/mpdesouza/git/linux/tools/testing/selftests/bpf'
EXT-COPY [test_maps]
MOD bpf_testmod.ko
/home/mpdesouza/git/linux/Makefile:733: include/config/auto.conf: No
such file or directory
make[2]: *** [Makefile:240: __sub-make] Error 2
make[1]: *** [Makefile:16: all] Error 2
make: *** [Makefile:233: /tmp/kselftest//bpf_testmod.ko] Error 2
make: Leaving directory
'/home/mpdesouza/git/linux/tools/testing/selftests/bpf'
(This was reproduced on upstream/master branch).
The reproducer from the kernel built robot is the following:
reproduce:
#
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=c4bbe83d27c2446a033cc0381c3fb6be5e8c41c7
git remote add linux-next
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkout c4bbe83d27c2446a033cc0381c3fb6be5e8c41c7
make W=1 O=/tmp/kselftest headers
make W=1 O=/tmp/kselftest -C tools/testing/selftests
make W=1 O=/tmp/kselftest -C tools/testing/selftests/bpf
(retrieved from https://download.01.org/0day-
ci/archive/20240130/202401300736.GkSZoSrA-lkp@intel.com/reproduce
)
Masahiro thanks
Shuah, the problem is already there even without out livepatch changes.
Should the test robot be fixed instead?
>
> > 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/
>
>
>
prev parent reply other threads:[~2024-02-15 13:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-14 14:02 Out-of-tree module building fails with O= argument Marcos Paulo de Souza
2024-02-14 20:49 ` Masahiro Yamada
2024-02-15 13:29 ` Marcos Paulo de Souza [this message]
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=16d1430240ed96b895db40cca1c6c310f056056c.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).