Re: [PATCH v3] kbuild: add debug level and macro defs options
From: Dmitrii Bundin
Date: Fri Aug 19 2022 - 18:52:22 EST
On Fri, Aug 19, 2022 at 8:42 PM Nick Desaulniers
<ndesaulniers@xxxxxxxxxx> wrote:
>
> Is any of this really necessary?
Consider the case if CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y.
Prior to GCC11/Clang12 -gsplit-dwarf implied -g2. So on newer
compilers with -gsplit-dwarf in use there would be no debug symbols
produced. -gdwarf-4/5 still implies -g2, but in case
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y neither of the options are
set. So it seems like a reasonable choice to provide a debug info
level config that would explicitly set the level without relying on
implicits. The default value of the config is set to -g2 to not change
the build behavior that was before introducing the option. And it
works for both older and newer versions of GCC/Clang in the same way.
The benefits of the -g1 option are indeed questionable except that it
produces an image with ~20% less in size.
> It seems like a great way to bloat
> vmlinux artifacts built with CONFIG_DEBUG_INFO even further.
The defaults were chosen to not change the build behavior that was
before introducing the options. Or did you mean something else?
> The
> above link mentions "when debugging with GDB." In that case, please
> don't add new Kconfigs for these; just set -g3 when
> CONFIG_GDB_SCRIPTS=y.
CONFIG_GDB_SCRIPTS does not necessarily mean that -g3 is wanted, -g2
(default) is usually a reasonable choice. The -g3 option is very
useful when debugging macro-intensive code, but requires much more
disk space to build. I documented it explicitly in the help section of
DEBUG_INFO_LEVEL. GCC and Clang use different options to include macro
definitions so it was handled depending on the compiler used.
Regards
Dmitrii