Rust for Linux List
 help / color / mirror / Atom feed
From: Nicolas Schier <n.schier@avm.de>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, Miguel Ojeda <ojeda@kernel.org>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH 00/23] kbuild: support building external modules in a separate build directory
Date: Fri, 20 Sep 2024 15:41:20 +0200	[thread overview]
Message-ID: <Zu17gH-A1rAAIS_-@l-nschier-nb> (raw)
In-Reply-To: <CAK7LNAS7D_d+Kz5+rk3OuN0StY=d3iOOa4Un12HYyF4w89LbTQ@mail.gmail.com>

On Fri, Sep 20, 2024 at 09:58:47PM +0900, Masahiro Yamada wrote:
> On Fri, Sep 20, 2024 at 7:39 PM Nicolas Schier <n.schier@avm.de> wrote:
> >
> > On Tue, Sep 17, 2024 at 11:16:28PM +0900, Masahiro Yamada wrote:
> > >
> > > There has been a long-standing request to support building external
> > > modules in a separate build directory.
> >
> > Thanks a lot, you are making several of my colleages very happy with
> > your patch set!
> >
> > > The first half is cleanups of documents and Makefiles.
> > >
> > > The last part adds KBUILD_EXTMOD_OUTPUT (MO=).
> > > This is too big changes, and too late for the current MW.
> > > (I did not test kselftest at all.)
> > > I hope people test this and may uncover some issues.
> >
> > I'm not through all the patches in detail yet, just one observation beforehand:
> >
> >     $ make KBUILD_OUTPUT=build allnoconfig
> >     $ ./scripts/config --file build/.config --enable modules --enable accessibility
> >     $ make KBUILD_OUTPUT=build olddefconfig
> >     $ make KBUILD_OUTPUT=build
> >     $ make KBUILD_OUTPUT=build CONFIG_SPEAKUP=m MO=/tmp/build M=~+/drivers/accessibility/speakup modules
> >     /home/nschier/src/kbuild-review/drivers/accessibility/speakup/genmap.c:23:10: fatal error: mapdata.h: No such file or directory
> >        23 | #include "mapdata.h"
> >           |          ^~~~~~~~~~~
> >     compilation terminated.
> >     make[3]: *** [/home/nschier/src/kbuild-review/scripts/Makefile.host:133: genmap.o] Error 1
> >     make[3]: *** Waiting for unfinished jobs....
> >     make[2]: *** [/home/nschier/src/kbuild-review/Makefile:1971: .] Error 2
> >     make[1]: *** [/home/nschier/src/kbuild-review/Makefile:251: __sub-make] Error 2
> >     make: *** [Makefile:251: __sub-make] Error 2
> >     [exit code 2]
> >
> > If I add "EXTRA_CFLAGS=-I${MO} and EXTRA_HOSTCFLAGS=-I${MO}" to the module
> > build command, it works as expected.
> >
> > Patching this into kbuild works for me, too, but I haven't checked whether it
> > breaks some other scenarios:
> >
> > diff --git a/scripts/Makefile.host b/scripts/Makefile.host
> > index e01c13a588dd..056c7da2776f 100644
> > --- a/scripts/Makefile.host
> > +++ b/scripts/Makefile.host
> > @@ -97,10 +97,13 @@ hostrust_flags = --out-dir $(dir $@) --emit=dep-info=$(depfile) \
> >                   $(HOSTRUSTFLAGS_$(target-stem))
> >
> >  # $(objtree)/$(obj) for including generated headers from checkin source files
> > -ifeq ($(KBUILD_EXTMOD),)
> >  ifdef building_out_of_srctree
> > +ifeq ($(KBUILD_EXTMOD),)
> >  hostc_flags   += -I $(objtree)/$(obj)
> >  hostcxx_flags += -I $(objtree)/$(obj)
> > +else
> > +hostc_flags   += -I $(CURDIR)
> > +hostcxx_flags   += -I $(CURDIR)
> >  endif
> >  endif
> >
> > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> > index 1bdd77f42289..428a9eb74381 100644
> > --- a/scripts/Makefile.lib
> > +++ b/scripts/Makefile.lib
> > @@ -190,11 +190,15 @@ endif
> >
> >  # $(src) for including checkin headers from generated source files
> >  # $(obj) for including generated headers from checkin source files
> > -ifeq ($(KBUILD_EXTMOD),)
> >  ifdef building_out_of_srctree
> > +ifeq ($(KBUILD_EXTMOD),)
> >  _c_flags   += $(addprefix -I, $(src) $(obj))
> >  _a_flags   += $(addprefix -I, $(src) $(obj))
> >  _cpp_flags += $(addprefix -I, $(src) $(obj))
> > +else
> > +_c_flags   += $(addprefix -I, $(src) $(obj) $(CURDIR))
> > +_a_flags   += $(addprefix -I, $(src) $(obj) $(CURDIR))
> > +_cpp_flags += $(addprefix -I, $(src) $(obj) $(CURDIR))
> >  endif
> >  endif
> >
> > Is '-I$(MO)' in CFLAGS/HOSTCFLAGS is something we should support by
> > default, or should this be added to the external module's Makefile by
> > the respective developers themselves?
> >
> > Kind regards,
> > Nicolas
> 
> 
> 
> We can fix it more simply.

Ah, yes.

> diff --git a/scripts/Makefile.host b/scripts/Makefile.host
> index e01c13a588dd..c1dedf646a39 100644
> --- a/scripts/Makefile.host
> +++ b/scripts/Makefile.host
> @@ -96,12 +96,10 @@ hostrust_flags = --out-dir $(dir $@)
> --emit=dep-info=$(depfile) \
>                   $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \
>                   $(HOSTRUSTFLAGS_$(target-stem))
> 
> -# $(objtree)/$(obj) for including generated headers from checkin source files
> -ifeq ($(KBUILD_EXTMOD),)
> +# $(obj) for including generated headers from checkin source files
>  ifdef building_out_of_srctree
> -hostc_flags   += -I $(objtree)/$(obj)
> -hostcxx_flags += -I $(objtree)/$(obj)
> -endif
> +hostc_flags   += -I $(obj)
> +hostcxx_flags += -I $(obj)
>  endif
> 
>  #####
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 1bdd77f42289..d8ce0f59fd17 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -190,13 +190,11 @@ endif
> 
>  # $(src) for including checkin headers from generated source files
>  # $(obj) for including generated headers from checkin source files
> -ifeq ($(KBUILD_EXTMOD),)
>  ifdef building_out_of_srctree
>  _c_flags   += $(addprefix -I, $(src) $(obj))
>  _a_flags   += $(addprefix -I, $(src) $(obj))
>  _cpp_flags += $(addprefix -I, $(src) $(obj))
>  endif
> -endif
> 
>  # If $(is-kernel-object) is 'y', this object will be linked to
> vmlinux or modules
>  is-kernel-object = $(or $(part-of-builtin),$(part-of-module))
> 
> 
> 
> 
> 
> However, I'd rather fix each Makefile
> to add necessary include paths explicitly.

Sure, clearly makes sense.  Especially as the explicit include path
addition is also as simple as:

    HOSTCFLAGS_genmap.o += -I $(obj)
    CFLAGS_main.o += -I $(obj)

Kind regards,
Nicolas

  reply	other threads:[~2024-09-20 13:41 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-17 14:16 [PATCH 00/23] kbuild: support building external modules in a separate build directory Masahiro Yamada
2024-09-17 14:16 ` [PATCH 01/23] kbuild: doc: update the description about Kbuild/Makefile split Masahiro Yamada
2024-09-18 15:35   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 02/23] kbuild: doc: remove description about grepping CONFIG options Masahiro Yamada
2024-09-18 15:35   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 03/23] kbuild: doc: remove outdated description of the limitation on -I usage Masahiro Yamada
2024-09-18 15:38   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 04/23] kbuild: doc: remove the description about shipped files Masahiro Yamada
2024-09-18 16:24   ` Nicolas Schier
2024-09-19 16:53     ` Masahiro Yamada
2024-09-17 14:16 ` [PATCH 05/23] kbuild: doc: describe the -C option precisely for external module builds Masahiro Yamada
2024-09-18 16:44   ` Nicolas Schier
2024-09-18 16:47   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 06/23] kbuild: doc: replace "gcc" in external module description Masahiro Yamada
2024-09-19 11:22   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 07/23] kbuild: remove unnecessary prune of rust/alloc for rustfmt Masahiro Yamada
2024-09-19 11:23   ` Nicolas Schier
2024-09-19 13:46     ` Nicolas Schier
2024-09-30 14:29       ` Miguel Ojeda
2024-09-17 14:16 ` [PATCH 08/23] kbuild: simplify find command " Masahiro Yamada
2024-09-19 13:54   ` Nicolas Schier
2024-09-19 13:59     ` Masahiro Yamada
2024-09-30 18:37   ` Miguel Ojeda
2024-10-01  2:18     ` Masahiro Yamada
2024-10-01  5:45       ` Miguel Ojeda
2024-09-17 14:16 ` [PATCH 09/23] speakup: use SPKDIR=$(src) to specify the source directory Masahiro Yamada
2024-10-03 18:25   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 10/23] kbuild: refactor the check for missing config files Masahiro Yamada
2024-09-25 14:04   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 11/23] kbuild: check the presence of include/generated/rustc_cfg Masahiro Yamada
2024-09-25 14:10   ` Nicolas Schier
2024-09-30 14:37   ` Miguel Ojeda
2024-09-17 14:16 ` [PATCH 12/23] scripts/nsdeps: use VPATH as src_prefix Masahiro Yamada
2024-09-25 14:18   ` Nicolas Schier
2024-09-26  7:30     ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 13/23] kbuild: replace two $(abs_objtree) with $(CURDIR) in top Makefile Masahiro Yamada
2024-09-25 14:27   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 14/23] kbuild: add $(objtree)/ prefix to some in-kernel build artifacts Masahiro Yamada
2024-09-26  7:50   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 15/23] kbuild: rename abs_objtree to abs_output Masahiro Yamada
2024-09-26  7:51   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 16/23] kbuild: use 'output' variable to create the output directory Masahiro Yamada
2024-09-26  7:54   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 17/23] kbuild: build external modules in their directory Masahiro Yamada
2024-10-03 18:41   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 18/23] kbuild: remove extmod_prefix, MODORDER, MODULES_NSDEPS variables Masahiro Yamada
2024-10-03 18:47   ` Nicolas Schier
2024-11-10  1:36     ` Masahiro Yamada
2024-09-17 14:16 ` [PATCH 19/23] kbuild: support building external modules in a separate build directory Masahiro Yamada
2024-10-03 19:47   ` Nicolas Schier
2024-10-04 19:45     ` Nicolas Schier
2024-11-10  1:36       ` Masahiro Yamada
2024-11-10  1:36     ` Masahiro Yamada
2024-09-17 14:16 ` [PATCH 20/23] kbuild: support -fmacro-prefix-map for external modules Masahiro Yamada
2024-10-04 18:51   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 21/23] kbuild: use absolute path in the generated wrapper Makefile Masahiro Yamada
2024-10-04 19:02   ` Nicolas Schier
2024-11-29 23:31   ` Caleb Connolly
2024-11-30  9:19     ` Masahiro Yamada
2024-09-17 14:16 ` [PATCH 22/23] kbuild: make wrapper Makefile more convenient for external modules Masahiro Yamada
2024-10-04 19:46   ` Nicolas Schier
2024-09-17 14:16 ` [PATCH 23/23] kbuild: allow to start building external module in any directory Masahiro Yamada
2024-10-04 20:05   ` Nicolas Schier
2024-09-20 10:39 ` [PATCH 00/23] kbuild: support building external modules in a separate build directory Nicolas Schier
2024-09-20 12:58   ` Masahiro Yamada
2024-09-20 13:41     ` Nicolas Schier [this message]
2024-09-28  6:50 ` Masahiro Yamada
2024-09-30 14:28   ` Miguel Ojeda
2024-10-04 20:16 ` Nicolas Schier

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=Zu17gH-A1rAAIS_-@l-nschier-nb \
    --to=n.schier@avm.de \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.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