kbuild: Fix TRIM_UNUSED_KSYMS with LTO_CLANG
authorSami Tolvanen <samitolvanen@google.com>
Mon, 16 Aug 2021 18:05:19 +0000 (11:05 -0700)
committerMasahiro Yamada <masahiroy@kernel.org>
Thu, 2 Sep 2021 23:12:39 +0000 (08:12 +0900)
commit850ded46c64299f04d15e39caaba21963fb966f8
tree782ee2114059886c099257096c2ede2623ad0b1e
parent7d73c3e9c51400d3e0e755488050804e4d44737a
kbuild: Fix TRIM_UNUSED_KSYMS with LTO_CLANG

With CONFIG_LTO_CLANG, we currently link modules into native
code just before modpost, which means with TRIM_UNUSED_KSYMS
enabled, we still look at the LLVM bitcode in the .o files when
generating the list of used symbols. As the bitcode doesn't
yet have calls to compiler intrinsics and llvm-nm doesn't see
function references that only exist in function-level inline
assembly, we currently need a whitelist for TRIM_UNUSED_KSYMS to
work with LTO.

This change moves module LTO linking to happen earlier, and
thus avoids the issue with LLVM bitcode and TRIM_UNUSED_KSYMS
entirely, allowing us to also drop the whitelist from
gen_autoksyms.sh.

Link: https://github.com/ClangBuiltLinux/linux/issues/1369
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Alexander Lobakin <alobakin@pm.me>
Tested-by: Alexander Lobakin <alobakin@pm.me>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/Makefile.build
scripts/Makefile.lib
scripts/Makefile.modfinal
scripts/Makefile.modpost
scripts/gen_autoksyms.sh