linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v9 0/3] Kbuild: DWARF v5 support
@ 2021-02-05 20:22 Nick Desaulniers
  2021-02-05 20:22 ` [PATCH v9 1/3] vmlinux.lds.h: add DWARF v5 sections Nick Desaulniers
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Nick Desaulniers @ 2021-02-05 20:22 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nathan Chancellor, Andrew Morton, Sedat Dilek, linux-kernel,
	clang-built-linux, linux-kbuild, linux-arch, Jakub Jelinek,
	Fangrui Song, Caroline Tice, Nick Clifton, Yonghong Song,
	Jiri Olsa, Andrii Nakryiko, Arnaldo Carvalho de Melo,
	Arvind Sankar, Chris Murphy, Mark Wielaard, Nick Desaulniers

DWARF v5 is the latest standard of the DWARF debug info format.

DWARF5 wins significantly in terms of size and especially so when mixed
with compression (CONFIG_DEBUG_INFO_COMPRESSED).

Link: http://www.dwarfstd.org/doc/DWARF5.pdf

Patch 1 places the DWARF v5 sections explicitly in the kernel linker
script.
Patch 2 modifies Kconfig for DEBUG_INFO_DWARF4 to be used as a fallback.
Patch 3 adds an explicit Kconfig for DWARF v5 for clang and older GCC
where the implicit default DWARF version is not 5.

Changes from v8:
* Separate out the linker script changes (from v7 0002). Put those
  first. Carry Reviewed by and tested by tags.  Least contentious part
  of the series. Tagged for stable; otherwise users upgrading to GCC 11
  may find orphan section warnings from the implicit default DWARF
  version changing and generating the new debug info sections.
* Add CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT in 0002, make it the
  default rather than CONFIG_DEBUG_INFO_DWARF4, as per Mark, Jakub,
  Arvind.
* Drop reviewed by and tested by tags for 0002 and 0003; sorry
  reviewers/testers, but I view that as a big change. I will buy you
  beers if you're fatigued, AND for the help so far. I appreciate you.
* Rework commit one lines, and commit messages somewhat.
* Remove Kconfig help text about v4 being "bigger."
* I didn't touch the BTF config from v8, but suggest the BTF folks
  consider
  https://lore.kernel.org/bpf/20210111180609.713998-1-natechancellor@gmail.com/
  that way we can express via Kconfig that older version of pahole are
  in conflict with other Kconfig options.

Changes from v7:
(Strictly commit message changes)
* Pick up Nathan's reviewed by tags for both patches.
* Add note about only modifying compiler dwarf info, not assembler dwarf
  info, as per Nathan.
* Add link to Red Hat bug report and Chris' reported by on patch 2.
* Add more info from Jakub on patch 2 commit message.
* Reorder info about validating version, noting the tree is not "clean"
  in the sense that parts mess up existing CFLAGS, or don't use
  DEBUG_CFLAGS. I will not be adding such cleanups to this series. They
  can be done AFTER.
* Update note about 2.35.2 (rather than include the full text Jakub
  wrote on it in https://patchwork.kernel.org/project/linux-kbuild/patch/20201022012106.1875129-1-ndesaulniers@google.com/#23727667).
* Add note that GCC 11 has changed the implicit default version.

Changes from v6:
* Reorder sections from linker script to match order from BFD's internal
  linker script.
* Add .debug_names section, as per Fangrui.
* Drop CONFIG_DEBUG_INFO_DWARF2. Patch 0001 becomes a menu with 1
  choice. GCC's implicit default version of DWARF has been DWARF v4
  since ~4.8.
* Modify the test script to check for the presence of
  https://sourceware.org/bugzilla/show_bug.cgi?id=27195.
* Drop the clang without integrated assembler block in
  0002. Bumps the version requirement for GAS to 2.35.2, which isn't
  released yet (but should be released soon).  Folks looking to test
  with clang but without the integrated assembler should fetch
  binutils-gdb, build it from source, add a symlink to
  binutils-gdb/gas/as-new to binutils-gdb/gas/as, then prefix
  binutils-gdb/gas/as to their $PATH when building the kernel.

Changes from v5:
* Drop previous patch 1, it has been accepted into kbuild:
  https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=kbuild&id=3f4d8ce271c7082be75bacbcbd2048aa78ce2b44
* Trying to set -Wa,-gdwarf-4 in the earlier patch was the source of
  additional complexity. Drop it that part of the patch. We can revisit
  clang without the integrated assembler setting -Wa,-gdwarf-4 later.
  That is a separate problem from generally supporting DWARF v5.
* Rework the final patch for clang without the integrated assembler.
  -Wa,-gdwarf-5 is required for DWARF5 in that case otherwise GAS will
  not accept the assembler directives clang produces from C code when
  generating asm.

Changes from v4:
* drop set -e from script as per Nathan.
* add dependency on !CONFIG_DEBUG_INFO_BTF for DWARF v5 as per Sedat.
* Move LLVM_IAS=1 complexity from patch 2 to patch 3 as per Arvind and
  Masahiro. Sorry it took me a few tries to understand the point (I
  might still not), but it looks much cleaner this way. Sorry Nathan, I
  did not carry forward your previous reviews as a result, but I would
  appreciate if you could look again.
* Add Nathan's reviewed by tag to patch 1.
* Reword commit message for patch 3 to mention LLVM_IAS=1 and -gdwarf-5
  binutils addition later, and BTF issue.
* I still happen to see a pahole related error spew for the combination
  of:
  * LLVM=1
  * LLVM_IAS=1
  * CONFIG_DEBUG_INFO_DWARF4
  * CONFIG_DEBUG_INFO_BTF
  Though they're non-fatal to the build. I'm not sure yet why removing
  any one of the above prevents the warning spew. Maybe we'll need a v6.

Changes from v3:

Changes as per Arvind:
* only add -Wa,-gdwarf-5 for (LLVM=1|CC=clang)+LLVM_IAS=0 builds.
* add -gdwarf-5 to Kconfig shell script.
* only run Kconfig shell script for Clang.

Apologies to Sedat and Nathan; I appreciate previous testing/review, but
I did no carry forward your Tested-by and Reviewed-by tags, as the
patches have changed too much IMO.

Changes from v2:
* Drop two of the earlier patches that have been accepted already.
* Add measurements with GCC 10.2 to commit message.
* Update help text as per Arvind with help from Caroline.
* Improve case/wording between DWARF Versions as per Masahiro.

Changes from the RFC:
* split patch in 3 patch series, include Fangrui's patch, too.
* prefer `DWARF vX` format, as per Fangrui.
* use spaces between assignment in Makefile as per Masahiro.
* simplify setting dwarf-version-y as per Masahiro.
* indent `prompt` in Kconfig change as per Masahiro.
* remove explicit default in Kconfig as per Masahiro.
* add comments to test_dwarf5_support.sh.
* change echo in test_dwarf5_support.sh as per Masahiro.
* remove -u from test_dwarf5_support.sh as per Masahiro.
* add a -gdwarf-5 cc-option check to Kconfig as per Jakub.

Nick Desaulniers (3):
  vmlinux.lds.h: add DWARF v5 sections
  Kbuild: make DWARF version a choice
  Kconfig: allow explicit opt in to DWARF v5

 Makefile                          |  6 ++--
 include/asm-generic/vmlinux.lds.h |  7 ++++-
 lib/Kconfig.debug                 | 48 +++++++++++++++++++++++++++----
 scripts/test_dwarf5_support.sh    |  8 ++++++
 4 files changed, 61 insertions(+), 8 deletions(-)
 create mode 100755 scripts/test_dwarf5_support.sh

-- 
2.30.0.365.g02bc693789-goog


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v9 1/3] vmlinux.lds.h: add DWARF v5 sections
  2021-02-05 20:22 [PATCH v9 0/3] Kbuild: DWARF v5 support Nick Desaulniers
@ 2021-02-05 20:22 ` Nick Desaulniers
  2021-02-06  0:00   ` Andrew Morton
  2021-02-06 15:02   ` Mark Wielaard
  2021-02-05 20:22 ` [PATCH v9 2/3] Kbuild: make DWARF version a choice Nick Desaulniers
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Nick Desaulniers @ 2021-02-05 20:22 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nathan Chancellor, Andrew Morton, Sedat Dilek, linux-kernel,
	clang-built-linux, linux-kbuild, linux-arch, Jakub Jelinek,
	Fangrui Song, Caroline Tice, Nick Clifton, Yonghong Song,
	Jiri Olsa, Andrii Nakryiko, Arnaldo Carvalho de Melo,
	Arvind Sankar, Chris Murphy, Mark Wielaard, Nick Desaulniers,
	stable, Chris Murphy, Nathan Chancellor

We expect toolchains to produce these new debug info sections as part of
DWARF v5. Add explicit placements to prevent the linker warnings from
--orphan-section=warn.

Compilers may produce such sections with explicit -gdwarf-5, or based on
the implicit default version of DWARF when -g is used via DEBUG_INFO.
This implicit default changes over time, and has changed to DWARF v5
with GCC 11.

.debug_sup was mentioned in review, but without compilers producing it
today, let's wait to add it until it becomes necessary.

Cc: stable@vger.kernel.org
Link: https://bugzilla.redhat.com/show_bug.cgi?id=1922707
Reported-by: Chris Murphy <lists@colorremedies.com>
Suggested-by: Fangrui Song <maskray@google.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 include/asm-generic/vmlinux.lds.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 34b7e0d2346c..1e7cde4bd3f9 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -842,8 +842,13 @@
 		/* DWARF 4 */						\
 		.debug_types	0 : { *(.debug_types) }			\
 		/* DWARF 5 */						\
+		.debug_addr	0 : { *(.debug_addr) }			\
+		.debug_line_str	0 : { *(.debug_line_str) }		\
+		.debug_loclists	0 : { *(.debug_loclists) }		\
 		.debug_macro	0 : { *(.debug_macro) }			\
-		.debug_addr	0 : { *(.debug_addr) }
+		.debug_names	0 : { *(.debug_names) }			\
+		.debug_rnglists	0 : { *(.debug_rnglists) }		\
+		.debug_str_offsets	0 : { *(.debug_str_offsets) }
 
 /* Stabs debugging sections. */
 #define STABS_DEBUG							\
-- 
2.30.0.365.g02bc693789-goog


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v9 2/3] Kbuild: make DWARF version a choice
  2021-02-05 20:22 [PATCH v9 0/3] Kbuild: DWARF v5 support Nick Desaulniers
  2021-02-05 20:22 ` [PATCH v9 1/3] vmlinux.lds.h: add DWARF v5 sections Nick Desaulniers
@ 2021-02-05 20:22 ` Nick Desaulniers
  2021-02-05 20:22 ` [PATCH v9 3/3] Kconfig: allow explicit opt in to DWARF v5 Nick Desaulniers
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Nick Desaulniers @ 2021-02-05 20:22 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nathan Chancellor, Andrew Morton, Sedat Dilek, linux-kernel,
	clang-built-linux, linux-kbuild, linux-arch, Jakub Jelinek,
	Fangrui Song, Caroline Tice, Nick Clifton, Yonghong Song,
	Jiri Olsa, Andrii Nakryiko, Arnaldo Carvalho de Melo,
	Arvind Sankar, Chris Murphy, Mark Wielaard, Nick Desaulniers,
	Nathan Chancellor

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 <nivedita@alum.mit.edu>
Suggested-by: Fangrui Song <maskray@google.com>
Suggested-by: Jakub Jelinek <jakub@redhat.com>
Suggested-by: Mark Wielaard <mark@klomp.org>
Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
Suggested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 Makefile          |  5 +++--
 lib/Kconfig.debug | 30 +++++++++++++++++++++++++-----
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 28019532e55a..a7eee28dd091 100644
--- a/Makefile
+++ b/Makefile
@@ -829,8 +829,9 @@ ifneq ($(LLVM_IAS),1)
 KBUILD_AFLAGS	+= -Wa,-gdwarf-2
 endif
 
-ifdef CONFIG_DEBUG_INFO_DWARF4
-DEBUG_CFLAGS	+= -gdwarf-4
+ifndef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
+dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4
+DEBUG_CFLAGS	+= -gdwarf-$(dwarf-version-y)
 endif
 
 ifdef CONFIG_DEBUG_INFO_REDUCED
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index e906ea906cb7..3ac450346dbe 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -256,13 +256,33 @@ config DEBUG_INFO_SPLIT
 	  to know about the .dwo files and include them.
 	  Incompatible with older versions of ccache.
 
+choice
+	prompt "DWARF version"
+	help
+	  Which version of DWARF debug info to emit.
+
+config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
+	bool "Rely on the toolchain's implicit default DWARF version"
+	help
+	  The implicit default version of DWARF debug info produced by a
+	  toolchain changes over time.
+
+	  This can break consumers of the debug info that haven't upgraded to
+	  support newer revisions, and prevent testing newer versions, but
+	  those should be less common scenarios.
+
+	  If unsure, say Y.
+
 config DEBUG_INFO_DWARF4
-	bool "Generate dwarf4 debuginfo"
+	bool "Generate DWARF Version 4 debuginfo"
 	help
-	  Generate dwarf4 debug info. This requires recent versions
-	  of gcc and gdb. It makes the debug information larger.
-	  But it significantly improves the success of resolving
-	  variables in gdb on optimized code.
+	  Generate DWARF v4 debug info. This requires gcc 4.5+ and gdb 7.0+.
+
+	  If you have consumers of DWARF debug info that are not ready for
+	  newer revisions of DWARF, you may wish to choose this or have your
+	  config select this.
+
+endchoice # "DWARF version"
 
 config DEBUG_INFO_BTF
 	bool "Generate BTF typeinfo"
-- 
2.30.0.365.g02bc693789-goog


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v9 3/3] Kconfig: allow explicit opt in to DWARF v5
  2021-02-05 20:22 [PATCH v9 0/3] Kbuild: DWARF v5 support Nick Desaulniers
  2021-02-05 20:22 ` [PATCH v9 1/3] vmlinux.lds.h: add DWARF v5 sections Nick Desaulniers
  2021-02-05 20:22 ` [PATCH v9 2/3] Kbuild: make DWARF version a choice Nick Desaulniers
@ 2021-02-05 20:22 ` Nick Desaulniers
  2021-02-05 21:00 ` [PATCH v9 0/3] Kbuild: DWARF v5 support Sedat Dilek
  2021-02-25 19:13 ` Sedat Dilek
  4 siblings, 0 replies; 11+ messages in thread
From: Nick Desaulniers @ 2021-02-05 20:22 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nathan Chancellor, Andrew Morton, Sedat Dilek, linux-kernel,
	clang-built-linux, linux-kbuild, linux-arch, Jakub Jelinek,
	Fangrui Song, Caroline Tice, Nick Clifton, Yonghong Song,
	Jiri Olsa, Andrii Nakryiko, Arnaldo Carvalho de Melo,
	Arvind Sankar, Chris Murphy, Mark Wielaard, Nick Desaulniers

DWARF v5 is the latest standard of the DWARF debug info format. GCC 11
will change the implicit default DWARF version, if left unspecified, to
DWARF v5.

Allow users of Clang and older versions of GCC that have not changed the
implicit default DWARF version to DWARF v5 to opt in. This can help
testing consumers of DWARF debug info in preparation of v5 becoming more
widespread, as well as result in significant binary size savings of the
pre-stripped vmlinux image.

DWARF5 wins significantly in terms of size when mixed with compression
(CONFIG_DEBUG_INFO_COMPRESSED).

363M    vmlinux.clang12.dwarf5.compressed
434M    vmlinux.clang12.dwarf4.compressed
439M    vmlinux.clang12.dwarf2.compressed
457M    vmlinux.clang12.dwarf5
536M    vmlinux.clang12.dwarf4
548M    vmlinux.clang12.dwarf2

515M    vmlinux.gcc10.2.dwarf5.compressed
599M    vmlinux.gcc10.2.dwarf4.compressed
624M    vmlinux.gcc10.2.dwarf2.compressed
630M    vmlinux.gcc10.2.dwarf5
765M    vmlinux.gcc10.2.dwarf4
809M    vmlinux.gcc10.2.dwarf2

Though the quality of debug info is harder to quantify; size is not a
proxy for quality.

Jakub notes:
  One thing is GCC DWARF-5 support, that is whether the compiler will
  support -gdwarf-5 flag, and that support should be there from GCC 7
  onwards.

  All [GCC] 5.1 - 6.x did was start accepting -gdwarf-5 as experimental
  option that enabled some small DWARF subset (initially only a few
  DW_LANG_* codes newly added to DWARF5 drafts).  Only GCC 7 (released
  after DWARF 5 has been finalized) started emitting DWARF5 section
  headers and got most of the DWARF5 changes in...

  Another separate thing is whether the assembler does support
  the -gdwarf-5 option (i.e. if you can compile assembler files
  with -Wa,-gdwarf-5) ... That option is about whether the assembler
  will emit DWARF5 or DWARF2 .debug_line.  It is fine to compile C sources
  with -gdwarf-5 and use DWARF2 .debug_line for assembler files if as
  doesn't support it.

Version check GCC so that we don't need to worry about the difference in
command line args between GNU readelf and llvm-readelf/llvm-dwarfdump to
validate the DWARF Version in the assembler feature detection script.

Most issues with clang produced assembler were fixed in binutils 2.35.1,
but 2.35.2 fixed issues related to requiring the flag -Wa,-gdwarf-5
explicitly. The added shell script test checks for the latter, and is
only required when using clang without its integrated assembler, though
we use for clang regardless as we do not yet have a way to query the
assembler from Kconfig.

Disabled for now if CONFIG_DEBUG_INFO_BTF is set; pahole doesn't yet
recognize the new additions to the DWARF debug info.

This only modifies the DWARF version emitted by the compiler, not the
assembler.

The DWARF version of a binary can be validated with:
$ llvm-dwarfdump <object file> | head -n 4 | grep version
or
$ readelf --debug-dump=info <object file> 2>/dev/null | grep Version

Parts of the tree don't reuse DEBUG_CFLAGS as they should; such cleanup
is left as a follow up.

Link: http://www.dwarfstd.org/doc/DWARF5.pdf
Link: https://bugzilla.redhat.com/show_bug.cgi?id=1922707
Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Suggested-by: Arvind Sankar <nivedita@alum.mit.edu>
Suggested-by: Caroline Tice <cmtice@google.com>
Suggested-by: Fangrui Song <maskray@google.com>
Suggested-by: Jakub Jelinek <jakub@redhat.com>
Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 Makefile                       |  1 +
 lib/Kconfig.debug              | 18 ++++++++++++++++++
 scripts/test_dwarf5_support.sh |  8 ++++++++
 3 files changed, 27 insertions(+)
 create mode 100755 scripts/test_dwarf5_support.sh

diff --git a/Makefile b/Makefile
index a7eee28dd091..a85535eb6a7d 100644
--- a/Makefile
+++ b/Makefile
@@ -831,6 +831,7 @@ endif
 
 ifndef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
 dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4
+dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5
 DEBUG_CFLAGS	+= -gdwarf-$(dwarf-version-y)
 endif
 
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 3ac450346dbe..c85d82d3c6ef 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -282,6 +282,24 @@ config DEBUG_INFO_DWARF4
 	  newer revisions of DWARF, you may wish to choose this or have your
 	  config select this.
 
+config DEBUG_INFO_DWARF5
+	bool "Generate DWARF Version 5 debuginfo"
+	depends on GCC_VERSION >= 50000 || CC_IS_CLANG
+	depends on CC_IS_GCC || $(success,$(srctree)/scripts/test_dwarf5_support.sh $(CC) $(CLANG_FLAGS))
+	depends on !DEBUG_INFO_BTF
+	help
+	  Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
+	  5.0+ accepts the -gdwarf-5 flag but only had partial support for some
+	  draft features until 7.0), and gdb 8.0+.
+
+	  Changes to the structure of debug info in Version 5 allow for around
+	  15-18% savings in resulting image and debug info section sizes as
+	  compared to DWARF Version 4. DWARF Version 5 standardizes previous
+	  extensions such as accelerators for symbol indexing and the format
+	  for fission (.dwo/.dwp) files. Users may not want to select this
+	  config if they rely on tooling that has not yet been updated to
+	  support DWARF Version 5.
+
 endchoice # "DWARF version"
 
 config DEBUG_INFO_BTF
diff --git a/scripts/test_dwarf5_support.sh b/scripts/test_dwarf5_support.sh
new file mode 100755
index 000000000000..c46e2456b47a
--- /dev/null
+++ b/scripts/test_dwarf5_support.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+# Test that the assembler doesn't need -Wa,-gdwarf-5 when presented with DWARF
+# v5 input, such as `.file 0` and `md5 0x00`. Should be fixed in GNU binutils
+# 2.35.2. https://sourceware.org/bugzilla/show_bug.cgi?id=25611
+echo '.file 0 "filename" md5 0x7a0b65214090b6693bd1dc24dd248245' | \
+  $* -gdwarf-5 -Wno-unused-command-line-argument -c -x assembler -o /dev/null -
-- 
2.30.0.365.g02bc693789-goog


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v9 0/3] Kbuild: DWARF v5 support
  2021-02-05 20:22 [PATCH v9 0/3] Kbuild: DWARF v5 support Nick Desaulniers
                   ` (2 preceding siblings ...)
  2021-02-05 20:22 ` [PATCH v9 3/3] Kconfig: allow explicit opt in to DWARF v5 Nick Desaulniers
@ 2021-02-05 21:00 ` Sedat Dilek
  2021-02-06 12:04   ` Masahiro Yamada
  2021-02-25 19:13 ` Sedat Dilek
  4 siblings, 1 reply; 11+ messages in thread
From: Sedat Dilek @ 2021-02-05 21:00 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Masahiro Yamada, Nathan Chancellor, Andrew Morton, linux-kernel,
	Clang-Built-Linux ML, linux-kbuild, linux-arch, Jakub Jelinek,
	Fangrui Song, Caroline Tice, Nick Clifton, Yonghong Song,
	Jiri Olsa, Andrii Nakryiko, Arnaldo Carvalho de Melo,
	Arvind Sankar, Chris Murphy, Mark Wielaard

On Fri, Feb 5, 2021 at 9:22 PM Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> DWARF v5 is the latest standard of the DWARF debug info format.
>
> DWARF5 wins significantly in terms of size and especially so when mixed
> with compression (CONFIG_DEBUG_INFO_COMPRESSED).
>
> Link: http://www.dwarfstd.org/doc/DWARF5.pdf
>
> Patch 1 places the DWARF v5 sections explicitly in the kernel linker
> script.
> Patch 2 modifies Kconfig for DEBUG_INFO_DWARF4 to be used as a fallback.
> Patch 3 adds an explicit Kconfig for DWARF v5 for clang and older GCC
> where the implicit default DWARF version is not 5.
>
> Changes from v8:
> * Separate out the linker script changes (from v7 0002). Put those
>   first. Carry Reviewed by and tested by tags.  Least contentious part
>   of the series. Tagged for stable; otherwise users upgrading to GCC 11
>   may find orphan section warnings from the implicit default DWARF
>   version changing and generating the new debug info sections.
> * Add CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT in 0002, make it the
>   default rather than CONFIG_DEBUG_INFO_DWARF4, as per Mark, Jakub,
>   Arvind.
> * Drop reviewed by and tested by tags for 0002 and 0003; sorry
>   reviewers/testers, but I view that as a big change. I will buy you
>   beers if you're fatigued, AND for the help so far. I appreciate you.

All 3 patches NACKed - I drink no beer.

- sed@ -

> * Rework commit one lines, and commit messages somewhat.
> * Remove Kconfig help text about v4 being "bigger."
> * I didn't touch the BTF config from v8, but suggest the BTF folks
>   consider
>   https://lore.kernel.org/bpf/20210111180609.713998-1-natechancellor@gmail.com/
>   that way we can express via Kconfig that older version of pahole are
>   in conflict with other Kconfig options.
>
> Changes from v7:
> (Strictly commit message changes)
> * Pick up Nathan's reviewed by tags for both patches.
> * Add note about only modifying compiler dwarf info, not assembler dwarf
>   info, as per Nathan.
> * Add link to Red Hat bug report and Chris' reported by on patch 2.
> * Add more info from Jakub on patch 2 commit message.
> * Reorder info about validating version, noting the tree is not "clean"
>   in the sense that parts mess up existing CFLAGS, or don't use
>   DEBUG_CFLAGS. I will not be adding such cleanups to this series. They
>   can be done AFTER.
> * Update note about 2.35.2 (rather than include the full text Jakub
>   wrote on it in https://patchwork.kernel.org/project/linux-kbuild/patch/20201022012106.1875129-1-ndesaulniers@google.com/#23727667).
> * Add note that GCC 11 has changed the implicit default version.
>
> Changes from v6:
> * Reorder sections from linker script to match order from BFD's internal
>   linker script.
> * Add .debug_names section, as per Fangrui.
> * Drop CONFIG_DEBUG_INFO_DWARF2. Patch 0001 becomes a menu with 1
>   choice. GCC's implicit default version of DWARF has been DWARF v4
>   since ~4.8.
> * Modify the test script to check for the presence of
>   https://sourceware.org/bugzilla/show_bug.cgi?id=27195.
> * Drop the clang without integrated assembler block in
>   0002. Bumps the version requirement for GAS to 2.35.2, which isn't
>   released yet (but should be released soon).  Folks looking to test
>   with clang but without the integrated assembler should fetch
>   binutils-gdb, build it from source, add a symlink to
>   binutils-gdb/gas/as-new to binutils-gdb/gas/as, then prefix
>   binutils-gdb/gas/as to their $PATH when building the kernel.
>
> Changes from v5:
> * Drop previous patch 1, it has been accepted into kbuild:
>   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=kbuild&id=3f4d8ce271c7082be75bacbcbd2048aa78ce2b44
> * Trying to set -Wa,-gdwarf-4 in the earlier patch was the source of
>   additional complexity. Drop it that part of the patch. We can revisit
>   clang without the integrated assembler setting -Wa,-gdwarf-4 later.
>   That is a separate problem from generally supporting DWARF v5.
> * Rework the final patch for clang without the integrated assembler.
>   -Wa,-gdwarf-5 is required for DWARF5 in that case otherwise GAS will
>   not accept the assembler directives clang produces from C code when
>   generating asm.
>
> Changes from v4:
> * drop set -e from script as per Nathan.
> * add dependency on !CONFIG_DEBUG_INFO_BTF for DWARF v5 as per Sedat.
> * Move LLVM_IAS=1 complexity from patch 2 to patch 3 as per Arvind and
>   Masahiro. Sorry it took me a few tries to understand the point (I
>   might still not), but it looks much cleaner this way. Sorry Nathan, I
>   did not carry forward your previous reviews as a result, but I would
>   appreciate if you could look again.
> * Add Nathan's reviewed by tag to patch 1.
> * Reword commit message for patch 3 to mention LLVM_IAS=1 and -gdwarf-5
>   binutils addition later, and BTF issue.
> * I still happen to see a pahole related error spew for the combination
>   of:
>   * LLVM=1
>   * LLVM_IAS=1
>   * CONFIG_DEBUG_INFO_DWARF4
>   * CONFIG_DEBUG_INFO_BTF
>   Though they're non-fatal to the build. I'm not sure yet why removing
>   any one of the above prevents the warning spew. Maybe we'll need a v6.
>
> Changes from v3:
>
> Changes as per Arvind:
> * only add -Wa,-gdwarf-5 for (LLVM=1|CC=clang)+LLVM_IAS=0 builds.
> * add -gdwarf-5 to Kconfig shell script.
> * only run Kconfig shell script for Clang.
>
> Apologies to Sedat and Nathan; I appreciate previous testing/review, but
> I did no carry forward your Tested-by and Reviewed-by tags, as the
> patches have changed too much IMO.
>
> Changes from v2:
> * Drop two of the earlier patches that have been accepted already.
> * Add measurements with GCC 10.2 to commit message.
> * Update help text as per Arvind with help from Caroline.
> * Improve case/wording between DWARF Versions as per Masahiro.
>
> Changes from the RFC:
> * split patch in 3 patch series, include Fangrui's patch, too.
> * prefer `DWARF vX` format, as per Fangrui.
> * use spaces between assignment in Makefile as per Masahiro.
> * simplify setting dwarf-version-y as per Masahiro.
> * indent `prompt` in Kconfig change as per Masahiro.
> * remove explicit default in Kconfig as per Masahiro.
> * add comments to test_dwarf5_support.sh.
> * change echo in test_dwarf5_support.sh as per Masahiro.
> * remove -u from test_dwarf5_support.sh as per Masahiro.
> * add a -gdwarf-5 cc-option check to Kconfig as per Jakub.
>
> Nick Desaulniers (3):
>   vmlinux.lds.h: add DWARF v5 sections
>   Kbuild: make DWARF version a choice
>   Kconfig: allow explicit opt in to DWARF v5
>
>  Makefile                          |  6 ++--
>  include/asm-generic/vmlinux.lds.h |  7 ++++-
>  lib/Kconfig.debug                 | 48 +++++++++++++++++++++++++++----
>  scripts/test_dwarf5_support.sh    |  8 ++++++
>  4 files changed, 61 insertions(+), 8 deletions(-)
>  create mode 100755 scripts/test_dwarf5_support.sh
>
> --
> 2.30.0.365.g02bc693789-goog
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9 1/3] vmlinux.lds.h: add DWARF v5 sections
  2021-02-05 20:22 ` [PATCH v9 1/3] vmlinux.lds.h: add DWARF v5 sections Nick Desaulniers
@ 2021-02-06  0:00   ` Andrew Morton
  2021-02-06  0:02     ` Nick Desaulniers
  2021-02-06 15:02   ` Mark Wielaard
  1 sibling, 1 reply; 11+ messages in thread
From: Andrew Morton @ 2021-02-06  0:00 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Masahiro Yamada, Nathan Chancellor, Sedat Dilek, linux-kernel,
	clang-built-linux, linux-kbuild, linux-arch, Jakub Jelinek,
	Fangrui Song, Caroline Tice, Nick Clifton, Yonghong Song,
	Jiri Olsa, Andrii Nakryiko, Arnaldo Carvalho de Melo,
	Arvind Sankar, Chris Murphy, Mark Wielaard, stable, Chris Murphy,
	Nathan Chancellor

On Fri,  5 Feb 2021 12:22:18 -0800 Nick Desaulniers <ndesaulniers@google.com> wrote:

> We expect toolchains to produce these new debug info sections as part of
> DWARF v5. Add explicit placements to prevent the linker warnings from
> --orphan-section=warn.
> 
> Compilers may produce such sections with explicit -gdwarf-5, or based on
> the implicit default version of DWARF when -g is used via DEBUG_INFO.
> This implicit default changes over time, and has changed to DWARF v5
> with GCC 11.
> 
> .debug_sup was mentioned in review, but without compilers producing it
> today, let's wait to add it until it becomes necessary.
> 

There isn't anything in this changelog which explains why a -stable
backport was requested?  Or is there?  Irritating linker warnings? 
More than that?


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9 1/3] vmlinux.lds.h: add DWARF v5 sections
  2021-02-06  0:00   ` Andrew Morton
@ 2021-02-06  0:02     ` Nick Desaulniers
  0 siblings, 0 replies; 11+ messages in thread
From: Nick Desaulniers @ 2021-02-06  0:02 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Masahiro Yamada, Nathan Chancellor, Sedat Dilek, LKML,
	clang-built-linux, Linux Kbuild mailing list, linux-arch,
	Jakub Jelinek, Fangrui Song, Caroline Tice, Nick Clifton,
	Yonghong Song, Jiri Olsa, Andrii Nakryiko,
	Arnaldo Carvalho de Melo, Arvind Sankar, Chris Murphy,
	Mark Wielaard, # 3.4.x, Chris Murphy, Nathan Chancellor

On Fri, Feb 5, 2021 at 4:00 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Fri,  5 Feb 2021 12:22:18 -0800 Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> > We expect toolchains to produce these new debug info sections as part of
> > DWARF v5. Add explicit placements to prevent the linker warnings from
> > --orphan-section=warn.
> >
> > Compilers may produce such sections with explicit -gdwarf-5, or based on
> > the implicit default version of DWARF when -g is used via DEBUG_INFO.
> > This implicit default changes over time, and has changed to DWARF v5
> > with GCC 11.
> >
> > .debug_sup was mentioned in review, but without compilers producing it
> > today, let's wait to add it until it becomes necessary.
> >
>
> There isn't anything in this changelog which explains why a -stable
> backport was requested?  Or is there?  Irritating linker warnings?
> More than that?

Users adopting GCC 11 will start to see warnings from the linker due
to --orphan-section=warn when building the branches of the stable
tree.  Stable has IME accepted patches for permitting newer toolchains
to continue to compile warning free.
-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9 0/3] Kbuild: DWARF v5 support
  2021-02-05 21:00 ` [PATCH v9 0/3] Kbuild: DWARF v5 support Sedat Dilek
@ 2021-02-06 12:04   ` Masahiro Yamada
  2021-02-06 12:28     ` Sedat Dilek
  0 siblings, 1 reply; 11+ messages in thread
From: Masahiro Yamada @ 2021-02-06 12:04 UTC (permalink / raw)
  To: Sedat Dilek
  Cc: Nick Desaulniers, Nathan Chancellor, Andrew Morton,
	Linux Kernel Mailing List, Clang-Built-Linux ML,
	Linux Kbuild mailing list, linux-arch, Jakub Jelinek,
	Fangrui Song, Caroline Tice, Nick Clifton, Yonghong Song,
	Jiri Olsa, Andrii Nakryiko, Arnaldo Carvalho de Melo,
	Arvind Sankar, Chris Murphy, Mark Wielaard

On Sat, Feb 6, 2021 at 6:00 AM Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Fri, Feb 5, 2021 at 9:22 PM Nick Desaulniers <ndesaulniers@google.com> wrote:
> >
> > DWARF v5 is the latest standard of the DWARF debug info format.
> >
> > DWARF5 wins significantly in terms of size and especially so when mixed
> > with compression (CONFIG_DEBUG_INFO_COMPRESSED).
> >
> > Link: http://www.dwarfstd.org/doc/DWARF5.pdf
> >
> > Patch 1 places the DWARF v5 sections explicitly in the kernel linker
> > script.
> > Patch 2 modifies Kconfig for DEBUG_INFO_DWARF4 to be used as a fallback.
> > Patch 3 adds an explicit Kconfig for DWARF v5 for clang and older GCC
> > where the implicit default DWARF version is not 5.
> >
> > Changes from v8:
> > * Separate out the linker script changes (from v7 0002). Put those
> >   first. Carry Reviewed by and tested by tags.  Least contentious part
> >   of the series. Tagged for stable; otherwise users upgrading to GCC 11
> >   may find orphan section warnings from the implicit default DWARF
> >   version changing and generating the new debug info sections.
> > * Add CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT in 0002, make it the
> >   default rather than CONFIG_DEBUG_INFO_DWARF4, as per Mark, Jakub,
> >   Arvind.
> > * Drop reviewed by and tested by tags for 0002 and 0003; sorry
> >   reviewers/testers, but I view that as a big change. I will buy you
> >   beers if you're fatigued, AND for the help so far. I appreciate you.
>
> All 3 patches NACKed - I drink no beer.

LoL.
Other than beer, I am fine with v9.

Personally, I thought v8 (no CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT)
was good too, but I do not have a strong opinion about
leaving the compiler's freedom to choose the dwarf version.

Unless somebody has an objection, I will pick up v9 for the next MW.


Meanwhile, if you want to give reviewed-by / tested-by
please do so.



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9 0/3] Kbuild: DWARF v5 support
  2021-02-06 12:04   ` Masahiro Yamada
@ 2021-02-06 12:28     ` Sedat Dilek
  0 siblings, 0 replies; 11+ messages in thread
From: Sedat Dilek @ 2021-02-06 12:28 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nick Desaulniers, Nathan Chancellor, Andrew Morton,
	Linux Kernel Mailing List, Clang-Built-Linux ML,
	Linux Kbuild mailing list, linux-arch, Jakub Jelinek,
	Fangrui Song, Caroline Tice, Nick Clifton, Yonghong Song,
	Jiri Olsa, Andrii Nakryiko, Arnaldo Carvalho de Melo,
	Arvind Sankar, Chris Murphy, Mark Wielaard

On Sat, Feb 6, 2021 at 1:05 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Sat, Feb 6, 2021 at 6:00 AM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> >
> > On Fri, Feb 5, 2021 at 9:22 PM Nick Desaulniers <ndesaulniers@google.com> wrote:
> > >
> > > DWARF v5 is the latest standard of the DWARF debug info format.
> > >
> > > DWARF5 wins significantly in terms of size and especially so when mixed
> > > with compression (CONFIG_DEBUG_INFO_COMPRESSED).
> > >
> > > Link: http://www.dwarfstd.org/doc/DWARF5.pdf
> > >
> > > Patch 1 places the DWARF v5 sections explicitly in the kernel linker
> > > script.
> > > Patch 2 modifies Kconfig for DEBUG_INFO_DWARF4 to be used as a fallback.
> > > Patch 3 adds an explicit Kconfig for DWARF v5 for clang and older GCC
> > > where the implicit default DWARF version is not 5.
> > >
> > > Changes from v8:
> > > * Separate out the linker script changes (from v7 0002). Put those
> > >   first. Carry Reviewed by and tested by tags.  Least contentious part
> > >   of the series. Tagged for stable; otherwise users upgrading to GCC 11
> > >   may find orphan section warnings from the implicit default DWARF
> > >   version changing and generating the new debug info sections.
> > > * Add CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT in 0002, make it the
> > >   default rather than CONFIG_DEBUG_INFO_DWARF4, as per Mark, Jakub,
> > >   Arvind.
> > > * Drop reviewed by and tested by tags for 0002 and 0003; sorry
> > >   reviewers/testers, but I view that as a big change. I will buy you
> > >   beers if you're fatigued, AND for the help so far. I appreciate you.
> >
> > All 3 patches NACKed - I drink no beer.
>
> LoL.
> Other than beer, I am fine with v9.
>
> Personally, I thought v8 (no CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT)
> was good too, but I do not have a strong opinion about
> leaving the compiler's freedom to choose the dwarf version.
>
> Unless somebody has an objection, I will pick up v9 for the next MW.
>
>
> Meanwhile, if you want to give reviewed-by / tested-by
> please do so.
>

Fine with me.

I have no opinion towards distro-handling of toolchain-default(s).

Feel free to add my:
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM/Clang v12.0.0-rc1 x86-64

Thanks to all involved people - I enjoyed the evolution of this patchset.

- Sedat -

P.S.: /me drinking right now an Earl Grey tea - drink whatever you prefer :-).

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9 1/3] vmlinux.lds.h: add DWARF v5 sections
  2021-02-05 20:22 ` [PATCH v9 1/3] vmlinux.lds.h: add DWARF v5 sections Nick Desaulniers
  2021-02-06  0:00   ` Andrew Morton
@ 2021-02-06 15:02   ` Mark Wielaard
  1 sibling, 0 replies; 11+ messages in thread
From: Mark Wielaard @ 2021-02-06 15:02 UTC (permalink / raw)
  To: Nick Desaulniers, Masahiro Yamada
  Cc: Nathan Chancellor, Andrew Morton, Sedat Dilek, linux-kernel,
	clang-built-linux, linux-kbuild, linux-arch, Jakub Jelinek,
	Fangrui Song, Caroline Tice, Nick Clifton, Yonghong Song,
	Jiri Olsa, Andrii Nakryiko, Arnaldo Carvalho de Melo,
	Arvind Sankar, Chris Murphy, stable, Chris Murphy,
	Nathan Chancellor

Hi Nick,

On Fri, 2021-02-05 at 12:22 -0800, Nick Desaulniers wrote:
> We expect toolchains to produce these new debug info sections as part of
> DWARF v5. Add explicit placements to prevent the linker warnings from
> --orphan-section=warn.
> 
> Compilers may produce such sections with explicit -gdwarf-5, or based on
> the implicit default version of DWARF when -g is used via DEBUG_INFO.
> This implicit default changes over time, and has changed to DWARF v5
> with GCC 11.
> 
> .debug_sup was mentioned in review, but without compilers producing it
> today, let's wait to add it until it becomes necessary.

I don't think that will be necessary. .debug_sup is for Dwarf
Supplemental file producers like dwz. Those would run after the linker.

> Cc: stable@vger.kernel.org
> Link: https://bugzilla.redhat.com/show_bug.cgi?id=1922707
> Reported-by: Chris Murphy <lists@colorremedies.com>
> Suggested-by: Fangrui Song <maskray@google.com>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>  include/asm-generic/vmlinux.lds.h | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index 34b7e0d2346c..1e7cde4bd3f9 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -842,8 +842,13 @@
>  		/* DWARF 4 */						\
>  		.debug_types	0 : { *(.debug_types) }			\
>  		/* DWARF 5 */						\
> +		.debug_addr	0 : { *(.debug_addr) }			\
> +		.debug_line_str	0 : { *(.debug_line_str) }		\
> +		.debug_loclists	0 : { *(.debug_loclists) }		\
>  		.debug_macro	0 : { *(.debug_macro) }			\
> -		.debug_addr	0 : { *(.debug_addr) }
> +		.debug_names	0 : { *(.debug_names) }			\
> +		.debug_rnglists	0 : { *(.debug_rnglists) }		\
> +		.debug_str_offsets	0 : { *(.debug_str_offsets) }
>  
>  /* Stabs debugging sections. */
>  #define STABS_DEBUG							\

Looks good to me.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v9 0/3] Kbuild: DWARF v5 support
  2021-02-05 20:22 [PATCH v9 0/3] Kbuild: DWARF v5 support Nick Desaulniers
                   ` (3 preceding siblings ...)
  2021-02-05 21:00 ` [PATCH v9 0/3] Kbuild: DWARF v5 support Sedat Dilek
@ 2021-02-25 19:13 ` Sedat Dilek
  4 siblings, 0 replies; 11+ messages in thread
From: Sedat Dilek @ 2021-02-25 19:13 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Masahiro Yamada, Nathan Chancellor, Andrew Morton, linux-kernel,
	Clang-Built-Linux ML, linux-kbuild, linux-arch, Jakub Jelinek,
	Fangrui Song, Caroline Tice, Nick Clifton, Yonghong Song,
	Jiri Olsa, Andrii Nakryiko, Arnaldo Carvalho de Melo,
	Arvind Sankar, Chris Murphy, Mark Wielaard

On Fri, Feb 5, 2021 at 9:22 PM Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> DWARF v5 is the latest standard of the DWARF debug info format.
>
> DWARF5 wins significantly in terms of size and especially so when mixed
> with compression (CONFIG_DEBUG_INFO_COMPRESSED).
>
> Link: http://www.dwarfstd.org/doc/DWARF5.pdf
>

Accepted into mainline via kbuild-v5.12.

- Sedat -

[1] https://git.kernel.org/linus/6fbd6cf85a3be127454a1ad58525a3adcf8612ab

> Patch 1 places the DWARF v5 sections explicitly in the kernel linker
> script.
> Patch 2 modifies Kconfig for DEBUG_INFO_DWARF4 to be used as a fallback.
> Patch 3 adds an explicit Kconfig for DWARF v5 for clang and older GCC
> where the implicit default DWARF version is not 5.
>
> Changes from v8:
> * Separate out the linker script changes (from v7 0002). Put those
>   first. Carry Reviewed by and tested by tags.  Least contentious part
>   of the series. Tagged for stable; otherwise users upgrading to GCC 11
>   may find orphan section warnings from the implicit default DWARF
>   version changing and generating the new debug info sections.
> * Add CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT in 0002, make it the
>   default rather than CONFIG_DEBUG_INFO_DWARF4, as per Mark, Jakub,
>   Arvind.
> * Drop reviewed by and tested by tags for 0002 and 0003; sorry
>   reviewers/testers, but I view that as a big change. I will buy you
>   beers if you're fatigued, AND for the help so far. I appreciate you.
> * Rework commit one lines, and commit messages somewhat.
> * Remove Kconfig help text about v4 being "bigger."
> * I didn't touch the BTF config from v8, but suggest the BTF folks
>   consider
>   https://lore.kernel.org/bpf/20210111180609.713998-1-natechancellor@gmail.com/
>   that way we can express via Kconfig that older version of pahole are
>   in conflict with other Kconfig options.
>
> Changes from v7:
> (Strictly commit message changes)
> * Pick up Nathan's reviewed by tags for both patches.
> * Add note about only modifying compiler dwarf info, not assembler dwarf
>   info, as per Nathan.
> * Add link to Red Hat bug report and Chris' reported by on patch 2.
> * Add more info from Jakub on patch 2 commit message.
> * Reorder info about validating version, noting the tree is not "clean"
>   in the sense that parts mess up existing CFLAGS, or don't use
>   DEBUG_CFLAGS. I will not be adding such cleanups to this series. They
>   can be done AFTER.
> * Update note about 2.35.2 (rather than include the full text Jakub
>   wrote on it in https://patchwork.kernel.org/project/linux-kbuild/patch/20201022012106.1875129-1-ndesaulniers@google.com/#23727667).
> * Add note that GCC 11 has changed the implicit default version.
>
> Changes from v6:
> * Reorder sections from linker script to match order from BFD's internal
>   linker script.
> * Add .debug_names section, as per Fangrui.
> * Drop CONFIG_DEBUG_INFO_DWARF2. Patch 0001 becomes a menu with 1
>   choice. GCC's implicit default version of DWARF has been DWARF v4
>   since ~4.8.
> * Modify the test script to check for the presence of
>   https://sourceware.org/bugzilla/show_bug.cgi?id=27195.
> * Drop the clang without integrated assembler block in
>   0002. Bumps the version requirement for GAS to 2.35.2, which isn't
>   released yet (but should be released soon).  Folks looking to test
>   with clang but without the integrated assembler should fetch
>   binutils-gdb, build it from source, add a symlink to
>   binutils-gdb/gas/as-new to binutils-gdb/gas/as, then prefix
>   binutils-gdb/gas/as to their $PATH when building the kernel.
>
> Changes from v5:
> * Drop previous patch 1, it has been accepted into kbuild:
>   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/commit/?h=kbuild&id=3f4d8ce271c7082be75bacbcbd2048aa78ce2b44
> * Trying to set -Wa,-gdwarf-4 in the earlier patch was the source of
>   additional complexity. Drop it that part of the patch. We can revisit
>   clang without the integrated assembler setting -Wa,-gdwarf-4 later.
>   That is a separate problem from generally supporting DWARF v5.
> * Rework the final patch for clang without the integrated assembler.
>   -Wa,-gdwarf-5 is required for DWARF5 in that case otherwise GAS will
>   not accept the assembler directives clang produces from C code when
>   generating asm.
>
> Changes from v4:
> * drop set -e from script as per Nathan.
> * add dependency on !CONFIG_DEBUG_INFO_BTF for DWARF v5 as per Sedat.
> * Move LLVM_IAS=1 complexity from patch 2 to patch 3 as per Arvind and
>   Masahiro. Sorry it took me a few tries to understand the point (I
>   might still not), but it looks much cleaner this way. Sorry Nathan, I
>   did not carry forward your previous reviews as a result, but I would
>   appreciate if you could look again.
> * Add Nathan's reviewed by tag to patch 1.
> * Reword commit message for patch 3 to mention LLVM_IAS=1 and -gdwarf-5
>   binutils addition later, and BTF issue.
> * I still happen to see a pahole related error spew for the combination
>   of:
>   * LLVM=1
>   * LLVM_IAS=1
>   * CONFIG_DEBUG_INFO_DWARF4
>   * CONFIG_DEBUG_INFO_BTF
>   Though they're non-fatal to the build. I'm not sure yet why removing
>   any one of the above prevents the warning spew. Maybe we'll need a v6.
>
> Changes from v3:
>
> Changes as per Arvind:
> * only add -Wa,-gdwarf-5 for (LLVM=1|CC=clang)+LLVM_IAS=0 builds.
> * add -gdwarf-5 to Kconfig shell script.
> * only run Kconfig shell script for Clang.
>
> Apologies to Sedat and Nathan; I appreciate previous testing/review, but
> I did no carry forward your Tested-by and Reviewed-by tags, as the
> patches have changed too much IMO.
>
> Changes from v2:
> * Drop two of the earlier patches that have been accepted already.
> * Add measurements with GCC 10.2 to commit message.
> * Update help text as per Arvind with help from Caroline.
> * Improve case/wording between DWARF Versions as per Masahiro.
>
> Changes from the RFC:
> * split patch in 3 patch series, include Fangrui's patch, too.
> * prefer `DWARF vX` format, as per Fangrui.
> * use spaces between assignment in Makefile as per Masahiro.
> * simplify setting dwarf-version-y as per Masahiro.
> * indent `prompt` in Kconfig change as per Masahiro.
> * remove explicit default in Kconfig as per Masahiro.
> * add comments to test_dwarf5_support.sh.
> * change echo in test_dwarf5_support.sh as per Masahiro.
> * remove -u from test_dwarf5_support.sh as per Masahiro.
> * add a -gdwarf-5 cc-option check to Kconfig as per Jakub.
>
> Nick Desaulniers (3):
>   vmlinux.lds.h: add DWARF v5 sections
>   Kbuild: make DWARF version a choice
>   Kconfig: allow explicit opt in to DWARF v5
>
>  Makefile                          |  6 ++--
>  include/asm-generic/vmlinux.lds.h |  7 ++++-
>  lib/Kconfig.debug                 | 48 +++++++++++++++++++++++++++----
>  scripts/test_dwarf5_support.sh    |  8 ++++++
>  4 files changed, 61 insertions(+), 8 deletions(-)
>  create mode 100755 scripts/test_dwarf5_support.sh
>
> --
> 2.30.0.365.g02bc693789-goog
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-02-25 19:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05 20:22 [PATCH v9 0/3] Kbuild: DWARF v5 support Nick Desaulniers
2021-02-05 20:22 ` [PATCH v9 1/3] vmlinux.lds.h: add DWARF v5 sections Nick Desaulniers
2021-02-06  0:00   ` Andrew Morton
2021-02-06  0:02     ` Nick Desaulniers
2021-02-06 15:02   ` Mark Wielaard
2021-02-05 20:22 ` [PATCH v9 2/3] Kbuild: make DWARF version a choice Nick Desaulniers
2021-02-05 20:22 ` [PATCH v9 3/3] Kconfig: allow explicit opt in to DWARF v5 Nick Desaulniers
2021-02-05 21:00 ` [PATCH v9 0/3] Kbuild: DWARF v5 support Sedat Dilek
2021-02-06 12:04   ` Masahiro Yamada
2021-02-06 12:28     ` Sedat Dilek
2021-02-25 19:13 ` Sedat Dilek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).