Messages in this thread | | | From | Sedat Dilek <> | Date | Wed, 10 Mar 2021 22:24:07 +0100 | Subject | Re: [PATCH] [RFC] arm64: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION |
| |
On Wed, Mar 10, 2021 at 10:08 PM Arnd Bergmann <arnd@kernel.org> wrote: > > On Wed, Mar 10, 2021 at 9:50 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > On Mon, Mar 1, 2021 at 10:11 AM Nicholas Piggin <npiggin@gmail.com> wrote: > > > Excerpts from Arnd Bergmann's message of February 27, 2021 7:49 pm: > > > > > masahiro@oscar:~/ref/linux$ echo 'void this_func_is_unused(void) {}' > > >> kernel/cpu.c > > masahiro@oscar:~/ref/linux$ export > > CROSS_COMPILE=/home/masahiro/tools/powerpc-10.1.0/bin/powerpc-linux- > > masahiro@oscar:~/ref/linux$ make ARCH=powerpc defconfig > > masahiro@oscar:~/ref/linux$ ./scripts/config -e EXPERT > > masahiro@oscar:~/ref/linux$ ./scripts/config -e LD_DEAD_CODE_DATA_ELIMINATION > > masahiro@oscar:~/ref/linux$ > > ~/tools/powerpc-10.1.0/bin/powerpc-linux-nm -n vmlinux | grep > > this_func > > c000000000170560 T .this_func_is_unused > > c000000001d8d560 D this_func_is_unused > > masahiro@oscar:~/ref/linux$ grep DEAD_CODE_ .config > > CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y > > CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y > > > > > > If I remember correctly, > > LD_DEAD_CODE_DATA_ELIMINATION dropped unused functions > > when I tried it last time. > > > > > > I also tried arm64 with a HAVE_LD_DEAD_CODE_DATA_ELIMINATION hack. > > The result was the same. > > > > > > > > Am I missing something? > > It's possible that it only works in combination with CLANG_LTO now > because something broke. I definitely saw a reduction in kernel > size when both options are enabled, but did not try a simple test > case like you did. > > Maybe some other reference gets created that prevents the function > from being garbage-collected unless that other option is removed > as well? >
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. Means longer build-time. 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.
If someone is interested in x86-64 I can provide the whitelist files and or (alternatively) changes to scripts/gen_autoksyms.sh. AFAICS I had open a thread for this - damn digital dementia.
- Sedat -
| |