Re: [bpf-next PATCH v2 4/4] kbuild: refactor module BTF rule
From: Andrii Nakryiko
Date: Fri Oct 20 2023 - 16:52:18 EST
On Fri, Oct 20, 2023 at 12:03 AM Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote:
>
> On Fri, Oct 20, 2023 at 7:55 AM Andrii Nakryiko
> <andrii.nakryiko@xxxxxxxxx> wrote:
> >
> > On Thu, Oct 19, 2023 at 1:15 AM Jiri Olsa <olsajiri@xxxxxxxxx> wrote:
> > >
> > > On Thu, Oct 19, 2023 at 12:19:50AM +0900, Masahiro Yamada wrote:
> > > > newer_prereqs_except and if_changed_except are ugly hacks of the
> > > > newer-prereqs and if_changed in scripts/Kbuild.include.
> > > >
> > > > Remove.
> > > >
> > > > Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> > > > ---
> > > >
> > > > Changes in v2:
> > > > - Fix if_changed_except to if_changed
> > > >
> > > > scripts/Makefile.modfinal | 25 ++++++-------------------
> > > > 1 file changed, 6 insertions(+), 19 deletions(-)
> > > >
> > > > diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal
> > > > index 9fd7a26e4fe9..fc07854bb7b9 100644
> > > > --- a/scripts/Makefile.modfinal
> > > > +++ b/scripts/Makefile.modfinal
> > > > @@ -19,6 +19,9 @@ vmlinux :=
> > > > ifdef CONFIG_DEBUG_INFO_BTF_MODULES
> > > > ifneq ($(wildcard vmlinux),)
> > > > vmlinux := vmlinux
> > > > +cmd_btf = ; \
> > > > + LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_FLAGS) --btf_base vmlinux $@; \
> > > > + $(RESOLVE_BTFIDS) -b vmlinux $@
> > > > else
> > > > $(warning Skipping BTF generation due to unavailability of vmlinux)
> > > > endif
> > > > @@ -41,27 +44,11 @@ quiet_cmd_ld_ko_o = LD [M] $@
> > > > cmd_ld_ko_o += \
> > > > $(LD) -r $(KBUILD_LDFLAGS) \
> > > > $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
> > > > - -T scripts/module.lds -o $@ $(filter %.o, $^)
> > > > + -T scripts/module.lds -o $@ $(filter %.o, $^) \
> > > > + $(cmd_btf)
> > > >
> > > > -quiet_cmd_btf_ko = BTF [M] $@
> > >
> > > nit not sure it's intentional but we no longer display 'BTF [M] ...ko' lines,
> > > I don't mind not displaying that, but we should mention that in changelog
> > >
> >
> > Thanks for spotting this! I think those messages are useful and
> > important to keep. Masahiro, is it possible to preserve them?
>
>
>
> No, I do not think so.
>
That's too bad, I think it's a useful one.
> Your code is wrong.
>
Could be, but note the comment you are removing:
# Re-generate module BTFs if either module's .ko or vmlinux changed
BTF has to be re-generated not just when module .ko is regenerated,
but also when the vmlinux image itself changes.
I don't see where this is done with your changes. Can you please point
it out explicitly?
>
> To clarify this is a fix,
> I will replace the commit as follows:
>
>
>
>
> ------------------->8----------------------
> kbuild: detect btf command change for modules
>
> Currently, the command change in cmd_btf_ko does not cause to rebuild
> the modules because it is not passed to if_changed.
>
> Pass everything to if_change so that the btf command is also recorded
> in the .*.cmd files. This removes the hacky newer_prereqs_except and
> if_changed_except macros too.
> ------------------->8----------------------
>
>
>
>
> --
> Best Regards
>
> Masahiro Yamada