From: Masahiro Yamada <masahiroy@kernel.org>
To: Nicolas Schier <nicolas@fjasle.eu>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arch@vger.kernel.org,
Nick Desaulniers <ndesaulniers@google.com>,
Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH v3 5/7] kbuild: unify two modpost invocations
Date: Thu, 29 Sep 2022 06:05:15 +0900 [thread overview]
Message-ID: <CAK7LNAQm9CQe26=rgid36KX3JTfwP0zOhZBXCjssj_hOvFePDw@mail.gmail.com> (raw)
In-Reply-To: <YzSnlIChHmKdKFt8@bergen.fjasle.eu>
On Thu, Sep 29, 2022 at 4:59 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Sun, 25 Sep 2022 03:19:13 +0900 Masahiro Yamada wrote:
> > Currently, modpost is executed twice; first for vmlinux, second
> > for modules.
> >
> > This commit merges them.
> >
> > Current build flow
> > ==================
> >
> > 1) build obj-y and obj-m objects
> > 2) link vmlinux.o
> > 3) modpost for vmlinux
> > 4) link vmlinux
> > 5) modpost for modules
> > 6) link modules (*.ko)
> >
> > The build steps 1) through 6) are serialized, that is, modules are
> > built after vmlinux. You do not get benefits of parallel builds when
> > scripts/link-vmlinux.sh is being run.
> >
> > New build flow
> > ==============
> >
> > 1) build obj-y and obj-m objects
> > 2) link vmlinux.o
> > 3) modpost for vmlinux and modules
> > 4a) link vmlinux
> > 4b) link modules (*.ko)
> >
> > In the new build flow, modpost is invoked just once.
> >
> > vmlinux and modules are built in parallel. One exception is
> > CONFIG_DEBUG_INFO_BTF_MODULES=y, where modules depend on vmlinux.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> > (no changes since v1)
> >
> > Makefile | 30 ++++++++++---
> > scripts/Makefile.modfinal | 2 +-
> > scripts/Makefile.modpost | 93 ++++++++++++---------------------------
> > scripts/link-vmlinux.sh | 3 --
> > 4 files changed, 53 insertions(+), 75 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index b5dfb54b1993..cf9d7b1d8c14 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1152,7 +1152,7 @@ cmd_link-vmlinux = \
> > $(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \
> > $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
> >
> > -vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
> > +vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) modpost FORCE
> > +$(call if_changed_dep,link-vmlinux)
> >
> > targets := vmlinux
> > @@ -1428,7 +1428,13 @@ endif
> > # Build modules
> > #
> >
> > -modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_prepare
> > +# *.ko are usually independent of vmlinux, but CONFIG_DEBUG_INFOBTF_MODULES
> > +# is an exception.
> > +ifdef CONFIG_DEBUG_INFO_BTF_MODULES
> > +modules: vmlinux
> > +endif
> > +
> > +modules: modules_prepare
> >
> > # Target to prepare building external modules
> > modules_prepare: prepare
> > @@ -1741,8 +1747,12 @@ ifdef CONFIG_MODULES
> > $(MODORDER): $(build-dir)
> > @:
> >
> > -modules: modules_check
> > - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
> > +# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
> > +# This is solely useful to speed up test compiles.
> > +modules: modpost
> > +ifneq ($(KBUILD_MODPOST_NOFINAL),1)
> > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal
> > +endif
> >
> > PHONY += modules_check
> > modules_check: $(MODORDER)
> > @@ -1773,6 +1783,11 @@ KBUILD_MODULES :=
> >
> > endif # CONFIG_MODULES
> >
> > +PHONY += modpost
> > +modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
> > + $(if $(KBUILD_MODULES), modules_check)
> > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
> > +
> > # Single targets
> > # ---------------------------------------------------------------------------
> > # To build individual files in subdirectories, you can do like this:
> > @@ -1792,16 +1807,19 @@ single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
> > single-no-ko := $(filter-out $(single-ko), $(MAKECMDGOALS)) \
> > $(foreach x, o mod, $(patsubst %.ko, %.$x, $(single-ko)))
> >
> > -$(single-ko): single_modpost
> > +$(single-ko): single_modules
> > @:
> > $(single-no-ko): $(build-dir)
> > @:
> >
> > # Remove MODORDER when done because it is not the real one.
> > PHONY += single_modpost
>
> PHONY += single_modules
Thank you for your close review!
I will fix it locally.
>
> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
>
--
Best Regards
Masahiro Yamada
next prev parent reply other threads:[~2022-09-28 21:16 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-24 18:19 [PATCH v3 0/7] kbuild: various cleanups Masahiro Yamada
2022-09-24 18:19 ` [PATCH v3 1/7] kbuild: hard-code KBUILD_ALLDIRS in scripts/Makefile.package Masahiro Yamada
2022-09-28 19:09 ` Nicolas Schier
2022-09-24 18:19 ` [PATCH v3 2/7] kbuild: list sub-directories in ./Kbuild Masahiro Yamada
2022-09-24 19:37 ` kernel test robot
2022-09-24 20:27 ` kernel test robot
2022-09-25 0:28 ` Masahiro Yamada
2022-09-26 21:06 ` Nick Desaulniers
2022-09-28 8:32 ` Masahiro Yamada
2022-09-28 19:30 ` Nicolas Schier
2022-09-24 18:19 ` [PATCH v3 3/7] kbuild: move .vmlinux.objs rule to Makefile.modpost Masahiro Yamada
2022-09-28 19:35 ` Nicolas Schier
2022-09-24 18:19 ` [PATCH v3 4/7] kbuild: move vmlinux.o rule to the top Makefile Masahiro Yamada
2022-09-28 19:37 ` Nicolas Schier
2022-09-24 18:19 ` [PATCH v3 5/7] kbuild: unify two modpost invocations Masahiro Yamada
2022-09-28 19:59 ` Nicolas Schier
2022-09-28 21:05 ` Masahiro Yamada [this message]
2022-09-24 18:19 ` [PATCH v3 6/7] kbuild: use obj-y instead extra-y for objects placed at the head Masahiro Yamada
2022-09-28 20:15 ` Nicolas Schier
2022-10-24 18:24 ` Jiri Slaby
2022-10-25 12:26 ` Michael Matz
2022-10-26 8:35 ` Jiri Slaby
2022-10-26 11:20 ` Ard Biesheuvel
2022-10-26 16:29 ` Masahiro Yamada
2022-10-26 17:09 ` Michael Matz
2022-09-24 18:19 ` [PATCH v3 7/7] kbuild: remove head-y syntax Masahiro Yamada
2022-09-29 15:21 ` Nicolas Schier
2022-10-18 8:16 ` Jiri Slaby
2022-10-18 9:12 ` Masahiro Yamada
2022-09-26 21:39 ` [PATCH v3 0/7] kbuild: various cleanups Nick Desaulniers
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='CAK7LNAQm9CQe26=rgid36KX3JTfwP0zOhZBXCjssj_hOvFePDw@mail.gmail.com' \
--to=masahiroy@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--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 NNTP newsgroup(s).