[PATCH] [RFC] arm64: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION
Nicolas Pitre
nico at fluxnic.net
Wed Mar 10 21:47:49 GMT 2021
On Wed, 10 Mar 2021, Sedat Dilek wrote:
> The best results on size-reduction of vmlinux I got with Clang-CFI on x86-64.
>
> Clang-LTO and Clang-CFI:
> I was able to build with CONFIG_TRIM_UNUSED_KSYMS=y which needs to add
> a whitelist file or add a whitelist to scripts/gen_autoksyms.sh.
> And boot on bare metal.
> Furthermore, I was able to compile
> CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y with and without
> CONFIG_TRIM_UNUSED_KSYMS=y.
> Every kernel I had CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y does not boot.
> Yes, there is a size reduction with both enabled but not that good as
> with Clang-CFI.
> All testings with several iterations of LLVM/Clang v13-git.
> With CONFIG_TRIM_UNUSED_KSYMS=y I see a 3x-loops of building .version
> and folowing steps - got no answer if this is intended.
Yes it is intended. I explained it here:
https://lkml.org/lkml/2021/3/9/1099
With CONFIG_TRIM_UNUSED_KSYMS some EXPORT_SYMBOL() are removed, which
allows for optimizing away the corresponding code, which in turn opens
the possibility for more EXPORT_SYMBOL() to be removed, etc. The process
eventually converge to a stable build. Normally only 2 passes are needed
to converge, but LTO opens the possibilities for extra passes.
> Means longer build-time.
Oh, absolutely. LTO (at least when I played with it) is slow. Add the
multi-pass from CONFIG_TRIM_UNUSED_KSYMS on top of that and your kernel
build becomes agonizingly slow. This is not something you want when
doing kernel development.
> I did not follow this anymore as both Kconfigs with Clang-LTO consume
> more build-time and the resulting vmlinux is some MiB bigger than with
> Clang-CFI.
That's rather strange. At least with gcc LTO I always obtained smaller
kernels.
Nicolas
More information about the linux-arm-kernel
mailing list