Message ID | 20210129194318.2125748-3-ndesaulniers@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Kbuild: DWARF v5 support | expand |
On Fri, Jan 29, 2021 at 8:43 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > DWARF v5 is the latest standard of the DWARF debug info format. > > Feature detection of DWARF5 is onerous, especially given that we've > removed $(AS), so we must query $(CC) for DWARF5 assembler directive > support. > > The DWARF version of a binary can be validated with: > $ llvm-dwarfdump vmlinux | head -n 4 | grep version > or > $ readelf --debug-dump=info vmlinux 2>/dev/null | grep Version > > 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: > 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... > > 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. > > GNU `as` only recently gained support for specifying -gdwarf-5, so when > compiling with Clang but without Clang's integrated assembler > (LLVM_IAS=1 is not set), explicitly add -Wa,-gdwarf-5 to DEBUG_CFLAGS. > > Disabled for now if CONFIG_DEBUG_INFO_BTF is set; pahole doesn't yet > recognize the new additions to the DWARF debug info. Thanks to Sedat for > the report. > > Link: http://www.dwarfstd.org/doc/DWARF5.pdf > 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 | 12 ++++++++++++ > include/asm-generic/vmlinux.lds.h | 6 +++++- > lib/Kconfig.debug | 18 ++++++++++++++++++ > scripts/test_dwarf5_support.sh | 8 ++++++++ > 4 files changed, 43 insertions(+), 1 deletion(-) > create mode 100755 scripts/test_dwarf5_support.sh > > diff --git a/Makefile b/Makefile > index 20141cd9319e..bed8b3b180b8 100644 > --- a/Makefile > +++ b/Makefile > @@ -832,8 +832,20 @@ endif > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > +# If using clang without the integrated assembler, we need to explicitly tell > +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should > +# detect whether the version of GAS supports DWARF v5. > +ifdef CONFIG_CC_IS_CLANG > +ifneq ($(LLVM_IAS),1) > +ifeq ($(dwarf-version-y),5) > +DEBUG_CFLAGS += -Wa,-gdwarf-5 I noticed double "-g -gdwarf-5 -g -gdwarf-5" (a different issue) and that's why I looked again into the top-level Makefile. Should this be...? KBUILD_AFLAGS += -Wa,-gdwarf-5 - Sedat - > +endif > +endif > +endif > + > ifdef CONFIG_DEBUG_INFO_REDUCED > DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ > $(call cc-option,-fno-var-tracking) > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h > index 34b7e0d2346c..f8d5455cd87f 100644 > --- a/include/asm-generic/vmlinux.lds.h > +++ b/include/asm-generic/vmlinux.lds.h > @@ -843,7 +843,11 @@ > .debug_types 0 : { *(.debug_types) } \ > /* DWARF 5 */ \ > .debug_macro 0 : { *(.debug_macro) } \ > - .debug_addr 0 : { *(.debug_addr) } > + .debug_addr 0 : { *(.debug_addr) } \ > + .debug_line_str 0 : { *(.debug_line_str) } \ > + .debug_loclists 0 : { *(.debug_loclists) } \ > + .debug_rnglists 0 : { *(.debug_rnglists) } \ > + .debug_str_offsets 0 : { *(.debug_str_offsets) } > > /* Stabs debugging sections. */ > #define STABS_DEBUG \ > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index 1850728b23e6..09146b1af20d 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -273,6 +273,24 @@ config DEBUG_INFO_DWARF4 > It makes the debug information larger, but it significantly > improves the success of resolving variables in gdb on optimized code. > > +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, 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..1a00484d0b2e > --- /dev/null > +++ b/scripts/test_dwarf5_support.sh > @@ -0,0 +1,8 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0 > + > +# Test that assembler accepts -gdwarf-5 and .file 0 directives, which were bugs > +# in binutils < 2.35. > +# https://sourceware.org/bugzilla/show_bug.cgi?id=25612 > +# https://sourceware.org/bugzilla/show_bug.cgi?id=25614 > +echo '.file 0 "filename"' | $* -gdwarf-5 -Wa,-gdwarf-5 -c -x assembler -o /dev/null - > -- > 2.30.0.365.g02bc693789-goog >
On Fri, Jan 29, 2021 at 12:41 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > On Fri, Jan 29, 2021 at 8:43 PM Nick Desaulniers > <ndesaulniers@google.com> wrote: > > > > diff --git a/Makefile b/Makefile > > index 20141cd9319e..bed8b3b180b8 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -832,8 +832,20 @@ endif > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > > > +# If using clang without the integrated assembler, we need to explicitly tell > > +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should > > +# detect whether the version of GAS supports DWARF v5. > > +ifdef CONFIG_CC_IS_CLANG > > +ifneq ($(LLVM_IAS),1) > > +ifeq ($(dwarf-version-y),5) > > +DEBUG_CFLAGS += -Wa,-gdwarf-5 > > I noticed double "-g -gdwarf-5 -g -gdwarf-5" (a different issue) and > that's why I looked again into the top-level Makefile. That's...unexpected. I don't see where that could be coming from. Can you tell me please what is the precise command line invocation of make and which source file you observed this on so that I can reproduce? > Should this be...? > > KBUILD_AFLAGS += -Wa,-gdwarf-5 No; under the set of conditions Clang is compiling .c to .S with DWARF v5 assembler directives. GAS will choke unless told -gdwarf-5 via -Wa,-gdwarf-5 for .c source files, hence it is a C flag, not an A flag. A flags are for .S assembler sources, not .c sources.
On Fri, Jan 29, 2021 at 9:48 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Fri, Jan 29, 2021 at 12:41 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > On Fri, Jan 29, 2021 at 8:43 PM Nick Desaulniers > > <ndesaulniers@google.com> wrote: > > > > > > diff --git a/Makefile b/Makefile > > > index 20141cd9319e..bed8b3b180b8 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -832,8 +832,20 @@ endif > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > > > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > > > > > +# If using clang without the integrated assembler, we need to explicitly tell > > > +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should > > > +# detect whether the version of GAS supports DWARF v5. > > > +ifdef CONFIG_CC_IS_CLANG > > > +ifneq ($(LLVM_IAS),1) > > > +ifeq ($(dwarf-version-y),5) > > > +DEBUG_CFLAGS += -Wa,-gdwarf-5 > > > > I noticed double "-g -gdwarf-5 -g -gdwarf-5" (a different issue) and > > that's why I looked again into the top-level Makefile. > > That's...unexpected. I don't see where that could be coming from. > Can you tell me please what is the precise command line invocation of > make and which source file you observed this on so that I can > reproduce? > That's everywhere... $ zstdgrep --color '\-g -gdwarf-5 -g -gdwarf-5' build-log_5.11.0-rc5-8-amd64-clang12-lto.txt.zst | wc -l 29529 > > Should this be...? > > > > KBUILD_AFLAGS += -Wa,-gdwarf-5 > > No; under the set of conditions Clang is compiling .c to .S with DWARF > v5 assembler directives. GAS will choke unless told -gdwarf-5 via > -Wa,-gdwarf-5 for .c source files, hence it is a C flag, not an A > flag. A flags are for .S assembler sources, not .c sources. > You are right. I mixed again C and A flags. - Sedat -
On Fri, Jan 29, 2021 at 12:48:11PM -0800, Nick Desaulniers wrote: > > Should this be...? > > > > KBUILD_AFLAGS += -Wa,-gdwarf-5 > > No; under the set of conditions Clang is compiling .c to .S with DWARF > v5 assembler directives. GAS will choke unless told -gdwarf-5 via > -Wa,-gdwarf-5 for .c source files, hence it is a C flag, not an A Wasn't that fixed in GAS? https://sourceware.org/bugzilla/show_bug.cgi?id=27195 Jakub
On Fri, Jan 29, 2021 at 12:57 PM Jakub Jelinek <jakub@redhat.com> wrote: > > On Fri, Jan 29, 2021 at 12:48:11PM -0800, Nick Desaulniers wrote: > > > Should this be...? > > > > > > KBUILD_AFLAGS += -Wa,-gdwarf-5 > > > > No; under the set of conditions Clang is compiling .c to .S with DWARF > > v5 assembler directives. GAS will choke unless told -gdwarf-5 via > > -Wa,-gdwarf-5 for .c source files, hence it is a C flag, not an A > > Wasn't that fixed in GAS? > https://sourceware.org/bugzilla/show_bug.cgi?id=27195 ``` diff --git a/Makefile b/Makefile index bed8b3b180b8..de616e584706 100644 --- a/Makefile +++ b/Makefile @@ -835,17 +835,6 @@ dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) -# If using clang without the integrated assembler, we need to explicitly tell -# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should -# detect whether the version of GAS supports DWARF v5. -ifdef CONFIG_CC_IS_CLANG -ifneq ($(LLVM_IAS),1) -ifeq ($(dwarf-version-y),5) -DEBUG_CFLAGS += -Wa,-gdwarf-5 -endif -endif -endif - ifdef CONFIG_DEBUG_INFO_REDUCED DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ $(call cc-option,-fno-var-tracking) ``` $ make LLVM=1 -j72 defconfig $ ./scripts/config -e DEBUG_INFO -e DEBUG_INFO_DWARF5 $ make LLVM=1 -j72 ... /tmp/init-d50d89.s: Assembler messages: /tmp/init-d50d89.s:10: Error: file number less than one /tmp/init-d50d89.s:11: Error: junk at end of line, first unrecognized character is `m' which is https://sourceware.org/bugzilla/show_bug.cgi?id=25611. $ as --version | head -n1 GNU assembler (GNU Binutils for Debian) 2.35.1 Maybe GAS should not need to be told -gdwarf-5 to parse these? Then we would not need to pass -Wa,-gdwarf-5 via clang with -no-integrated-as.
On Fri, Jan 29, 2021 at 12:55 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > On Fri, Jan 29, 2021 at 9:48 PM Nick Desaulniers > <ndesaulniers@google.com> wrote: > > > > On Fri, Jan 29, 2021 at 12:41 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > On Fri, Jan 29, 2021 at 8:43 PM Nick Desaulniers > > > <ndesaulniers@google.com> wrote: > > > > > > > > diff --git a/Makefile b/Makefile > > > > index 20141cd9319e..bed8b3b180b8 100644 > > > > --- a/Makefile > > > > +++ b/Makefile > > > > @@ -832,8 +832,20 @@ endif > > > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > > > > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > > > > > > > +# If using clang without the integrated assembler, we need to explicitly tell > > > > +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should > > > > +# detect whether the version of GAS supports DWARF v5. > > > > +ifdef CONFIG_CC_IS_CLANG > > > > +ifneq ($(LLVM_IAS),1) > > > > +ifeq ($(dwarf-version-y),5) > > > > +DEBUG_CFLAGS += -Wa,-gdwarf-5 > > > > > > I noticed double "-g -gdwarf-5 -g -gdwarf-5" (a different issue) and > > > that's why I looked again into the top-level Makefile. > > > > That's...unexpected. I don't see where that could be coming from. > > Can you tell me please what is the precise command line invocation of > > make and which source file you observed this on so that I can > > reproduce? > > > > That's everywhere... > > $ zstdgrep --color '\-g -gdwarf-5 -g -gdwarf-5' > build-log_5.11.0-rc5-8-amd64-clang12-lto.txt.zst > | wc -l > 29529 I'm not able to reproduce. $ make LLVM=1 -j72 V=1 2>&1 | grep dwarf ... clang ... -g -gdwarf-5 -Wa,-gdwarf-5 ... ... $ make LLVM=1 LLVM_IAS=1 -j72 V=1 2>&1 | grep dwarf ... clang ... -g -gdwarf-5 ... ... Can you tell me please what is the precise command line invocation of make and which source file you observed this on so that I can reproduce?
On Fri, Jan 29, 2021 at 01:05:56PM -0800, Nick Desaulniers wrote: > > Wasn't that fixed in GAS? > > https://sourceware.org/bugzilla/show_bug.cgi?id=27195 > > $ make LLVM=1 -j72 defconfig > $ ./scripts/config -e DEBUG_INFO -e DEBUG_INFO_DWARF5 > $ make LLVM=1 -j72 > ... > /tmp/init-d50d89.s: Assembler messages: > /tmp/init-d50d89.s:10: Error: file number less than one > /tmp/init-d50d89.s:11: Error: junk at end of line, first unrecognized > character is `m' > > which is https://sourceware.org/bugzilla/show_bug.cgi?id=25611. > > $ as --version | head -n1 > GNU assembler (GNU Binutils for Debian) 2.35.1 > > Maybe GAS should not need to be told -gdwarf-5 to parse these? Then > we would not need to pass -Wa,-gdwarf-5 via clang with > -no-integrated-as. That is what sw#27195 is about, just try current binutils 2.35, 2.36 or trunk branches. Jakub
On Fri, Jan 29, 2021 at 10:09 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Fri, Jan 29, 2021 at 12:55 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > On Fri, Jan 29, 2021 at 9:48 PM Nick Desaulniers > > <ndesaulniers@google.com> wrote: > > > > > > On Fri, Jan 29, 2021 at 12:41 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > On Fri, Jan 29, 2021 at 8:43 PM Nick Desaulniers > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > diff --git a/Makefile b/Makefile > > > > > index 20141cd9319e..bed8b3b180b8 100644 > > > > > --- a/Makefile > > > > > +++ b/Makefile > > > > > @@ -832,8 +832,20 @@ endif > > > > > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > > > > > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > > > > > > > > > +# If using clang without the integrated assembler, we need to explicitly tell > > > > > +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should > > > > > +# detect whether the version of GAS supports DWARF v5. > > > > > +ifdef CONFIG_CC_IS_CLANG > > > > > +ifneq ($(LLVM_IAS),1) > > > > > +ifeq ($(dwarf-version-y),5) > > > > > +DEBUG_CFLAGS += -Wa,-gdwarf-5 > > > > > > > > I noticed double "-g -gdwarf-5 -g -gdwarf-5" (a different issue) and > > > > that's why I looked again into the top-level Makefile. > > > > > > That's...unexpected. I don't see where that could be coming from. > > > Can you tell me please what is the precise command line invocation of > > > make and which source file you observed this on so that I can > > > reproduce? > > > > > > > That's everywhere... > > > > $ zstdgrep --color '\-g -gdwarf-5 -g -gdwarf-5' > > build-log_5.11.0-rc5-8-amd64-clang12-lto.txt.zst > > | wc -l > > 29529 > > I'm not able to reproduce. > > $ make LLVM=1 -j72 V=1 2>&1 | grep dwarf > ... > clang ... -g -gdwarf-5 -Wa,-gdwarf-5 ... > ... > > $ make LLVM=1 LLVM_IAS=1 -j72 V=1 2>&1 | grep dwarf > ... > clang ... -g -gdwarf-5 ... > ... > Hmm... I do not see in my current build "-Wa,-gdwarf-5" is passed with v6. $ grep '\-Wa,-gdwarf-5' build-log_5.11.0-rc5-10-amd64-clang12-lto-pgo.txt [ empty ] - Sedat > Can you tell me please what is the precise command line invocation of > make and which source file you observed this on so that I can > reproduce? > -- > Thanks, > ~Nick Desaulniers
On Fri, Jan 29, 2021 at 10:13 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > On Fri, Jan 29, 2021 at 10:09 PM Nick Desaulniers > <ndesaulniers@google.com> wrote: > > > > On Fri, Jan 29, 2021 at 12:55 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > On Fri, Jan 29, 2021 at 9:48 PM Nick Desaulniers > > > <ndesaulniers@google.com> wrote: > > > > > > > > On Fri, Jan 29, 2021 at 12:41 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > On Fri, Jan 29, 2021 at 8:43 PM Nick Desaulniers > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > diff --git a/Makefile b/Makefile > > > > > > index 20141cd9319e..bed8b3b180b8 100644 > > > > > > --- a/Makefile > > > > > > +++ b/Makefile > > > > > > @@ -832,8 +832,20 @@ endif > > > > > > > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > > > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > > > > > > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > > > > > > > > > > > +# If using clang without the integrated assembler, we need to explicitly tell > > > > > > +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should > > > > > > +# detect whether the version of GAS supports DWARF v5. > > > > > > +ifdef CONFIG_CC_IS_CLANG > > > > > > +ifneq ($(LLVM_IAS),1) > > > > > > +ifeq ($(dwarf-version-y),5) > > > > > > +DEBUG_CFLAGS += -Wa,-gdwarf-5 > > > > > > > > > > I noticed double "-g -gdwarf-5 -g -gdwarf-5" (a different issue) and > > > > > that's why I looked again into the top-level Makefile. > > > > > > > > That's...unexpected. I don't see where that could be coming from. > > > > Can you tell me please what is the precise command line invocation of > > > > make and which source file you observed this on so that I can > > > > reproduce? > > > > > > > > > > That's everywhere... > > > > > > $ zstdgrep --color '\-g -gdwarf-5 -g -gdwarf-5' > > > build-log_5.11.0-rc5-8-amd64-clang12-lto.txt.zst > > > | wc -l > > > 29529 > > > > I'm not able to reproduce. > > > > $ make LLVM=1 -j72 V=1 2>&1 | grep dwarf > > ... > > clang ... -g -gdwarf-5 -Wa,-gdwarf-5 ... > > ... > > > > $ make LLVM=1 LLVM_IAS=1 -j72 V=1 2>&1 | grep dwarf > > ... > > clang ... -g -gdwarf-5 ... > > ... > > > > Hmm... > > I do not see in my current build "-Wa,-gdwarf-5" is passed with v6. > > $ grep '\-Wa,-gdwarf-5' build-log_5.11.0-rc5-10-amd64-clang12-lto-pgo.txt > [ empty ] > That's the diff v5 -> v6... [ Makefile ] @@ -826,16 +829,23 @@ else DEBUG_CFLAGS += -g endif +ifneq ($(LLVM_IAS),1) +KBUILD_AFLAGS += -Wa,-gdwarf-2 +endif + dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) -# Binutils 2.35+ required for -gdwarf-4+ support. -dwarf-aflag := $(call as-option,-Wa$(comma)-gdwarf-$(dwarf-version-y)) -KBUILD_AFLAGS += $(dwarf-aflag) + +# If using clang without the integrated assembler, we need to explicitly tell +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should +# detect whether the version of GAS supports DWARF v5. ifdef CONFIG_CC_IS_CLANG ifneq ($(LLVM_IAS),1) -DEBUG_CFLAGS += $(dwarf-aflag) +ifeq ($(dwarf-version-y),5) +DEBUG_CFLAGS += -Wa,-gdwarf-5 +endif endif endif There is no more a dwarf-aflag / KBUILD_AFLAGS += $(dwarf-aflag) used. - Sedat - > > - Sedat > > > > > > Can you tell me please what is the precise command line invocation of > > make and which source file you observed this on so that I can > > reproduce? > > -- > > Thanks, > > ~Nick Desaulniers
On 2021-01-29, Nick Desaulniers wrote: >DWARF v5 is the latest standard of the DWARF debug info format. > >Feature detection of DWARF5 is onerous, especially given that we've >removed $(AS), so we must query $(CC) for DWARF5 assembler directive >support. > >The DWARF version of a binary can be validated with: >$ llvm-dwarfdump vmlinux | head -n 4 | grep version >or >$ readelf --debug-dump=info vmlinux 2>/dev/null | grep Version > >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: > 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... > >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. > >GNU `as` only recently gained support for specifying -gdwarf-5, so when >compiling with Clang but without Clang's integrated assembler >(LLVM_IAS=1 is not set), explicitly add -Wa,-gdwarf-5 to DEBUG_CFLAGS. > >Disabled for now if CONFIG_DEBUG_INFO_BTF is set; pahole doesn't yet >recognize the new additions to the DWARF debug info. Thanks to Sedat for >the report. > >Link: http://www.dwarfstd.org/doc/DWARF5.pdf >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 | 12 ++++++++++++ > include/asm-generic/vmlinux.lds.h | 6 +++++- > lib/Kconfig.debug | 18 ++++++++++++++++++ > scripts/test_dwarf5_support.sh | 8 ++++++++ > 4 files changed, 43 insertions(+), 1 deletion(-) > create mode 100755 scripts/test_dwarf5_support.sh > >diff --git a/Makefile b/Makefile >index 20141cd9319e..bed8b3b180b8 100644 >--- a/Makefile >+++ b/Makefile >@@ -832,8 +832,20 @@ endif > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 >+dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > >+# If using clang without the integrated assembler, we need to explicitly tell >+# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should >+# detect whether the version of GAS supports DWARF v5. >+ifdef CONFIG_CC_IS_CLANG >+ifneq ($(LLVM_IAS),1) >+ifeq ($(dwarf-version-y),5) >+DEBUG_CFLAGS += -Wa,-gdwarf-5 >+endif >+endif >+endif >+ > ifdef CONFIG_DEBUG_INFO_REDUCED > DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ > $(call cc-option,-fno-var-tracking) >diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h >index 34b7e0d2346c..f8d5455cd87f 100644 >--- a/include/asm-generic/vmlinux.lds.h >+++ b/include/asm-generic/vmlinux.lds.h >@@ -843,7 +843,11 @@ > .debug_types 0 : { *(.debug_types) } \ > /* DWARF 5 */ \ > .debug_macro 0 : { *(.debug_macro) } \ >- .debug_addr 0 : { *(.debug_addr) } >+ .debug_addr 0 : { *(.debug_addr) } \ >+ .debug_line_str 0 : { *(.debug_line_str) } \ >+ .debug_loclists 0 : { *(.debug_loclists) } \ >+ .debug_rnglists 0 : { *(.debug_rnglists) } \ >+ .debug_str_offsets 0 : { *(.debug_str_offsets) } Add .debug_names for -gdwarf-5 -gpubnames The internal linker script of GNU ld 2.36 will have it. https://sourceware.org/pipermail/binutils/2021-January/115064.html (Compilers don't generate .debug_sup, I added to GNU ld just for future-proof.). > /* Stabs debugging sections. */ > #define STABS_DEBUG \ >diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug >index 1850728b23e6..09146b1af20d 100644 >--- a/lib/Kconfig.debug >+++ b/lib/Kconfig.debug >@@ -273,6 +273,24 @@ config DEBUG_INFO_DWARF4 > It makes the debug information larger, but it significantly > improves the success of resolving variables in gdb on optimized code. > >+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, 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..1a00484d0b2e >--- /dev/null >+++ b/scripts/test_dwarf5_support.sh >@@ -0,0 +1,8 @@ >+#!/bin/sh >+# SPDX-License-Identifier: GPL-2.0 >+ >+# Test that assembler accepts -gdwarf-5 and .file 0 directives, which were bugs >+# in binutils < 2.35. >+# https://sourceware.org/bugzilla/show_bug.cgi?id=25612 >+# https://sourceware.org/bugzilla/show_bug.cgi?id=25614 >+echo '.file 0 "filename"' | $* -gdwarf-5 -Wa,-gdwarf-5 -c -x assembler -o /dev/null - >-- >2.30.0.365.g02bc693789-goog >
On Fri, Jan 29, 2021 at 1:11 PM Jakub Jelinek <jakub@redhat.com> wrote: > > On Fri, Jan 29, 2021 at 01:05:56PM -0800, Nick Desaulniers wrote: > > > Wasn't that fixed in GAS? > > > https://sourceware.org/bugzilla/show_bug.cgi?id=27195 > > > > $ make LLVM=1 -j72 defconfig > > $ ./scripts/config -e DEBUG_INFO -e DEBUG_INFO_DWARF5 > > $ make LLVM=1 -j72 > > ... > > /tmp/init-d50d89.s: Assembler messages: > > /tmp/init-d50d89.s:10: Error: file number less than one > > /tmp/init-d50d89.s:11: Error: junk at end of line, first unrecognized > > character is `m' > > > > which is https://sourceware.org/bugzilla/show_bug.cgi?id=25611. > > > > $ as --version | head -n1 > > GNU assembler (GNU Binutils for Debian) 2.35.1 > > > > Maybe GAS should not need to be told -gdwarf-5 to parse these? Then > > we would not need to pass -Wa,-gdwarf-5 via clang with > > -no-integrated-as. > > That is what sw#27195 is about, just try current binutils 2.35, 2.36 or > trunk branches. Ah, I see. Then I should update the script I add (scripts/test_dwarf5_support.sh) to feature detect that bug, since it's the latest of the bunch. Also, should update my comment to note that this requires binutils greater than 2.35.1 (which is what I have, which fails, since the backport landed in ... what?!) How was this backported to 2.35 (https://sourceware.org/bugzilla/show_bug.cgi?id=27195#c12, Jan 26 2021) when binutils-2_35_1 was tagged sept 19 2020? Or will there be a binutils 2.35.2 point release?
On Fri, Jan 29, 2021 at 1:52 PM Fangrui Song <maskray@google.com> wrote: > > On 2021-01-29, Nick Desaulniers wrote: > >diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h > >index 34b7e0d2346c..f8d5455cd87f 100644 > >--- a/include/asm-generic/vmlinux.lds.h > >+++ b/include/asm-generic/vmlinux.lds.h > >@@ -843,7 +843,11 @@ > > .debug_types 0 : { *(.debug_types) } \ > > /* DWARF 5 */ \ > > .debug_macro 0 : { *(.debug_macro) } \ > >- .debug_addr 0 : { *(.debug_addr) } > >+ .debug_addr 0 : { *(.debug_addr) } \ > >+ .debug_line_str 0 : { *(.debug_line_str) } \ > >+ .debug_loclists 0 : { *(.debug_loclists) } \ > >+ .debug_rnglists 0 : { *(.debug_rnglists) } \ > >+ .debug_str_offsets 0 : { *(.debug_str_offsets) } > > Add .debug_names for -gdwarf-5 -gpubnames > > The internal linker script of GNU ld 2.36 will have it. > https://sourceware.org/pipermail/binutils/2021-January/115064.html > > (Compilers don't generate .debug_sup, I added to GNU ld just for > future-proof.). If we don't use `-gpubnames`, do I need to future proof the kernel's linker script? YAGNI? :-P (Since I need to make changes anyways, ok, I will add it to be safe. Thanks for the sugguestion).
On Fri, Jan 29, 2021 at 1:20 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > On Fri, Jan 29, 2021 at 10:13 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > On Fri, Jan 29, 2021 at 10:09 PM Nick Desaulniers > > <ndesaulniers@google.com> wrote: > > > > > > On Fri, Jan 29, 2021 at 12:55 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > On Fri, Jan 29, 2021 at 9:48 PM Nick Desaulniers > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > On Fri, Jan 29, 2021 at 12:41 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > > > On Fri, Jan 29, 2021 at 8:43 PM Nick Desaulniers > > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > > > diff --git a/Makefile b/Makefile > > > > > > > index 20141cd9319e..bed8b3b180b8 100644 > > > > > > > --- a/Makefile > > > > > > > +++ b/Makefile > > > > > > > @@ -832,8 +832,20 @@ endif > > > > > > > > > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > > > > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > > > > > > > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > > > > > > > > > > > > > +# If using clang without the integrated assembler, we need to explicitly tell > > > > > > > +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should > > > > > > > +# detect whether the version of GAS supports DWARF v5. > > > > > > > +ifdef CONFIG_CC_IS_CLANG > > > > > > > +ifneq ($(LLVM_IAS),1) > > > > > > > +ifeq ($(dwarf-version-y),5) > > > > > > > +DEBUG_CFLAGS += -Wa,-gdwarf-5 > > > > > > > > > > > > I noticed double "-g -gdwarf-5 -g -gdwarf-5" (a different issue) and > > > > > > that's why I looked again into the top-level Makefile. > > > > > > > > > > That's...unexpected. I don't see where that could be coming from. > > > > > Can you tell me please what is the precise command line invocation of > > > > > make and which source file you observed this on so that I can > > > > > reproduce? > > > > > > > > > > > > > That's everywhere... > > > > > > > > $ zstdgrep --color '\-g -gdwarf-5 -g -gdwarf-5' > > > > build-log_5.11.0-rc5-8-amd64-clang12-lto.txt.zst > > > > | wc -l > > > > 29529 > > > > > > I'm not able to reproduce. > > > > > > $ make LLVM=1 -j72 V=1 2>&1 | grep dwarf > > > ... > > > clang ... -g -gdwarf-5 -Wa,-gdwarf-5 ... > > > ... > > > > > > $ make LLVM=1 LLVM_IAS=1 -j72 V=1 2>&1 | grep dwarf > > > ... > > > clang ... -g -gdwarf-5 ... > > > ... > > > > > > > Hmm... > > > > I do not see in my current build "-Wa,-gdwarf-5" is passed with v6. > > > > $ grep '\-Wa,-gdwarf-5' build-log_5.11.0-rc5-10-amd64-clang12-lto-pgo.txt > > [ empty ] > > > > That's the diff v5 -> v6... > > There is no more a dwarf-aflag / KBUILD_AFLAGS += $(dwarf-aflag) used. Yep; not sure that's relevant though to duplicate flags? > > > Can you tell me please what is the precise command line invocation of > > > make and which source file you observed this on so that I can > > > reproduce? If you don't send me your invocation of `make`, I cannot help you.
On Fri, Jan 29, 2021 at 02:05:59PM -0800, Nick Desaulniers wrote: > Ah, I see. Then I should update the script I add > (scripts/test_dwarf5_support.sh) to feature detect that bug, since > it's the latest of the bunch. Also, should update my comment to note > that this requires binutils greater than 2.35.1 (which is what I have, > which fails, since the backport landed in ... what?!) How was this > backported to 2.35 > (https://sourceware.org/bugzilla/show_bug.cgi?id=27195#c12, Jan 26 > 2021) when binutils-2_35_1 was tagged sept 19 2020? Or will there be > a binutils 2.35.2 point release? AFAIK yes, soon. Jakub
On Fri, Jan 29, 2021 at 11:09 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Fri, Jan 29, 2021 at 1:20 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > On Fri, Jan 29, 2021 at 10:13 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > On Fri, Jan 29, 2021 at 10:09 PM Nick Desaulniers > > > <ndesaulniers@google.com> wrote: > > > > > > > > On Fri, Jan 29, 2021 at 12:55 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > On Fri, Jan 29, 2021 at 9:48 PM Nick Desaulniers > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > On Fri, Jan 29, 2021 at 12:41 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > > > > > On Fri, Jan 29, 2021 at 8:43 PM Nick Desaulniers > > > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > > > > > diff --git a/Makefile b/Makefile > > > > > > > > index 20141cd9319e..bed8b3b180b8 100644 > > > > > > > > --- a/Makefile > > > > > > > > +++ b/Makefile > > > > > > > > @@ -832,8 +832,20 @@ endif > > > > > > > > > > > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > > > > > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > > > > > > > > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > > > > > > > > > > > > > > > +# If using clang without the integrated assembler, we need to explicitly tell > > > > > > > > +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should > > > > > > > > +# detect whether the version of GAS supports DWARF v5. > > > > > > > > +ifdef CONFIG_CC_IS_CLANG > > > > > > > > +ifneq ($(LLVM_IAS),1) > > > > > > > > +ifeq ($(dwarf-version-y),5) > > > > > > > > +DEBUG_CFLAGS += -Wa,-gdwarf-5 > > > > > > > > > > > > > > I noticed double "-g -gdwarf-5 -g -gdwarf-5" (a different issue) and > > > > > > > that's why I looked again into the top-level Makefile. > > > > > > > > > > > > That's...unexpected. I don't see where that could be coming from. > > > > > > Can you tell me please what is the precise command line invocation of > > > > > > make and which source file you observed this on so that I can > > > > > > reproduce? > > > > > > > > > > > > > > > > That's everywhere... > > > > > > > > > > $ zstdgrep --color '\-g -gdwarf-5 -g -gdwarf-5' > > > > > build-log_5.11.0-rc5-8-amd64-clang12-lto.txt.zst > > > > > | wc -l > > > > > 29529 > > > > > > > > I'm not able to reproduce. > > > > > > > > $ make LLVM=1 -j72 V=1 2>&1 | grep dwarf > > > > ... > > > > clang ... -g -gdwarf-5 -Wa,-gdwarf-5 ... > > > > ... > > > > > > > > $ make LLVM=1 LLVM_IAS=1 -j72 V=1 2>&1 | grep dwarf > > > > ... > > > > clang ... -g -gdwarf-5 ... > > > > ... > > > > > > > > > > Hmm... > > > > > > I do not see in my current build "-Wa,-gdwarf-5" is passed with v6. > > > > > > $ grep '\-Wa,-gdwarf-5' build-log_5.11.0-rc5-10-amd64-clang12-lto-pgo.txt > > > [ empty ] > > > > > > > That's the diff v5 -> v6... > > > > There is no more a dwarf-aflag / KBUILD_AFLAGS += $(dwarf-aflag) used. > > Yep; not sure that's relevant though to duplicate flags? > > > > > Can you tell me please what is the precise command line invocation of > > > > make and which source file you observed this on so that I can > > > > reproduce? > > If you don't send me your invocation of `make`, I cannot help you. > /usr/bin/perf_5.10 stat make V=1 -j4 LLVM=1 LLVM_IAS=1 PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-10-amd64-clang12 -lto-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza KBUILD_BUILD_USER=sedat.dilek@gmail.com KBUILD_BUILD_TIMESTAMP=2021-01-29 bindeb-pkg KDEB_PKGVERSION=5.11.0~rc5-10~bullseye+dileks1 - Sedat -
On Fri, Jan 29, 2021 at 2:11 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > On Fri, Jan 29, 2021 at 11:09 PM Nick Desaulniers > <ndesaulniers@google.com> wrote: > > > > On Fri, Jan 29, 2021 at 1:20 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > On Fri, Jan 29, 2021 at 10:13 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > On Fri, Jan 29, 2021 at 10:09 PM Nick Desaulniers > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > On Fri, Jan 29, 2021 at 12:55 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > > > On Fri, Jan 29, 2021 at 9:48 PM Nick Desaulniers > > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > > > On Fri, Jan 29, 2021 at 12:41 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > > > > > > > On Fri, Jan 29, 2021 at 8:43 PM Nick Desaulniers > > > > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > > > > > > > diff --git a/Makefile b/Makefile > > > > > > > > > index 20141cd9319e..bed8b3b180b8 100644 > > > > > > > > > --- a/Makefile > > > > > > > > > +++ b/Makefile > > > > > > > > > @@ -832,8 +832,20 @@ endif > > > > > > > > > > > > > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > > > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > > > > > > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > > > > > > > > > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > > > > > > > > > > > > > > > > > +# If using clang without the integrated assembler, we need to explicitly tell > > > > > > > > > +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should > > > > > > > > > +# detect whether the version of GAS supports DWARF v5. > > > > > > > > > +ifdef CONFIG_CC_IS_CLANG > > > > > > > > > +ifneq ($(LLVM_IAS),1) > > > > > > > > > +ifeq ($(dwarf-version-y),5) > > > > > > > > > +DEBUG_CFLAGS += -Wa,-gdwarf-5 > > > > > > > > > > > > > > > > I noticed double "-g -gdwarf-5 -g -gdwarf-5" (a different issue) and > > > > > > > > that's why I looked again into the top-level Makefile. > > > > > > > > > > > > > > That's...unexpected. I don't see where that could be coming from. > > > > > > > Can you tell me please what is the precise command line invocation of > > > > > > > make and which source file you observed this on so that I can > > > > > > > reproduce? > > > > > > > > > > > > > > > > > > > That's everywhere... > > > > > > > > > > > > $ zstdgrep --color '\-g -gdwarf-5 -g -gdwarf-5' > > > > > > build-log_5.11.0-rc5-8-amd64-clang12-lto.txt.zst > > > > > > | wc -l > > > > > > 29529 > > > > > > > > > > I'm not able to reproduce. > > > > > > > > > > $ make LLVM=1 -j72 V=1 2>&1 | grep dwarf > > > > > ... > > > > > clang ... -g -gdwarf-5 -Wa,-gdwarf-5 ... > > > > > ... > > > > > > > > > > $ make LLVM=1 LLVM_IAS=1 -j72 V=1 2>&1 | grep dwarf > > > > > ... > > > > > clang ... -g -gdwarf-5 ... > > > > > ... > > > > > > > > > > > > > Hmm... > > > > > > > > I do not see in my current build "-Wa,-gdwarf-5" is passed with v6. > > > > > > > > $ grep '\-Wa,-gdwarf-5' build-log_5.11.0-rc5-10-amd64-clang12-lto-pgo.txt > > > > [ empty ] > > > > > > > > > > That's the diff v5 -> v6... > > > > > > There is no more a dwarf-aflag / KBUILD_AFLAGS += $(dwarf-aflag) used. > > > > Yep; not sure that's relevant though to duplicate flags? > > > > > > > Can you tell me please what is the precise command line invocation of > > > > > make and which source file you observed this on so that I can > > > > > reproduce? > > > > If you don't send me your invocation of `make`, I cannot help you. > > > > /usr/bin/perf_5.10 stat make V=1 -j4 LLVM=1 LLVM_IAS=1 > PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-10-amd64-clang12 > -lto-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza > KBUILD_BUILD_USER=sedat.dilek@gmail.com > KBUILD_BUILD_TIMESTAMP=2021-01-29 bindeb-pkg > KDEB_PKGVERSION=5.11.0~rc5-10~bullseye+dileks1 $ make LLVM=1 LLVM_IAS=1 -j72 defconfig $ make LLVM=1 LLVM_IAS=1 -j72 menuconfig <enable CONFIG_DEBUG_INFO and CONFIG_DEBUG_INFO_DWARF5> $ make LLVM=1 LLVM_IAS=1 -j72 V=1 &> log.txt $ grep '\-g -gdwarf-5 -g -gdwarf-5' log.txt | wc -l 0 $ grep '\-g -gdwarf-5' log.txt | wc -l 2517 Do have the patch applied twice, perhaps? Is your compiler haunted, or is mine? (haha! they both are; false dichotomy; they are one in the same). Is zstdgrep haunted, or is GNU grep haunted? :P
On Fri, Jan 29, 2021 at 11:21 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Fri, Jan 29, 2021 at 2:11 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > On Fri, Jan 29, 2021 at 11:09 PM Nick Desaulniers > > <ndesaulniers@google.com> wrote: > > > > > > On Fri, Jan 29, 2021 at 1:20 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > On Fri, Jan 29, 2021 at 10:13 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > On Fri, Jan 29, 2021 at 10:09 PM Nick Desaulniers > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > On Fri, Jan 29, 2021 at 12:55 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > > > > > On Fri, Jan 29, 2021 at 9:48 PM Nick Desaulniers > > > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > > > > > On Fri, Jan 29, 2021 at 12:41 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > > > > > > > > > On Fri, Jan 29, 2021 at 8:43 PM Nick Desaulniers > > > > > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > > > > > > > > > diff --git a/Makefile b/Makefile > > > > > > > > > > index 20141cd9319e..bed8b3b180b8 100644 > > > > > > > > > > --- a/Makefile > > > > > > > > > > +++ b/Makefile > > > > > > > > > > @@ -832,8 +832,20 @@ endif > > > > > > > > > > > > > > > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > > > > > > > > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > > > > > > > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > > > > > > > > > > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > > > > > > > > > > > > > > > > > > > +# If using clang without the integrated assembler, we need to explicitly tell > > > > > > > > > > +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should > > > > > > > > > > +# detect whether the version of GAS supports DWARF v5. > > > > > > > > > > +ifdef CONFIG_CC_IS_CLANG > > > > > > > > > > +ifneq ($(LLVM_IAS),1) > > > > > > > > > > +ifeq ($(dwarf-version-y),5) > > > > > > > > > > +DEBUG_CFLAGS += -Wa,-gdwarf-5 > > > > > > > > > > > > > > > > > > I noticed double "-g -gdwarf-5 -g -gdwarf-5" (a different issue) and > > > > > > > > > that's why I looked again into the top-level Makefile. > > > > > > > > > > > > > > > > That's...unexpected. I don't see where that could be coming from. > > > > > > > > Can you tell me please what is the precise command line invocation of > > > > > > > > make and which source file you observed this on so that I can > > > > > > > > reproduce? > > > > > > > > > > > > > > > > > > > > > > That's everywhere... > > > > > > > > > > > > > > $ zstdgrep --color '\-g -gdwarf-5 -g -gdwarf-5' > > > > > > > build-log_5.11.0-rc5-8-amd64-clang12-lto.txt.zst > > > > > > > | wc -l > > > > > > > 29529 > > > > > > > > > > > > I'm not able to reproduce. > > > > > > > > > > > > $ make LLVM=1 -j72 V=1 2>&1 | grep dwarf > > > > > > ... > > > > > > clang ... -g -gdwarf-5 -Wa,-gdwarf-5 ... > > > > > > ... > > > > > > > > > > > > $ make LLVM=1 LLVM_IAS=1 -j72 V=1 2>&1 | grep dwarf > > > > > > ... > > > > > > clang ... -g -gdwarf-5 ... > > > > > > ... > > > > > > > > > > > > > > > > Hmm... > > > > > > > > > > I do not see in my current build "-Wa,-gdwarf-5" is passed with v6. > > > > > > > > > > $ grep '\-Wa,-gdwarf-5' build-log_5.11.0-rc5-10-amd64-clang12-lto-pgo.txt > > > > > [ empty ] > > > > > > > > > > > > > That's the diff v5 -> v6... > > > > > > > > There is no more a dwarf-aflag / KBUILD_AFLAGS += $(dwarf-aflag) used. > > > > > > Yep; not sure that's relevant though to duplicate flags? > > > > > > > > > Can you tell me please what is the precise command line invocation of > > > > > > make and which source file you observed this on so that I can > > > > > > reproduce? > > > > > > If you don't send me your invocation of `make`, I cannot help you. > > > > > > > /usr/bin/perf_5.10 stat make V=1 -j4 LLVM=1 LLVM_IAS=1 > > PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-10-amd64-clang12 > > -lto-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza > > KBUILD_BUILD_USER=sedat.dilek@gmail.com > > KBUILD_BUILD_TIMESTAMP=2021-01-29 bindeb-pkg > > KDEB_PKGVERSION=5.11.0~rc5-10~bullseye+dileks1 > > $ make LLVM=1 LLVM_IAS=1 -j72 defconfig > $ make LLVM=1 LLVM_IAS=1 -j72 menuconfig > <enable CONFIG_DEBUG_INFO and CONFIG_DEBUG_INFO_DWARF5> > $ make LLVM=1 LLVM_IAS=1 -j72 V=1 &> log.txt > $ grep '\-g -gdwarf-5 -g -gdwarf-5' log.txt | wc -l > 0 > $ grep '\-g -gdwarf-5' log.txt | wc -l > 2517 > > Do have the patch applied twice, perhaps? > > Is your compiler haunted, or is mine? (haha! they both are; false > dichotomy; they are one in the same). Is zstdgrep haunted, or is GNU > grep haunted? :P > Switched to my v6 local Git branch and invoked above make line I gave you. I still see that double. Looks like I need some "undrunken" switch. - Sedat -
On Fri, Jan 29, 2021 at 1:11 PM Jakub Jelinek <jakub@redhat.com> wrote: > > On Fri, Jan 29, 2021 at 01:05:56PM -0800, Nick Desaulniers wrote: > > > Wasn't that fixed in GAS? > > > https://sourceware.org/bugzilla/show_bug.cgi?id=27195 > > > > $ make LLVM=1 -j72 defconfig > > $ ./scripts/config -e DEBUG_INFO -e DEBUG_INFO_DWARF5 > > $ make LLVM=1 -j72 > > ... > > /tmp/init-d50d89.s: Assembler messages: > > /tmp/init-d50d89.s:10: Error: file number less than one > > /tmp/init-d50d89.s:11: Error: junk at end of line, first unrecognized > > character is `m' > > > > which is https://sourceware.org/bugzilla/show_bug.cgi?id=25611. > > > > $ as --version | head -n1 > > GNU assembler (GNU Binutils for Debian) 2.35.1 > > > > Maybe GAS should not need to be told -gdwarf-5 to parse these? Then > > we would not need to pass -Wa,-gdwarf-5 via clang with > > -no-integrated-as. > > That is what sw#27195 is about, just try current binutils 2.35, 2.36 or > trunk branches. Ok, yep, I can confirm. I just built ToT binutils and I no longer need to specify -Wa,-gdwarf-5 when building with clang with -no-integrated-as. I will update scripts/test_dwarf5_support.sh to check for that and update the comments/documentation/commit messages to say binutils 2.35.2+, link to https://sourceware.org/bugzilla/show_bug.cgi?id=27195 instead, then drop hunk that was passing -Wa,-gdwarf-5.
On Fri, Jan 29, 2021 at 2:23 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > On Fri, Jan 29, 2021 at 11:21 PM Nick Desaulniers > <ndesaulniers@google.com> wrote: > > > > On Fri, Jan 29, 2021 at 2:11 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > On Fri, Jan 29, 2021 at 11:09 PM Nick Desaulniers > > > <ndesaulniers@google.com> wrote: > > > > > > > > On Fri, Jan 29, 2021 at 1:20 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > On Fri, Jan 29, 2021 at 10:13 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > > > On Fri, Jan 29, 2021 at 10:09 PM Nick Desaulniers > > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > > > Can you tell me please what is the precise command line invocation of > > > > > > > make and which source file you observed this on so that I can > > > > > > > reproduce? > > > > > > > > If you don't send me your invocation of `make`, I cannot help you. > > > > > > > > > > /usr/bin/perf_5.10 stat make V=1 -j4 LLVM=1 LLVM_IAS=1 > > > PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-10-amd64-clang12 > > > -lto-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza > > > KBUILD_BUILD_USER=sedat.dilek@gmail.com > > > KBUILD_BUILD_TIMESTAMP=2021-01-29 bindeb-pkg > > > KDEB_PKGVERSION=5.11.0~rc5-10~bullseye+dileks1 > > > > $ make LLVM=1 LLVM_IAS=1 -j72 defconfig > > $ make LLVM=1 LLVM_IAS=1 -j72 menuconfig > > <enable CONFIG_DEBUG_INFO and CONFIG_DEBUG_INFO_DWARF5> > > $ make LLVM=1 LLVM_IAS=1 -j72 V=1 &> log.txt > > $ grep '\-g -gdwarf-5 -g -gdwarf-5' log.txt | wc -l > > 0 > > $ grep '\-g -gdwarf-5' log.txt | wc -l > > 2517 > > > > Do have the patch applied twice, perhaps? > > > > Switched to my v6 local Git branch and invoked above make line I gave you. > I still see that double. > Looks like I need some "undrunken" switch. Can you follow my steps precisely to see whether it's your .config? Perhaps there is a config that duplicates DEBUG_CFLAGS that is not set in the defconfig? If so, it's still harmless to specify the same commands twice, and likely isn't introduced by this patch set if so; so I'm not sure how much more effort is worth pursuing.
On Fri, Jan 29, 2021 at 11:31 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Fri, Jan 29, 2021 at 2:23 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > On Fri, Jan 29, 2021 at 11:21 PM Nick Desaulniers > > <ndesaulniers@google.com> wrote: > > > > > > On Fri, Jan 29, 2021 at 2:11 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > On Fri, Jan 29, 2021 at 11:09 PM Nick Desaulniers > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > On Fri, Jan 29, 2021 at 1:20 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > > > On Fri, Jan 29, 2021 at 10:13 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > > > > > On Fri, Jan 29, 2021 at 10:09 PM Nick Desaulniers > > > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > > > > > Can you tell me please what is the precise command line invocation of > > > > > > > > make and which source file you observed this on so that I can > > > > > > > > reproduce? > > > > > > > > > > If you don't send me your invocation of `make`, I cannot help you. > > > > > > > > > > > > > /usr/bin/perf_5.10 stat make V=1 -j4 LLVM=1 LLVM_IAS=1 > > > > PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-10-amd64-clang12 > > > > -lto-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza > > > > KBUILD_BUILD_USER=sedat.dilek@gmail.com > > > > KBUILD_BUILD_TIMESTAMP=2021-01-29 bindeb-pkg > > > > KDEB_PKGVERSION=5.11.0~rc5-10~bullseye+dileks1 > > > > > > $ make LLVM=1 LLVM_IAS=1 -j72 defconfig > > > $ make LLVM=1 LLVM_IAS=1 -j72 menuconfig > > > <enable CONFIG_DEBUG_INFO and CONFIG_DEBUG_INFO_DWARF5> > > > $ make LLVM=1 LLVM_IAS=1 -j72 V=1 &> log.txt > > > $ grep '\-g -gdwarf-5 -g -gdwarf-5' log.txt | wc -l > > > 0 > > > $ grep '\-g -gdwarf-5' log.txt | wc -l > > > 2517 > > > > > > Do have the patch applied twice, perhaps? > > > > > > > Switched to my v6 local Git branch and invoked above make line I gave you. > > I still see that double. > > Looks like I need some "undrunken" switch. > > Can you follow my steps precisely to see whether it's your .config? > Perhaps there is a config that duplicates DEBUG_CFLAGS that is not set > in the defconfig? If so, it's still harmless to specify the same > commands twice, and likely isn't introduced by this patch set if so; > so I'm not sure how much more effort is worth pursuing. > If I follow your steps of make I do not see it "double" (in my local v6 Git branch). Looks like this is coming from my build-script. I checked if I have some double dwarf(-5) patches double - Nope. - Sedat -
On 2021-01-29, Nick Desaulniers wrote: >DWARF v5 is the latest standard of the DWARF debug info format. > >Feature detection of DWARF5 is onerous, especially given that we've >removed $(AS), so we must query $(CC) for DWARF5 assembler directive >support. > >The DWARF version of a binary can be validated with: >$ llvm-dwarfdump vmlinux | head -n 4 | grep version >or >$ readelf --debug-dump=info vmlinux 2>/dev/null | grep Version > >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: > 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... > >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. > >GNU `as` only recently gained support for specifying -gdwarf-5, so when >compiling with Clang but without Clang's integrated assembler >(LLVM_IAS=1 is not set), explicitly add -Wa,-gdwarf-5 to DEBUG_CFLAGS. > >Disabled for now if CONFIG_DEBUG_INFO_BTF is set; pahole doesn't yet >recognize the new additions to the DWARF debug info. Thanks to Sedat for >the report. > >Link: http://www.dwarfstd.org/doc/DWARF5.pdf >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 | 12 ++++++++++++ > include/asm-generic/vmlinux.lds.h | 6 +++++- > lib/Kconfig.debug | 18 ++++++++++++++++++ > scripts/test_dwarf5_support.sh | 8 ++++++++ > 4 files changed, 43 insertions(+), 1 deletion(-) > create mode 100755 scripts/test_dwarf5_support.sh > >diff --git a/Makefile b/Makefile >index 20141cd9319e..bed8b3b180b8 100644 >--- a/Makefile >+++ b/Makefile >@@ -832,8 +832,20 @@ endif > > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 >+dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 > DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > >+# If using clang without the integrated assembler, we need to explicitly tell >+# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should >+# detect whether the version of GAS supports DWARF v5. >+ifdef CONFIG_CC_IS_CLANG >+ifneq ($(LLVM_IAS),1) >+ifeq ($(dwarf-version-y),5) >+DEBUG_CFLAGS += -Wa,-gdwarf-5 >+endif >+endif >+endif >+ > ifdef CONFIG_DEBUG_INFO_REDUCED > DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ > $(call cc-option,-fno-var-tracking) >diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h >index 34b7e0d2346c..f8d5455cd87f 100644 >--- a/include/asm-generic/vmlinux.lds.h >+++ b/include/asm-generic/vmlinux.lds.h >@@ -843,7 +843,11 @@ > .debug_types 0 : { *(.debug_types) } \ > /* DWARF 5 */ \ > .debug_macro 0 : { *(.debug_macro) } \ >- .debug_addr 0 : { *(.debug_addr) } >+ .debug_addr 0 : { *(.debug_addr) } \ >+ .debug_line_str 0 : { *(.debug_line_str) } \ >+ .debug_loclists 0 : { *(.debug_loclists) } \ >+ .debug_rnglists 0 : { *(.debug_rnglists) } \ >+ .debug_str_offsets 0 : { *(.debug_str_offsets) } > > /* Stabs debugging sections. */ > #define STABS_DEBUG \ >diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug >index 1850728b23e6..09146b1af20d 100644 >--- a/lib/Kconfig.debug >+++ b/lib/Kconfig.debug >@@ -273,6 +273,24 @@ config DEBUG_INFO_DWARF4 > It makes the debug information larger, but it significantly > improves the success of resolving variables in gdb on optimized code. > >+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, 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..1a00484d0b2e >--- /dev/null >+++ b/scripts/test_dwarf5_support.sh >@@ -0,0 +1,8 @@ >+#!/bin/sh >+# SPDX-License-Identifier: GPL-2.0 >+ >+# Test that assembler accepts -gdwarf-5 and .file 0 directives, which were bugs >+# in binutils < 2.35. >+# https://sourceware.org/bugzilla/show_bug.cgi?id=25612 >+# https://sourceware.org/bugzilla/show_bug.cgi?id=25614 >+echo '.file 0 "filename"' | $* -gdwarf-5 -Wa,-gdwarf-5 -c -x assembler -o /dev/null - >-- >2.30.0.365.g02bc693789-goog > Since the other thread suggested that you keep just DWARF v4 and v5 and drop DWARF v2, you'll need v7... I suggest: Change the -Wa,-gdwarf-2 logic to add either -Wa,-gdwarf-4 or -Wa,-gdwarf-5 and drop the CONFIG_CC_IS_CLANG ifdef. (CONFIG_CC_IS_CLANG is there because clang -Wa,-gdwarf-2 does not allow DW_AT_ranges which is not in DWARF v2). GNU as before 2020 did not support -gdwarf-[345] (https://sourceware.org/bugzilla/show_bug.cgi?id=25612), so you can make -Wa,-gdwarf-2 a DWARF v4 workaround for older GNU as.
On Fri, Jan 29, 2021 at 2:10 PM Jakub Jelinek <jakub@redhat.com> wrote: > > On Fri, Jan 29, 2021 at 02:05:59PM -0800, Nick Desaulniers wrote: > > Ah, I see. Then I should update the script I add > > (scripts/test_dwarf5_support.sh) to feature detect that bug, since > > it's the latest of the bunch. Also, should update my comment to note > > that this requires binutils greater than 2.35.1 (which is what I have, > > which fails, since the backport landed in ... what?!) How was this > > backported to 2.35 > > (https://sourceware.org/bugzilla/show_bug.cgi?id=27195#c12, Jan 26 > > 2021) when binutils-2_35_1 was tagged sept 19 2020? Or will there be > > a binutils 2.35.2 point release? > > AFAIK yes, soon. Err...perhaps https://sourceware.org/bugzilla/show_bug.cgi?id=27195 was about `.file 0`, but it looks like `.file 1 "filename" md5 0x7a0b65214090b6693bd1dc24dd248245` without -gdwarf-5. Specifically the md5 ... . So https://sourceware.org/bugzilla/show_bug.cgi?id=25611 needs a rework perhaps?
On Fri, Jan 29, 2021 at 3:25 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Fri, Jan 29, 2021 at 2:10 PM Jakub Jelinek <jakub@redhat.com> wrote: > > > > On Fri, Jan 29, 2021 at 02:05:59PM -0800, Nick Desaulniers wrote: > > > Ah, I see. Then I should update the script I add > > > (scripts/test_dwarf5_support.sh) to feature detect that bug, since > > > it's the latest of the bunch. Also, should update my comment to note > > > that this requires binutils greater than 2.35.1 (which is what I have, > > > which fails, since the backport landed in ... what?!) How was this > > > backported to 2.35 > > > (https://sourceware.org/bugzilla/show_bug.cgi?id=27195#c12, Jan 26 > > > 2021) when binutils-2_35_1 was tagged sept 19 2020? Or will there be > > > a binutils 2.35.2 point release? > > > > AFAIK yes, soon. > > Err...perhaps https://sourceware.org/bugzilla/show_bug.cgi?id=27195 > was about `.file 0`, but it looks like `.file 1 "filename" md5 > 0x7a0b65214090b6693bd1dc24dd248245` without -gdwarf-5. Specifically > the md5 ... . > > So https://sourceware.org/bugzilla/show_bug.cgi?id=25611 needs a rework perhaps? $ echo '.file 1 "filename" md5 0x7a0b65214090b6693bd1dc24dd248245' | binutils-gdb/gas/as - {standard input}: Assembler messages: {standard input}:1: Error: junk at end of line, first unrecognized character is `m' $ echo '.file 1 "filename" md5 0x7a0b65214090b6693bd1dc24dd248245' | binutils-gdb/gas/as -gdwarf-5 - $ https://sourceware.org/bugzilla/show_bug.cgi?id=27280
On Sat, Jan 30, 2021 at 7:42 AM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > On Fri, Jan 29, 2021 at 11:31 PM Nick Desaulniers > <ndesaulniers@google.com> wrote: > > > > On Fri, Jan 29, 2021 at 2:23 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > On Fri, Jan 29, 2021 at 11:21 PM Nick Desaulniers > > > <ndesaulniers@google.com> wrote: > > > > > > > > On Fri, Jan 29, 2021 at 2:11 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > On Fri, Jan 29, 2021 at 11:09 PM Nick Desaulniers > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > On Fri, Jan 29, 2021 at 1:20 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > > > > > On Fri, Jan 29, 2021 at 10:13 PM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > > > > > > > > > > > > > > On Fri, Jan 29, 2021 at 10:09 PM Nick Desaulniers > > > > > > > > <ndesaulniers@google.com> wrote: > > > > > > > > > > > > > > > > > > Can you tell me please what is the precise command line invocation of > > > > > > > > > make and which source file you observed this on so that I can > > > > > > > > > reproduce? > > > > > > > > > > > > If you don't send me your invocation of `make`, I cannot help you. > > > > > > > > > > > > > > > > /usr/bin/perf_5.10 stat make V=1 -j4 LLVM=1 LLVM_IAS=1 > > > > > PAHOLE=/opt/pahole/bin/pahole LOCALVERSION=-10-amd64-clang12 > > > > > -lto-pgo KBUILD_VERBOSE=1 KBUILD_BUILD_HOST=iniza > > > > > KBUILD_BUILD_USER=sedat.dilek@gmail.com > > > > > KBUILD_BUILD_TIMESTAMP=2021-01-29 bindeb-pkg > > > > > KDEB_PKGVERSION=5.11.0~rc5-10~bullseye+dileks1 > > > > > > > > $ make LLVM=1 LLVM_IAS=1 -j72 defconfig > > > > $ make LLVM=1 LLVM_IAS=1 -j72 menuconfig > > > > <enable CONFIG_DEBUG_INFO and CONFIG_DEBUG_INFO_DWARF5> > > > > $ make LLVM=1 LLVM_IAS=1 -j72 V=1 &> log.txt > > > > $ grep '\-g -gdwarf-5 -g -gdwarf-5' log.txt | wc -l > > > > 0 > > > > $ grep '\-g -gdwarf-5' log.txt | wc -l > > > > 2517 > > > > > > > > Do have the patch applied twice, perhaps? > > > > > > > > > > Switched to my v6 local Git branch and invoked above make line I gave you. > > > I still see that double. > > > Looks like I need some "undrunken" switch. > > > > Can you follow my steps precisely to see whether it's your .config? > > Perhaps there is a config that duplicates DEBUG_CFLAGS that is not set > > in the defconfig? If so, it's still harmless to specify the same > > commands twice, and likely isn't introduced by this patch set if so; > > so I'm not sure how much more effort is worth pursuing. > > > > If I follow your steps of make I do not see it "double" (in my local > v6 Git branch). > > Looks like this is coming from my build-script. > > I checked if I have some double dwarf(-5) patches double - Nope. Sorry for the late reply. I do not know which command you input, but this happens for deb-pkg builds for example. Please try this patch: https://lore.kernel.org/patchwork/patch/1374926/ -- Best Regards Masahiro Yamada
diff --git a/Makefile b/Makefile index 20141cd9319e..bed8b3b180b8 100644 --- a/Makefile +++ b/Makefile @@ -832,8 +832,20 @@ endif dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5 DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) +# If using clang without the integrated assembler, we need to explicitly tell +# GAS that we will be feeding it DWARF v5 assembler directives. Kconfig should +# detect whether the version of GAS supports DWARF v5. +ifdef CONFIG_CC_IS_CLANG +ifneq ($(LLVM_IAS),1) +ifeq ($(dwarf-version-y),5) +DEBUG_CFLAGS += -Wa,-gdwarf-5 +endif +endif +endif + ifdef CONFIG_DEBUG_INFO_REDUCED DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ $(call cc-option,-fno-var-tracking) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 34b7e0d2346c..f8d5455cd87f 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -843,7 +843,11 @@ .debug_types 0 : { *(.debug_types) } \ /* DWARF 5 */ \ .debug_macro 0 : { *(.debug_macro) } \ - .debug_addr 0 : { *(.debug_addr) } + .debug_addr 0 : { *(.debug_addr) } \ + .debug_line_str 0 : { *(.debug_line_str) } \ + .debug_loclists 0 : { *(.debug_loclists) } \ + .debug_rnglists 0 : { *(.debug_rnglists) } \ + .debug_str_offsets 0 : { *(.debug_str_offsets) } /* Stabs debugging sections. */ #define STABS_DEBUG \ diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 1850728b23e6..09146b1af20d 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -273,6 +273,24 @@ config DEBUG_INFO_DWARF4 It makes the debug information larger, but it significantly improves the success of resolving variables in gdb on optimized code. +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, 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..1a00484d0b2e --- /dev/null +++ b/scripts/test_dwarf5_support.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +# Test that assembler accepts -gdwarf-5 and .file 0 directives, which were bugs +# in binutils < 2.35. +# https://sourceware.org/bugzilla/show_bug.cgi?id=25612 +# https://sourceware.org/bugzilla/show_bug.cgi?id=25614 +echo '.file 0 "filename"' | $* -gdwarf-5 -Wa,-gdwarf-5 -c -x assembler -o /dev/null -
DWARF v5 is the latest standard of the DWARF debug info format. Feature detection of DWARF5 is onerous, especially given that we've removed $(AS), so we must query $(CC) for DWARF5 assembler directive support. The DWARF version of a binary can be validated with: $ llvm-dwarfdump vmlinux | head -n 4 | grep version or $ readelf --debug-dump=info vmlinux 2>/dev/null | grep Version 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: 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... 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. GNU `as` only recently gained support for specifying -gdwarf-5, so when compiling with Clang but without Clang's integrated assembler (LLVM_IAS=1 is not set), explicitly add -Wa,-gdwarf-5 to DEBUG_CFLAGS. Disabled for now if CONFIG_DEBUG_INFO_BTF is set; pahole doesn't yet recognize the new additions to the DWARF debug info. Thanks to Sedat for the report. Link: http://www.dwarfstd.org/doc/DWARF5.pdf 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 | 12 ++++++++++++ include/asm-generic/vmlinux.lds.h | 6 +++++- lib/Kconfig.debug | 18 ++++++++++++++++++ scripts/test_dwarf5_support.sh | 8 ++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 scripts/test_dwarf5_support.sh