diff mbox series

[3/3] Makefile.debug: set -g unconditional on CONFIG_DEBUG_INFO_SPLIT

Message ID 20220826181035.859042-4-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 Aug. 26, 2022, 6:10 p.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.

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
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>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 scripts/Makefile.debug | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Nick Desaulniers Aug. 31, 2022, 5:40 p.m. UTC | #1
On Fri, Aug 26, 2022 at 11:10 AM 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.

Looking at
commit 866ced950bcd ("kbuild: Support split debug info v4")
I'm curious whether -gsplit-dwarf needed to be mutually exclusive with
-g, possibly for older compilers? Andi, do you recall?
I have gcc-9 handy; that doesn't seem to be the case. I get the same
size binary with `-gsplit-dwarf` as I do with `-g -gsplit-dwarf`.  So
it does seem like mutual exclusion between the two is not necessary.

x86_64-gcc-5.5.0-nolibc-x86_64-linux.tar.gz from
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/5.5.0/
seems to really need libisl.so.15...
$ cd /tmp
$ wget https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/5.5.0/x86_64-gcc-5.5.0-nolibc-x86_64-linux.tar.gz
$ echo "void foo(void) {}" > x.c
$ ./gcc-5.5.0-nolibc/x86_64-linux/bin/x86_64-linux-gcc-5.5.0
-gsplit-dwarf x.c -c
/tmp/gcc-5.5.0-nolibc/x86_64-linux/bin/../libexec/gcc/x86_64-linux/5.5.0/cc1:
error while loading shared libraries: libisl.so.15: cannot open shared
object file: No such file or directory
$ find /usr/lib -name libisl\*
/usr/lib/x86_64-linux-gnu/libisl.so.23.2.0
/usr/lib/x86_64-linux-gnu/libisl.so.23
/usr/lib/x86_64-linux-gnu/libisl.a
/usr/lib/x86_64-linux-gnu/libisl.so

>
> 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
> 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>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
>  scripts/Makefile.debug | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/Makefile.debug b/scripts/Makefile.debug
> index a7a6da7f6e7d..0f9912f7bd4c 100644
> --- a/scripts/Makefile.debug
> +++ b/scripts/Makefile.debug
> @@ -1,10 +1,8 @@
> -DEBUG_CFLAGS   :=
> +DEBUG_CFLAGS   := -g
> +KBUILD_AFLAGS  += -g
>
>  ifdef CONFIG_DEBUG_INFO_SPLIT
>  DEBUG_CFLAGS   += -gsplit-dwarf
> -else
> -DEBUG_CFLAGS   += -g
> -KBUILD_AFLAGS  += -g
>  endif
>
>  ifdef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
> --
> 2.37.2.672.g94769d06f0-goog
>
diff mbox series

Patch

diff --git a/scripts/Makefile.debug b/scripts/Makefile.debug
index a7a6da7f6e7d..0f9912f7bd4c 100644
--- a/scripts/Makefile.debug
+++ b/scripts/Makefile.debug
@@ -1,10 +1,8 @@ 
-DEBUG_CFLAGS	:=
+DEBUG_CFLAGS	:= -g
+KBUILD_AFLAGS	+= -g
 
 ifdef CONFIG_DEBUG_INFO_SPLIT
 DEBUG_CFLAGS	+= -gsplit-dwarf
-else
-DEBUG_CFLAGS	+= -g
-KBUILD_AFLAGS	+= -g
 endif
 
 ifdef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT