Re: [PATCH v2 2/2] kbuild: warn objects shared among multiple modules
From: Masahiro Yamada
Date: Sat Nov 19 2022 - 01:10:50 EST
On Sat, Nov 19, 2022 at 6:36 AM Alexander Lobakin <alobakin@xxxxx> wrote:
>
> From: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> Date: Sat, 19 Nov 2022 04:15:51 +0900
>
> > If an object is shared among multiple modules, amd some of them are
> > configured as 'm', but the others as 'y', the shared object is built
> > as modular, then linked to the modules and vmlinux. This is a potential
> > issue because the expected CFLAGS are different between modules and
> > builtins.
> >
> > Commit 637a642f5ca5 ("zstd: Fixing mixed module-builtin objects")
> > reported that this could be even more fatal in some cases such as
> > Clang LTO.
> >
> > That commit fixed lib/zlib/zstd_{compress,decompress}, but there are
> > still more instances of breakage.
> >
> > This commit adds a W=1 warning for shared objects, so that the kbuild
> > test robot, which provides build tests with W=1, will avoid a new
> > breakage slipping in.
> >
> > Quick compile tests on v6.1-rc4 detected the following:
>
> For the series:
>
> Reviewed-and-tested-by: Alexander Lobakin <alobakin@xxxxx>
>
> [...]
>
> > Once all the warnings are fixed, it can become an error irrespective of
> > W= option.
>
> BTW I've fixed most of these (the ones that get build on typical
> x86_64 distroconfig) during my local tests, basing off your WIP
> tree. I could send a series if you wish.
Yes, thanks for the help.
>
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> > ---
> >
> > Changes in v2:
> > - Add drivers/block/rnbd/Makefile for commit log
> >
> > scripts/Makefile.build | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> > index 37cf88d076e8..799df12b53f3 100644
> > --- a/scripts/Makefile.build
> > +++ b/scripts/Makefile.build
> > @@ -222,6 +222,10 @@ endif
> >
> > cmd_check_local_export = $(srctree)/scripts/check-local-export $@
> >
> > +ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
> > +cmd_warn_shared_object = $(if $(word 2, $(modname-multi)),$(warning $(kbuild-file): $*.o is added to multiple modules: $(modname-multi)))
> > +endif
> > +
> > define rule_cc_o_c
> > $(call cmd_and_fixdep,cc_o_c)
> > $(call cmd,gen_ksymdeps)
> > @@ -231,6 +235,7 @@ define rule_cc_o_c
> > $(call cmd,gen_objtooldep)
> > $(call cmd,gen_symversions_c)
> > $(call cmd,record_mcount)
> > + $(call cmd,warn_shared_object)
> > endef
> >
> > define rule_as_o_S
> > @@ -239,6 +244,7 @@ define rule_as_o_S
> > $(call cmd,check_local_export)
> > $(call cmd,gen_objtooldep)
> > $(call cmd,gen_symversions_S)
> > + $(call cmd,warn_shared_object)
> > endef
> >
> > # Built-in and composite module parts
> > --
> > 2.34.1
>
> Thanks,
> Olek
>
--
Best Regards
Masahiro Yamada