Re: [PATCH kbuild] kbuild: add -grecord-gcc-switches to clang build

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 3/29/21 3:52 PM, Nick Desaulniers wrote:
(replying to https://lore.kernel.org/bpf/20210328064121.2062927-1-yhs@xxxxxx/)

Thanks for the patch!

+# gcc emits compilation flags in dwarf DW_AT_producer by default
+# while clang needs explicit flag. Add this flag explicitly.
+ifdef CONFIG_CC_IS_CLANG
+DEBUG_CFLAGS	+= -grecord-gcc-switches
+endif
+

This adds ~5MB/1% to vmlinux of an x86_64 defconfig built with clang. Do we
want to add additional guards for CONFIG_DEBUG_INFO_BTF, so that we don't have
to pay that cost if that config is not set?

Since this patch is mostly motivated to detect whether the kernel is
built with clang lto or not. Let me add the flag only if lto is
enabled. My measurement shows 0.5% increase to thinlto-vmlinux.
The smaller percentage is due to larger .debug_info section
(almost double) for thinlto vs. no lto.

 ifdef CONFIG_LTO_CLANG
 DEBUG_CFLAGS   += -grecord-gcc-switches
 endif

This will make pahole with any clang built kernels, lto or non-lto.

If the maintainer wants further restriction with CONFIG_DEBUG_INFO_BTF,
I can do that in another revision.



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux