Re: [PATCH v3 5/7] kbuild: unify two modpost invocations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 29, 2022 at 4:59 AM Nicolas Schier <nicolas@xxxxxxxxx> 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@xxxxxxxxxx>
> > ---
> >
> > (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@xxxxxxxxx>
>

-- 
Best Regards
Masahiro Yamada



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux