Linux-KBuild Archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Nicolas Schier <nicolas@fjasle.eu>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] kbuild: use $(src) instead of $(srctree)/$(src) for source directory
Date: Sat, 20 Apr 2024 17:56:47 +0900	[thread overview]
Message-ID: <CAK7LNATQBZyKArGAO9GyjiN26cUgjmxaczStxsJG-Q0b7RW+Yg@mail.gmail.com> (raw)
In-Reply-To: <ZiKJNrei7zUVaLkb@bergen.fjasle.eu>

On Sat, Apr 20, 2024 at 12:09 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Tue 16 Apr 2024 21:18:38 GMT, Masahiro Yamada wrote:
> > Kbuild conventionally uses $(obj)/ for generated files, and $(src)/ for
> > checked-in source files. It is merely a convention without any functional
> > difference. In fact, $(obj) and $(src) are exactly the same, as defined
> > in scripts/Makefile.build:
> >
> >     src := $(obj)
> >
> > When the kernel is built in a separate output directory, $(src) does
> > not match the directory in the source tree. It still works because the
> > top Makefile sets VPATH to $(srctree). However, VPATH does not cover
> > all cases. There are many places where the exact path to the source
> > directory is needed. For example, when adding a header search path for
> > local headers, it is typical to pass -I$(srctree)/$(src) to the compiler.
> >
> > However, it introduces inconsistency between upstream Makefiles and
> > downstream Makefiles; when the source directory path is needed,
> > $(srctree)/$(src) is used in the upstream kernel, while $(src) is used
> > in external modules.
> >
> > To resolve the distortion, this commit changes the semantics of $(src)
> > so that it always points to the directory in the source tree.
> >
> > Going forward, the variables used in Makefiles will work as follows:
> >
> >   $(obj)     - directory in the object tree
> >   $(src)     - directory in the source tree  (changed by this commit!)
> >   $(objtree) - the top of the kernel object tree
> >   $(srctree) - the top of the kernel source tree
> >
> > This is a tweewide Makefile conversion for replacing $(srctree)/$(src)
> > with $(src).
>
> tweewide -> treewide
>
> [...]
> > diff --git a/drivers/Makefile b/drivers/Makefile
> > index 3bf5cab4b451..fe9ceb0d2288 100644
> > --- a/drivers/Makefile
> > +++ b/drivers/Makefile
> > @@ -6,11 +6,6 @@
> >  # Rewritten to use lists instead of if-statements.
> >  #
> >
> > -# Some driver Makefiles miss $(srctree)/ for include directive.
> > -ifdef building_out_of_srctree
> > -MAKEFLAGS += --include-dir=$(srctree)
> > -endif
> > -
>
> Ah, it's nice to get rid of this.
>
> >  obj-y                                += cache/
> >  obj-y                                += irqchip/
> >  obj-y                                += bus/
> [...]
> > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> > index 3179747cbd2c..c53d2f168801 100644
> > --- a/scripts/Makefile.lib
> > +++ b/scripts/Makefile.lib
> > @@ -209,13 +209,13 @@ _c_flags += $(if $(patsubst n%,, \
> >       -D__KCSAN_INSTRUMENT_BARRIERS__)
> >  endif
> >
> > -# $(srctree)/$(src) for including checkin headers from generated source files
> > -# $(objtree)/$(obj) for including generated headers from checkin source files
> > +# $(src) for including checkin headers from generated source files
> > +# $(obj) for including generated headers from checkin source files
>
> this is a funny criss-cross of words; but might the following be more
> accurate?
>
> # $(src) for including headers from checked-in source files
> # $(obj) for including generated headers



These are added only when building_out_of_srctree is defined.

When the kernel is built in-tree,
the include directive with the double-quote form
should work without the header inclusion path.



Anyway, this does not seem to be a good idea.
I want to get rid of these entirely.




>
>
>
> Anyway, thanks for the patch.  I think it is quite a good way forward!
>
> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>



-- 
Best Regards
Masahiro Yamada

      reply	other threads:[~2024-04-20  8:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 12:18 [PATCH 0/4] kbuild: replace $(srctree)/$(src) with $(src) in Makefiles Masahiro Yamada
2024-04-16 12:18 ` [PATCH 1/4] arch: use $(obj)/ instead of $(src)/ for preprocessed linker scripts Masahiro Yamada
2024-04-19 14:59   ` Nicolas Schier
2024-04-16 12:18 ` [PATCH 2/4] Makefile: remove some unnecessary header include paths Masahiro Yamada
2024-04-19 15:07   ` Nicolas Schier
2024-04-20  7:46     ` Masahiro Yamada
2024-04-16 12:18 ` [PATCH 3/4] kbuild: use $(obj)/ instead of $(src)/ for pattern rules for %.[cS] Masahiro Yamada
2024-04-19 15:09   ` Nicolas Schier
2024-04-16 12:18 ` [PATCH 4/4] kbuild: use $(src) instead of $(srctree)/$(src) for source directory Masahiro Yamada
2024-04-16 22:45   ` kernel test robot
2024-04-17  4:19   ` kernel test robot
2024-04-18 13:43   ` Rob Herring
2024-04-19 15:09   ` Nicolas Schier
2024-04-20  8:56     ` Masahiro Yamada [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=CAK7LNATQBZyKArGAO9GyjiN26cUgjmxaczStxsJG-Q0b7RW+Yg@mail.gmail.com \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas@fjasle.eu \
    /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).