Hi Masahiro, I wondered why my generated linux-image-db Debian packages were so big when I use GCC toolchain instead of LLVM toolchain. It turned out I mixed both... KBUILD_AFLAGS += -Wa,-gdwarf-2 ...together with... DEBUG_CFLAGS += -gdwarf-4 ...when CONFIG_DEBUG_INFO_DWARF4=y is set. So I hacked up something like the following to prevent this: diff --git a/Makefile b/Makefile index 24a4c1b97bb0..e7a8e47b0e34 100644 --- a/Makefile +++ b/Makefile @@ -815,7 +815,11 @@ DEBUG_CFLAGS += -gsplit-dwarf else DEBUG_CFLAGS += -g endif +ifdef CONFIG_DEBUG_INFO_AS_DWARF2 KBUILD_AFLAGS += -Wa,-gdwarf-2 +else ifdef CONFIG_DEBUG_INFO_AS_DWARF4 +KBUILD_AFLAGS += -Wa,-gdwarf-4 +endif endif ifdef CONFIG_DEBUG_INFO_DWARF4 DEBUG_CFLAGS += -gdwarf-4 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 9ad9210d70a1..9f11fc71462c 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -257,10 +257,23 @@ config DEBUG_INFO_SPLIT to know about the .dwo files and include them. Incompatible with older versions of ccache. +config DEBUG_INFO_AS_DWARF2 + bool "Use DWARF-2 assembler option with debuginfo" + depends on $(cc-option,-Wa$(comma)-gdwarf-2) + help + Set DWARF-2 assembler option with debuginfo + +config DEBUG_INFO_AS_DWARF4 + bool "Use DWARF-4 assembler option with debuginfo" + depends on $(cc-option,-Wa$(comma)-gdwarf-4) + help + Set DWARF-4 assembler option with debuginfo + config DEBUG_INFO_DWARF4 bool "Generate dwarf4 debuginfo" depends on DEBUG_INFO depends on $(cc-option,-gdwarf-4) + select DEBUG_INFO_AS_DWARF4 help Generate dwarf4 debug info. This requires recent versions of gcc and gdb. It makes the debug information larger. NOTE: This is on top of Linux v5.8 vanilla. NOTE-2: When building with LLVM toolchain v11.0.0-rc1+ and especially with LLVM_IAS=1 (and LLVM=1) DWARF version 4 is a good choice. For details see below links. Thoughts? Regards, - Sedat - [1] https://github.com/ClangBuiltLinux/linux/issues/1086 [2] https://github.com/ClangBuiltLinux/linux/issues/1086#issuecomment-674503335 [3] https://github.com/ClangBuiltLinux/linux/issues/1086#issuecomment-674517876