Message ID | 20210129194318.2125748-2-ndesaulniers@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Kbuild: DWARF v5 support | expand |
On Fri, Jan 29, 2021 at 11:43:17AM -0800, Nick Desaulniers wrote: > Modifies CONFIG_DEBUG_INFO_DWARF4 to be a member of a choice. Adds an > explicit CONFIG_DEBUG_INFO_DWARF2, which is the default. Does so in a > way that's forward compatible with existing configs, and makes adding > future versions more straightforward. > > Suggested-by: Arvind Sankar <nivedita@alum.mit.edu> > Suggested-by: Fangrui Song <maskray@google.com> > Suggested-by: Nathan Chancellor <nathan@kernel.org> > Suggested-by: Masahiro Yamada <masahiroy@kernel.org> > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > --- > Makefile | 6 +++--- > lib/Kconfig.debug | 21 ++++++++++++++++----- > 2 files changed, 19 insertions(+), 8 deletions(-) > > diff --git a/Makefile b/Makefile > index 95ab9856f357..20141cd9319e 100644 > --- a/Makefile > +++ b/Makefile > @@ -830,9 +830,9 @@ ifneq ($(LLVM_IAS),1) > KBUILD_AFLAGS += -Wa,-gdwarf-2 > endif > > -ifdef CONFIG_DEBUG_INFO_DWARF4 > -DEBUG_CFLAGS += -gdwarf-4 > -endif > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > +DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) Why do you make DWARF2 the default? That seems a big step back from what the Makefile used to do before, where it defaulted to whatever DWARF version the compiler defaulted to? E.g. GCC 4.8 up to 10 defaults to -gdwarf-4 and GCC 11 will default to -gdwarf-5. DWARF2 is more than 27 years old standard, DWARF3 15 years old, DWARF4 over 10 years old and DWARF5 almost 4 years old... It is true that some tools aren't DWARF5 ready at this point, but with GCC defaulting to that it will change quickly, but at least DWARF4 support has been around for years. Jakub
On Fri, Jan 29, 2021 at 12:17 PM Jakub Jelinek <jakub@redhat.com> wrote: > > On Fri, Jan 29, 2021 at 11:43:17AM -0800, Nick Desaulniers wrote: > > Modifies CONFIG_DEBUG_INFO_DWARF4 to be a member of a choice. Adds an > > explicit CONFIG_DEBUG_INFO_DWARF2, which is the default. Does so in a > > way that's forward compatible with existing configs, and makes adding > > future versions more straightforward. > > > > Suggested-by: Arvind Sankar <nivedita@alum.mit.edu> > > Suggested-by: Fangrui Song <maskray@google.com> > > Suggested-by: Nathan Chancellor <nathan@kernel.org> > > Suggested-by: Masahiro Yamada <masahiroy@kernel.org> > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > > --- > > Makefile | 6 +++--- > > lib/Kconfig.debug | 21 ++++++++++++++++----- > > 2 files changed, 19 insertions(+), 8 deletions(-) > > > > diff --git a/Makefile b/Makefile > > index 95ab9856f357..20141cd9319e 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -830,9 +830,9 @@ ifneq ($(LLVM_IAS),1) > > KBUILD_AFLAGS += -Wa,-gdwarf-2 > > endif > > > > -ifdef CONFIG_DEBUG_INFO_DWARF4 > > -DEBUG_CFLAGS += -gdwarf-4 > > -endif > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > +DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > Why do you make DWARF2 the default? That seems a big step back from what > the Makefile used to do before, where it defaulted to whatever DWARF version > the compiler defaulted to? > E.g. GCC 4.8 up to 10 defaults to -gdwarf-4 and GCC 11 will default to > -gdwarf-5. > DWARF2 is more than 27 years old standard, DWARF3 15 years old, > DWARF4 over 10 years old and DWARF5 almost 4 years old... > It is true that some tools aren't DWARF5 ready at this point, but with GCC > defaulting to that it will change quickly, but at least DWARF4 support has > been around for years. I agree with you; I also do not want to change the existing defaults in this series. That is a separate issue to address.
On Fri, Jan 29, 2021 at 12:19 PM Nick Desaulniers <ndesaulniers@google.com> wrote: > > On Fri, Jan 29, 2021 at 12:17 PM Jakub Jelinek <jakub@redhat.com> wrote: > > > > On Fri, Jan 29, 2021 at 11:43:17AM -0800, Nick Desaulniers wrote: > > > Modifies CONFIG_DEBUG_INFO_DWARF4 to be a member of a choice. Adds an > > > explicit CONFIG_DEBUG_INFO_DWARF2, which is the default. Does so in a > > > way that's forward compatible with existing configs, and makes adding > > > future versions more straightforward. > > > > > > Suggested-by: Arvind Sankar <nivedita@alum.mit.edu> > > > Suggested-by: Fangrui Song <maskray@google.com> > > > Suggested-by: Nathan Chancellor <nathan@kernel.org> > > > Suggested-by: Masahiro Yamada <masahiroy@kernel.org> > > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > > > --- > > > Makefile | 6 +++--- > > > lib/Kconfig.debug | 21 ++++++++++++++++----- > > > 2 files changed, 19 insertions(+), 8 deletions(-) > > > > > > diff --git a/Makefile b/Makefile > > > index 95ab9856f357..20141cd9319e 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -830,9 +830,9 @@ ifneq ($(LLVM_IAS),1) > > > KBUILD_AFLAGS += -Wa,-gdwarf-2 > > > endif > > > > > > -ifdef CONFIG_DEBUG_INFO_DWARF4 > > > -DEBUG_CFLAGS += -gdwarf-4 > > > -endif > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > > +DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > > > Why do you make DWARF2 the default? That seems a big step back from what > > the Makefile used to do before, where it defaulted to whatever DWARF version > > the compiler defaulted to? > > E.g. GCC 4.8 up to 10 defaults to -gdwarf-4 and GCC 11 will default to > > -gdwarf-5. > > DWARF2 is more than 27 years old standard, DWARF3 15 years old, > > DWARF4 over 10 years old and DWARF5 almost 4 years old... > > It is true that some tools aren't DWARF5 ready at this point, but with GCC > > defaulting to that it will change quickly, but at least DWARF4 support has > > been around for years. > > I agree with you; I also do not want to change the existing defaults > in this series. That is a separate issue to address. Thinking more about this over lunch... I agree that DWARF v2 is quite old and I don't have a concrete reason why the Linux kernel should continue to support it in 2021. I agree that this patch takes away the compiler vendor's choice as to what the implicit default choice is for dwarf version for the kernel. (We, the Linux kernel, do so already for implicit default -std=gnuc* as well). I would not mind making this commit more explicit along the lines of: """ If you previously had not explicitly opted into CONFIG_DEBUG_INFO_DWARF4, you will be opted in to CONFIG_DEBUG_INFO_DWARF2 rather than the compiler's implicit default (which changes over time). """ If you would rather see dwarf4 be the explicit default, that can be done before or after this patch series, but to avoid further "rope-a-dope" over getting DWARFv5 enabled, I suggest waiting until after. If Masahiro or Arvind (or whoever) feel differently about preserving the previous "don't care" behavior related to DWARF version for developers who had previously not opted in to CONFIG_DEBUG_INFO_DWARF4, I can drop this patch, and resend v7 of 0002/0002 simply adding CONFIG_DEBUG_INFO_DWARF5 and making that and CONFIG_DEBUG_INFO_DWARF4 depend on ! each other (I think). But I'm going to suggest we follow the Zen of Python: explicit is better than implicit. Supporting "I choose not to choose (my dwarf version)" doesn't seem worthwhile to me, but could be convinced otherwise.
On Fri, Jan 29, 2021 at 12:57:20PM -0800, Nick Desaulniers wrote: > On Fri, Jan 29, 2021 at 12:19 PM Nick Desaulniers > <ndesaulniers@google.com> wrote: > > > > On Fri, Jan 29, 2021 at 12:17 PM Jakub Jelinek <jakub@redhat.com> wrote: > > > > > > On Fri, Jan 29, 2021 at 11:43:17AM -0800, Nick Desaulniers wrote: > > > > Modifies CONFIG_DEBUG_INFO_DWARF4 to be a member of a choice. Adds an > > > > explicit CONFIG_DEBUG_INFO_DWARF2, which is the default. Does so in a > > > > way that's forward compatible with existing configs, and makes adding > > > > future versions more straightforward. > > > > > > > > Suggested-by: Arvind Sankar <nivedita@alum.mit.edu> > > > > Suggested-by: Fangrui Song <maskray@google.com> > > > > Suggested-by: Nathan Chancellor <nathan@kernel.org> > > > > Suggested-by: Masahiro Yamada <masahiroy@kernel.org> > > > > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> > > > > --- > > > > Makefile | 6 +++--- > > > > lib/Kconfig.debug | 21 ++++++++++++++++----- > > > > 2 files changed, 19 insertions(+), 8 deletions(-) > > > > > > > > diff --git a/Makefile b/Makefile > > > > index 95ab9856f357..20141cd9319e 100644 > > > > --- a/Makefile > > > > +++ b/Makefile > > > > @@ -830,9 +830,9 @@ ifneq ($(LLVM_IAS),1) > > > > KBUILD_AFLAGS += -Wa,-gdwarf-2 > > > > endif > > > > > > > > -ifdef CONFIG_DEBUG_INFO_DWARF4 > > > > -DEBUG_CFLAGS += -gdwarf-4 > > > > -endif > > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 > > > > +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 > > > > +DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) > > > > > > Why do you make DWARF2 the default? That seems a big step back from what > > > the Makefile used to do before, where it defaulted to whatever DWARF version > > > the compiler defaulted to? > > > E.g. GCC 4.8 up to 10 defaults to -gdwarf-4 and GCC 11 will default to > > > -gdwarf-5. > > > DWARF2 is more than 27 years old standard, DWARF3 15 years old, > > > DWARF4 over 10 years old and DWARF5 almost 4 years old... > > > It is true that some tools aren't DWARF5 ready at this point, but with GCC > > > defaulting to that it will change quickly, but at least DWARF4 support has > > > been around for years. > > > > I agree with you; I also do not want to change the existing defaults > > in this series. That is a separate issue to address. > > Thinking more about this over lunch... > > I agree that DWARF v2 is quite old and I don't have a concrete reason > why the Linux kernel should continue to support it in 2021. > > I agree that this patch takes away the compiler vendor's choice as to > what the implicit default choice is for dwarf version for the kernel. > (We, the Linux kernel, do so already for implicit default -std=gnuc* > as well). > > I would not mind making this commit more explicit along the lines of: > """ > If you previously had not explicitly opted into > CONFIG_DEBUG_INFO_DWARF4, you will be opted in to > CONFIG_DEBUG_INFO_DWARF2 rather than the compiler's implicit default > (which changes over time). > """ > If you would rather see dwarf4 be the explicit default, that can be > done before or after this patch series, but to avoid further > "rope-a-dope" over getting DWARFv5 enabled, I suggest waiting until > after. > > If Masahiro or Arvind (or whoever) feel differently about preserving > the previous "don't care" behavior related to DWARF version for > developers who had previously not opted in to > CONFIG_DEBUG_INFO_DWARF4, I can drop this patch, and resend v7 of > 0002/0002 simply adding CONFIG_DEBUG_INFO_DWARF5 and making that and > CONFIG_DEBUG_INFO_DWARF4 depend on ! each other (I think). But I'm > going to suggest we follow the Zen of Python: explicit is better than > implicit. Supporting "I choose not to choose (my dwarf version)" > doesn't seem worthwhile to me, but could be convinced otherwise. > -- > Thanks, > ~Nick Desaulniers Given what Jakub is saying, i.e. it was previously impossible to get dwarf2 with gcc, and you get dwarf4 whether or not DEBUG_INFO_DWARF4 was actually selected, we should make the default choice DEBUG_INFO_DWARF4 with the new menu to avoid surprising users. We should probably just drop DWARF2 and make the menu in this patch have only DWARF4, and then add DWARF5 as the second choice. The menu is still a good thing for future-proofing even if it only has two options currently. Thanks.
On Fri, Jan 29, 2021 at 04:32:32PM -0500, Arvind Sankar wrote: > Given what Jakub is saying, i.e. it was previously impossible to get > dwarf2 with gcc, and you get dwarf4 whether or not DEBUG_INFO_DWARF4 was It isn't impossible to get it, -gdwarf-2 works, it is just not a very good choice (at least unless one knows some debug info consumer is not DWARF3 or later ready). Though, even gcc -gdwarf-2 will use many extensions from DWARF3 and later, as long as there is no way to describe stuff in DWARF2. -gstrict-dwarf option requests that no DWARF extensions are used. Jakub
On Fri, Jan 29, 2021 at 1:41 PM Jakub Jelinek <jakub@redhat.com> wrote: > > On Fri, Jan 29, 2021 at 04:32:32PM -0500, Arvind Sankar wrote: > > Given what Jakub is saying, i.e. it was previously impossible to get > > dwarf2 with gcc, and you get dwarf4 whether or not DEBUG_INFO_DWARF4 was > > It isn't impossible to get it, -gdwarf-2 works, it is just not a very good > choice (at least unless one knows some debug info consumer is not DWARF3 or > later ready). > Though, even gcc -gdwarf-2 will use many extensions from DWARF3 and later, > as long as there is no way to describe stuff in DWARF2. -gstrict-dwarf > option requests that no DWARF extensions are used. Playing with this in godbolt, it looks like the implicit default dwarf version changed from 2 to 4 in somewhere between the GCC 4.7.4 and 4.8.1 release. The precise version, and whether it was strictly that version or not doesn't matter much; the minimum supported version of GCC for building the kernel currently being 4.9 means that without specifying DEBUG_INFO_DWARF4, that all kernel developers regardless of toolchain and supported toolchain version have been building as DWARF v4 (implicitly, or explicitly). DWARF v2 is quite irrelevant then. Ok, so I think Arvind's suggestion of "make DEBUG_INFO_DWARF4 a menu option, just don't add a DEBUG_INFO_DWARF2" makes a lot of sense. Will drop DEBUG_INFO_DWARF2 in v7.
diff --git a/Makefile b/Makefile index 95ab9856f357..20141cd9319e 100644 --- a/Makefile +++ b/Makefile @@ -830,9 +830,9 @@ ifneq ($(LLVM_IAS),1) KBUILD_AFLAGS += -Wa,-gdwarf-2 endif -ifdef CONFIG_DEBUG_INFO_DWARF4 -DEBUG_CFLAGS += -gdwarf-4 -endif +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF2) := 2 +dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4 +DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y) ifdef CONFIG_DEBUG_INFO_REDUCED DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index e906ea906cb7..1850728b23e6 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -256,13 +256,24 @@ 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_DWARF2 + bool "Generate DWARF Version 2 debuginfo" + help + Generate DWARF v2 debug info. + 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+. + It makes the debug information larger, but it significantly + improves the success of resolving variables in gdb on optimized code. + +endchoice # "DWARF version" config DEBUG_INFO_BTF bool "Generate BTF typeinfo"
Modifies CONFIG_DEBUG_INFO_DWARF4 to be a member of a choice. Adds an explicit CONFIG_DEBUG_INFO_DWARF2, which is the default. Does so in a way that's forward compatible with existing configs, and makes adding future versions more straightforward. Suggested-by: Arvind Sankar <nivedita@alum.mit.edu> Suggested-by: Fangrui Song <maskray@google.com> Suggested-by: Nathan Chancellor <nathan@kernel.org> Suggested-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> --- Makefile | 6 +++--- lib/Kconfig.debug | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-)