Skip to content

Commit a66049e

Browse files
nickdesaulniersmasahir0y
authored andcommitted
Kbuild: make DWARF version a choice
Adds a default CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT which allows the implicit default version of DWARF emitted by the toolchain to progress over time. Modifies CONFIG_DEBUG_INFO_DWARF4 to be a member of a choice, making it mutually exclusive with CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT. Users may want to select this if they are using a newer toolchain, but have consumers of the DWARF debug info that aren't yet ready for newer DWARF versions' debug info. Does so in a way that's forward compatible with existing configs, and makes adding future versions more straightforward. This patch does not change the current behavior or selection of DWARF version for users upgrading to kernels with this patch. GCC since ~4.8 has defaulted to DWARF v4 implicitly, and GCC 11 has bumped this to v5. Remove the Kconfig help text about DWARF v4 being larger. It's empirically false for the latest toolchains for x86_64 defconfig, has no point of reference (I suspect it was DWARF v2 but that's stil empirically false), and debug info size is not a qualatative measure. Suggested-by: Arvind Sankar <[email protected]> Suggested-by: Fangrui Song <[email protected]> Suggested-by: Jakub Jelinek <[email protected]> Suggested-by: Mark Wielaard <[email protected]> Suggested-by: Masahiro Yamada <[email protected]> Suggested-by: Nathan Chancellor <[email protected]> Tested-by: Sedat Dilek <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 3c4fa46 commit a66049e

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,9 @@ ifneq ($(LLVM_IAS),1)
830830
KBUILD_AFLAGS += -Wa,-gdwarf-2
831831
endif
832832

833-
ifdef CONFIG_DEBUG_INFO_DWARF4
834-
DEBUG_CFLAGS += -gdwarf-4
833+
ifndef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
834+
dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4
835+
DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y)
835836
endif
836837

837838
ifdef CONFIG_DEBUG_INFO_REDUCED

lib/Kconfig.debug

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,33 @@ config DEBUG_INFO_SPLIT
256256
to know about the .dwo files and include them.
257257
Incompatible with older versions of ccache.
258258

259+
choice
260+
prompt "DWARF version"
261+
help
262+
Which version of DWARF debug info to emit.
263+
264+
config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
265+
bool "Rely on the toolchain's implicit default DWARF version"
266+
help
267+
The implicit default version of DWARF debug info produced by a
268+
toolchain changes over time.
269+
270+
This can break consumers of the debug info that haven't upgraded to
271+
support newer revisions, and prevent testing newer versions, but
272+
those should be less common scenarios.
273+
274+
If unsure, say Y.
275+
259276
config DEBUG_INFO_DWARF4
260-
bool "Generate dwarf4 debuginfo"
277+
bool "Generate DWARF Version 4 debuginfo"
261278
help
262-
Generate dwarf4 debug info. This requires recent versions
263-
of gcc and gdb. It makes the debug information larger.
264-
But it significantly improves the success of resolving
265-
variables in gdb on optimized code.
279+
Generate DWARF v4 debug info. This requires gcc 4.5+ and gdb 7.0+.
280+
281+
If you have consumers of DWARF debug info that are not ready for
282+
newer revisions of DWARF, you may wish to choose this or have your
283+
config select this.
284+
285+
endchoice # "DWARF version"
266286

267287
config DEBUG_INFO_BTF
268288
bool "Generate BTF typeinfo"

0 commit comments

Comments
 (0)