[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yp9f7lKjcCrRUcAD@dev-arch.thelio-3990X>
Date: Tue, 7 Jun 2022 07:25:50 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Jon Hunter <jonathanh@...dia.com>
Cc: Masahiro Yamada <masahiroy@...nel.org>,
linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
Nick Desaulniers <ndesaulniers@...gle.com>,
Nicolas Schier <nicolas@...sle.eu>,
Peter Zijlstra <peterz@...radead.org>,
linux-modules@...r.kernel.org, llvm@...ts.linux.dev,
Ard Biesheuvel <ardb@...nel.org>,
Sami Tolvanen <samitolvanen@...gle.com>,
"linux-tegra@...r.kernel.org" <linux-tegra@...r.kernel.org>
Subject: Re: [PATCH v6 06/10] kbuild: check static EXPORT_SYMBOL* by script
instead of modpost
On Tue, Jun 07, 2022 at 03:22:21PM +0100, Jon Hunter wrote:
>
> On 13/05/2022 12:39, Masahiro Yamada wrote:
> > The 'static' specifier and EXPORT_SYMBOL() are an odd combination.
> >
> > Commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL*
> > functions") tried to detect it, but this check has false negatives.
> >
> > Here is the sample code.
> >
> > Makefile:
> >
> > obj-y += foo1.o foo2.o
> >
> > foo1.c:
> >
> > #include <linux/export.h>
> > static void foo(void) {}
> > EXPORT_SYMBOL(foo);
> >
> > foo2.c:
> >
> > void foo(void) {}
> >
> > foo1.c exports the static symbol 'foo', but modpost cannot catch it
> > because it is fooled by foo2.c, which has a global symbol with the
> > same name.
> >
> > s->is_static is cleared if a global symbol with the same name is found
> > somewhere, but EXPORT_SYMBOL() and the global symbol do not necessarily
> > belong to the same compilation unit.
> >
> > This check should be done per compilation unit, but I do not know how
> > to do it in modpost. modpost runs against vmlinux.o or modules, which
> > merges multiple objects, then forgets their origin.
> >
> > It is true modpost gets access to the lists of all the member objects
> > (.vmlinux.objs and *.mod), but modpost cannot parse individual objects
> > because they may not be ELF but LLVM IR when CONFIG_LTO_CLANG=y.
> >
> > Add a simple bash script to parse the output from ${NM}. This works for
> > CONFIG_LTO_CLANG=y because llvm-nm can dump symbols of LLVM IR files.
> >
> > Revert 15bfc2348d54.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
> > Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>
> > Tested-by: Nathan Chancellor <nathan@...nel.org>
>
>
> One some older build machines this is causing some builds (ARM/ARM64)
> to fail ...
>
> /dvs/git/dirty/git-master_l4t-upstream/kernel/scripts/check-local-export: line 54: wait: pid 48433 is not a child of this shell
> /dvs/git/dirty/git-master_l4t-upstream/kernel/scripts/Makefile.build:250: recipe for target 'scripts/mod/empty.o' failed
> make[2]: *** [scripts/mod/empty.o] Error 127
> make[2]: *** Deleting file 'scripts/mod/empty.o'
> make[2]: *** Waiting for unfinished jobs....
> /dvs/git/dirty/git-master_l4t-upstream/kernel/Makefile:1285: recipe for target 'prepare0' failed
> make[1]: *** [prepare0] Error 2
> make[1]: Leaving directory '/dvs/git/dirty/git-master_l4t-upstream/artifacts/linux/arm64-defconfig-jetson'
> Makefile:228: recipe for target '__sub-make' failed
> make: *** [__sub-make] Error 2
>
> Any ideas?
https://lore.kernel.org/20220607084317.211785-1-masahiroy@kernel.org/
should resolve it if you wanted to give it a test.
Cheers,
Nathan
Powered by blists - more mailing lists