diff mbox series

[v3,5/5] Makefile.debug: set -g unconditional on CONFIG_DEBUG_INFO_SPLIT

Message ID 20220907045907.484043-6-ndesaulniers@google.com (mailing list archive)
State New, archived
Headers show
Series fix debug info for asm and DEBUG_INFO_SPLIT | expand

Commit Message

Nick Desaulniers Sept. 7, 2022, 4:59 a.m. UTC
Dmitrii, Fangrui, and Mashahiro note:

  Before GCC 11 and Clang 12 -gsplit-dwarf implicitly uses -g2.

Fix CONFIG_DEBUG_INFO_SPLIT for gcc-11+ & clang-12+ which now need -g
specified in order for -gsplit-dwarf to work at all.

-gsplit-dwarf has been mutually exclusive with -g since support for
CONFIG_DEBUG_INFO_SPLIT was introduced in
commit 866ced950bcd ("kbuild: Support split debug info v4")
I don't think it ever needed to be.

Link: https://lore.kernel.org/lkml/20220815013317.26121-1-dmitrii.bundin.a@gmail.com/
Link: https://lore.kernel.org/lkml/CAK7LNARPAmsJD5XKAw7m_X2g7Fi-CAAsWDQiP7+ANBjkg7R7ng@mail.gmail.com/
Link: https://reviews.llvm.org/D80391
Cc: Andi Kleen <ak@linux.intel.com>
Reported-by: Dmitrii Bundin <dmitrii.bundin.a@gmail.com>
Reported-by: Fangrui Song <maskray@google.com>
Reported-by: Masahiro Yamada <masahiroy@kernel.org>
Suggested-by: Dmitrii Bundin <dmitrii.bundin.a@gmail.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
Changes v2 -> v3:
* Pick up Nathan's RB tag.

Changes v1 -> v2:
* Add reference to 866ced950bcd, cc Andi, in commit message.

 scripts/Makefile.debug | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Masahiro Yamada Sept. 9, 2022, 8:56 p.m. UTC | #1
On Wed, Sep 7, 2022 at 1:59 PM Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> Dmitrii, Fangrui, and Mashahiro note:
>
>   Before GCC 11 and Clang 12 -gsplit-dwarf implicitly uses -g2.
>
> Fix CONFIG_DEBUG_INFO_SPLIT for gcc-11+ & clang-12+ which now need -g
> specified in order for -gsplit-dwarf to work at all.
>
> -gsplit-dwarf has been mutually exclusive with -g since support for
> CONFIG_DEBUG_INFO_SPLIT was introduced in
> commit 866ced950bcd ("kbuild: Support split debug info v4")
> I don't think it ever needed to be.
>
> Link: https://lore.kernel.org/lkml/20220815013317.26121-1-dmitrii.bundin.a@gmail.com/
> Link: https://lore.kernel.org/lkml/CAK7LNARPAmsJD5XKAw7m_X2g7Fi-CAAsWDQiP7+ANBjkg7R7ng@mail.gmail.com/
> Link: https://reviews.llvm.org/D80391
> Cc: Andi Kleen <ak@linux.intel.com>
> Reported-by: Dmitrii Bundin <dmitrii.bundin.a@gmail.com>
> Reported-by: Fangrui Song <maskray@google.com>
> Reported-by: Masahiro Yamada <masahiroy@kernel.org>
> Suggested-by: Dmitrii Bundin <dmitrii.bundin.a@gmail.com>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> Changes v2 -> v3:
> * Pick up Nathan's RB tag.
>
> Changes v1 -> v2:
> * Add reference to 866ced950bcd, cc Andi, in commit message.
>
>  scripts/Makefile.debug | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/scripts/Makefile.debug b/scripts/Makefile.debug
> index 2845145c1220..c20f8f2e76bf 100644
> --- a/scripts/Makefile.debug
> +++ b/scripts/Makefile.debug
> @@ -1,10 +1,4 @@
> -DEBUG_CFLAGS   :=
> -
> -ifdef CONFIG_DEBUG_INFO_SPLIT
> -DEBUG_CFLAGS   += -gsplit-dwarf
> -else
> -debug-cflags-y += -g
> -endif
> +DEBUG_CFLAGS   := -g
>
>  debug-flags-$(CONFIG_DEBUG_INFO_DWARF4)        += -gdwarf-4
>  debug-flags-$(CONFIG_DEBUG_INFO_DWARF5)        += -gdwarf-5
> @@ -15,6 +9,8 @@ ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_AS_IS_GNU),yy)
>  KBUILD_AFLAGS  += $(addprefix -Wa$(comma), $(debug-flags-y))
>  endif
>
> +debug-flags-$(CONFIG_DEBUG_INFO_SPLIT) += -gsplit-dwarf
> +


This patch changes the behavior that is not mentioned in the commit log.




Previously, -gsplit-dwarf was passed only when compiling *.c files.
(DEBUG_CFLAGS).

Now it is passed also when compiling *.S files.
(debug-flags-y is appended to KBUILD_AFLAGS)


Please confirm if this makes sense, and if so,
please mention it in the commit log.



As far as I tested, I did not see this change was useful.

When *.S is compiled to *.o, *.dwo is also created,
but it does not contain any debug info.



>  ifdef CONFIG_DEBUG_INFO_REDUCED
>  DEBUG_CFLAGS   += -fno-var-tracking
>  ifdef CONFIG_CC_IS_GCC
> --
> 2.37.2.789.g6183377224-goog
>
Masahiro Yamada Sept. 9, 2022, 9:02 p.m. UTC | #2
On Sat, Sep 10, 2022 at 5:56 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Wed, Sep 7, 2022 at 1:59 PM Nick Desaulniers <ndesaulniers@google.com> wrote:
> >
> > Dmitrii, Fangrui, and Mashahiro note:
> >
> >   Before GCC 11 and Clang 12 -gsplit-dwarf implicitly uses -g2.
> >
> > Fix CONFIG_DEBUG_INFO_SPLIT for gcc-11+ & clang-12+ which now need -g
> > specified in order for -gsplit-dwarf to work at all.
> >
> > -gsplit-dwarf has been mutually exclusive with -g since support for
> > CONFIG_DEBUG_INFO_SPLIT was introduced in
> > commit 866ced950bcd ("kbuild: Support split debug info v4")
> > I don't think it ever needed to be.
> >
> > Link: https://lore.kernel.org/lkml/20220815013317.26121-1-dmitrii.bundin.a@gmail.com/
> > Link: https://lore.kernel.org/lkml/CAK7LNARPAmsJD5XKAw7m_X2g7Fi-CAAsWDQiP7+ANBjkg7R7ng@mail.gmail.com/
> > Link: https://reviews.llvm.org/D80391
> > Cc: Andi Kleen <ak@linux.intel.com>
> > Reported-by: Dmitrii Bundin <dmitrii.bundin.a@gmail.com>
> > Reported-by: Fangrui Song <maskray@google.com>
> > Reported-by: Masahiro Yamada <masahiroy@kernel.org>
> > Suggested-by: Dmitrii Bundin <dmitrii.bundin.a@gmail.com>
> > Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > ---
> > Changes v2 -> v3:
> > * Pick up Nathan's RB tag.
> >
> > Changes v1 -> v2:
> > * Add reference to 866ced950bcd, cc Andi, in commit message.
> >
> >  scripts/Makefile.debug | 10 +++-------
> >  1 file changed, 3 insertions(+), 7 deletions(-)
> >
> > diff --git a/scripts/Makefile.debug b/scripts/Makefile.debug
> > index 2845145c1220..c20f8f2e76bf 100644
> > --- a/scripts/Makefile.debug
> > +++ b/scripts/Makefile.debug
> > @@ -1,10 +1,4 @@
> > -DEBUG_CFLAGS   :=
> > -
> > -ifdef CONFIG_DEBUG_INFO_SPLIT
> > -DEBUG_CFLAGS   += -gsplit-dwarf
> > -else
> > -debug-cflags-y += -g
> > -endif
> > +DEBUG_CFLAGS   := -g
> >
> >  debug-flags-$(CONFIG_DEBUG_INFO_DWARF4)        += -gdwarf-4
> >  debug-flags-$(CONFIG_DEBUG_INFO_DWARF5)        += -gdwarf-5
> > @@ -15,6 +9,8 @@ ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_AS_IS_GNU),yy)
> >  KBUILD_AFLAGS  += $(addprefix -Wa$(comma), $(debug-flags-y))
> >  endif
> >
> > +debug-flags-$(CONFIG_DEBUG_INFO_SPLIT) += -gsplit-dwarf
> > +
>
>
> This patch changes the behavior that is not mentioned in the commit log.
>
>
>
>
> Previously, -gsplit-dwarf was passed only when compiling *.c files.
> (DEBUG_CFLAGS).
>
> Now it is passed also when compiling *.S files.
> (debug-flags-y is appended to KBUILD_AFLAGS)
>
>
> Please confirm if this makes sense, and if so,
> please mention it in the commit log.
>
>
>
> As far as I tested, I did not see this change was useful.
>
> When *.S is compiled to *.o, *.dwo is also created,
> but it does not contain any debug info.
>
>
>
> >  ifdef CONFIG_DEBUG_INFO_REDUCED
> >  DEBUG_CFLAGS   += -fno-var-tracking
> >  ifdef CONFIG_CC_IS_GCC
> > --
> > 2.37.2.789.g6183377224-goog
> >
>
>
> --
> Best Regards
> Masahiro Yamada


BTW, you do not need to resend the entire series
even if you end up with v4.


 - 01-02
 - 03
 - 04-05

are mutually independent of the others now.

They can be reviewed separately.


--
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/scripts/Makefile.debug b/scripts/Makefile.debug
index 2845145c1220..c20f8f2e76bf 100644
--- a/scripts/Makefile.debug
+++ b/scripts/Makefile.debug
@@ -1,10 +1,4 @@ 
-DEBUG_CFLAGS	:=
-
-ifdef CONFIG_DEBUG_INFO_SPLIT
-DEBUG_CFLAGS	+= -gsplit-dwarf
-else
-debug-cflags-y	+= -g
-endif
+DEBUG_CFLAGS	:= -g
 
 debug-flags-$(CONFIG_DEBUG_INFO_DWARF4)	+= -gdwarf-4
 debug-flags-$(CONFIG_DEBUG_INFO_DWARF5)	+= -gdwarf-5
@@ -15,6 +9,8 @@  ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_AS_IS_GNU),yy)
 KBUILD_AFLAGS	+= $(addprefix -Wa$(comma), $(debug-flags-y))
 endif
 
+debug-flags-$(CONFIG_DEBUG_INFO_SPLIT)	+= -gsplit-dwarf
+
 ifdef CONFIG_DEBUG_INFO_REDUCED
 DEBUG_CFLAGS	+= -fno-var-tracking
 ifdef CONFIG_CC_IS_GCC