* [PATCH] Check for working assembler --gdwarf-[45] options
@ 2020-10-16 17:58 H.J. Lu
2020-10-16 18:17 ` Jakub Jelinek
0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2020-10-16 17:58 UTC (permalink / raw)
To: gcc-patches; +Cc: Jakub Jelinek
Don't set HAVE_AS_GDWARF_5_DEBUG_FLAG nor HAVE_AS_WORKING_DWARF_4_FLAG
if there is an extra assembly input file in debug info generated by
--gdwarf-5/--gdwarf-4:
https://sourceware.org/bugzilla/show_bug.cgi?id=25878
https://sourceware.org/bugzilla/show_bug.cgi?id=26740
Also replace success with dwarf4_success in the 32-bit --gdwarf-4 check.
OK for master?
PR bootstrap/97451
* configure.ac (HAVE_AS_GDWARF_5_DEBUG_FLAG): Don't define if
there is an extra assembly input file in debug info.
(HAVE_AS_WORKING_DWARF_4_FLAG): Likewise. Replace success with
dwarf4_success in the 32-bit --gdwarf-4 check.
* configure: Regenerated.
---
gcc/configure | 114 ++++++++++++++++++++++++++++++++++++++++++++---
gcc/configure.ac | 70 ++++++++++++++++++++++++++---
2 files changed, 172 insertions(+), 12 deletions(-)
diff --git a/gcc/configure b/gcc/configure
index abff47d30eb..d63c2331157 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -28475,6 +28475,7 @@ $as_echo "#define HAVE_AS_GDWARF2_DEBUG_FLAG 1" >>confdefs.h
fi
+ dwarf5_success=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --gdwarf-5 option" >&5
$as_echo_n "checking assembler for --gdwarf-5 option... " >&6; }
if ${gcc_cv_as_gdwarf_5_flag+:} false; then :
@@ -28506,9 +28507,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_gdwarf_5_flag" >&5
$as_echo "$gcc_cv_as_gdwarf_5_flag" >&6; }
if test $gcc_cv_as_gdwarf_5_flag = yes; then
-
-$as_echo "#define HAVE_AS_GDWARF_5_DEBUG_FLAG 1" >>confdefs.h
-
+ dwarf5_success=yes
fi
@@ -28701,7 +28700,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_debug_line_32_flag" >&5
$as_echo "$gcc_cv_as_debug_line_32_flag" >&6; }
if test $gcc_cv_as_debug_line_32_flag = yes; then
- success=yes
+ dwarf4_success=yes
fi
else
@@ -28741,6 +28740,7 @@ fi
fi
if test $dwarf4_success = yes; then
+ dwarf4_success=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --gdwarf-4 not refusing compiler generated .debug_line" >&5
$as_echo_n "checking assembler for --gdwarf-4 not refusing compiler generated .debug_line... " >&6; }
if ${gcc_cv_as_dwarf_4_debug_line_flag+:} false; then :
@@ -28772,9 +28772,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_dwarf_4_debug_line_flag" >&5
$as_echo "$gcc_cv_as_dwarf_4_debug_line_flag" >&6; }
if test $gcc_cv_as_dwarf_4_debug_line_flag = yes; then
-
-$as_echo "#define HAVE_AS_WORKING_DWARF_4_FLAG 1" >>confdefs.h
-
+ dwarf4_success=yes
fi
break
@@ -28785,6 +28783,108 @@ fi
dwarf4_line_sz=5
done
+ conftest_s="\
+ .text
+ .globl foo
+ .type foo, %function
+foo:
+ $insn
+ .size foo, .-foo
+ .file 0 \"foo.c\"
+"
+ if test $dwarf5_success = yes; then
+ dwarf5_success=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for working --gdwarf-5 option" >&5
+$as_echo_n "checking assembler for working --gdwarf-5 option... " >&6; }
+if ${gcc_cv_as_working_gdwarf_5_flag+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_working_gdwarf_5_flag=no
+ if test x$gcc_cv_as != x; then
+ $as_echo "$conftest_s" > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags --gdwarf-5 -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ if test x$gcc_cv_readelf != x \
+ && $gcc_cv_readelf -w conftest.o 2>&1 \
+ | grep conftest.s > /dev/null 2>&1; then
+ dwarf5_success=no
+ else
+ dwarf5_success=yes
+ fi
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_working_gdwarf_5_flag" >&5
+$as_echo "$gcc_cv_as_working_gdwarf_5_flag" >&6; }
+
+
+ if test $dwarf5_success = yes; then
+
+$as_echo "#define HAVE_AS_GDWARF_5_DEBUG_FLAG 1" >>confdefs.h
+
+ fi
+ fi
+
+ conftest_s="\
+ .text
+ .globl foo
+ .type foo, %function
+foo:
+ $insn
+ .size foo, .-foo
+ .file 1 \"foo.c\"
+"
+ if test $dwarf4_success = yes; then
+ dwarf4_success=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for working --gdwarf-4 option" >&5
+$as_echo_n "checking assembler for working --gdwarf-4 option... " >&6; }
+if ${gcc_cv_as_working_gdwarf_4_flag+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_working_gdwarf_4_flag=no
+ if test x$gcc_cv_as != x; then
+ $as_echo "$conftest_s" > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags --gdwarf-4 -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ if test x$gcc_cv_readelf != x \
+ && $gcc_cv_readelf -w conftest.o 2>&1 \
+ | grep conftest.s > /dev/null 2>&1; then
+ dwarf4_success=no
+ else
+ dwarf4_success=yes
+ fi
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_working_gdwarf_4_flag" >&5
+$as_echo "$gcc_cv_as_working_gdwarf_4_flag" >&6; }
+
+
+ if test $dwarf4_success = yes; then
+
+$as_echo "#define HAVE_AS_WORKING_DWARF_4_FLAG 1" >>confdefs.h
+
+ fi
+ fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --gstabs option" >&5
$as_echo_n "checking assembler for --gstabs option... " >&6; }
if ${gcc_cv_as_gstabs_flag+:} false; then :
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 26a5d8e3619..0da3009fa5d 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5197,11 +5197,11 @@ if test x"$insn" != x; then
[AC_DEFINE(HAVE_AS_GDWARF2_DEBUG_FLAG, 1,
[Define if your assembler supports the --gdwarf2 option.])])
+ dwarf5_success=no
gcc_GAS_CHECK_FEATURE([--gdwarf-5 option],
gcc_cv_as_gdwarf_5_flag,
[elf,2,36,0], [--gdwarf-5], [$insn],,
- [AC_DEFINE(HAVE_AS_GDWARF_5_DEBUG_FLAG, 1,
-[Define if your assembler supports the --gdwarf-5 option.])])
+ [dwarf5_success=yes])
dwarf4_debug_info_size=0x46
dwarf4_high_pc_form=7
@@ -5364,7 +5364,7 @@ foo:
gcc_GAS_CHECK_FEATURE([assembly of compiler generated 32-bit .debug_line],
gcc_cv_as_debug_line_32_flag,
[elf,2,36,0], [], [$conftest_s],,
- [success=yes])
+ [dwarf4_success=yes])
else
gcc_GAS_CHECK_FEATURE([assembly of compiler generated 64-bit .debug_line],
gcc_cv_as_debug_line_64_flag,
@@ -5372,11 +5372,11 @@ foo:
[dwarf4_success=yes])
fi
if test $dwarf4_success = yes; then
+ dwarf4_success=no
gcc_GAS_CHECK_FEATURE([--gdwarf-4 not refusing compiler generated .debug_line],
gcc_cv_as_dwarf_4_debug_line_flag,
[elf,2,36,0], [--gdwarf-4], [$conftest_s],,
- [AC_DEFINE(HAVE_AS_WORKING_DWARF_4_FLAG, 1,
-[Define if your assembler supports --gdwarf-4 even with compiler generated .debug_line])])
+ [dwarf4_success=yes])
break
fi
dwarf4_debug_info_size=0x36
@@ -5385,6 +5385,66 @@ foo:
dwarf4_line_sz=5
done
+ conftest_s="\
+ .text
+ .globl foo
+ .type foo, %function
+foo:
+ $insn
+ .size foo, .-foo
+ .file 0 \"foo.c\"
+"
+ if test $dwarf5_success = yes; then
+ dwarf5_success=no
+ gcc_GAS_CHECK_FEATURE([working --gdwarf-5 option],
+ gcc_cv_as_working_gdwarf_5_flag,,
+ [--gdwarf-5],
+ [$conftest_s],
+ [changequote(,)dnl
+ if test x$gcc_cv_readelf != x \
+ && $gcc_cv_readelf -w conftest.o 2>&1 \
+ | grep conftest.s > /dev/null 2>&1; then
+ dwarf5_success=no
+ else
+ dwarf5_success=yes
+ fi
+ changequote([,])dnl])
+ if test $dwarf5_success = yes; then
+ AC_DEFINE(HAVE_AS_GDWARF_5_DEBUG_FLAG, 1,
+[Define if your assembler supports the --gdwarf-5 option.])
+ fi
+ fi
+
+ conftest_s="\
+ .text
+ .globl foo
+ .type foo, %function
+foo:
+ $insn
+ .size foo, .-foo
+ .file 1 \"foo.c\"
+"
+ if test $dwarf4_success = yes; then
+ dwarf4_success=no
+ gcc_GAS_CHECK_FEATURE([working --gdwarf-4 option],
+ gcc_cv_as_working_gdwarf_4_flag,,
+ [--gdwarf-4],
+ [$conftest_s],
+ [changequote(,)dnl
+ if test x$gcc_cv_readelf != x \
+ && $gcc_cv_readelf -w conftest.o 2>&1 \
+ | grep conftest.s > /dev/null 2>&1; then
+ dwarf4_success=no
+ else
+ dwarf4_success=yes
+ fi
+ changequote([,])dnl])
+ if test $dwarf4_success = yes; then
+ AC_DEFINE(HAVE_AS_WORKING_DWARF_4_FLAG, 1,
+[Define if your assembler supports --gdwarf-4 even with compiler generated .debug_line])
+ fi
+ fi
+
gcc_GAS_CHECK_FEATURE([--gstabs option],
gcc_cv_as_gstabs_flag,
[elf,2,11,0], [--gstabs], [$insn],,
--
2.26.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Check for working assembler --gdwarf-[45] options
2020-10-16 17:58 [PATCH] Check for working assembler --gdwarf-[45] options H.J. Lu
@ 2020-10-16 18:17 ` Jakub Jelinek
2020-10-16 18:29 ` H.J. Lu
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2020-10-16 18:17 UTC (permalink / raw)
To: H.J. Lu; +Cc: gcc-patches
On Fri, Oct 16, 2020 at 10:58:34AM -0700, H.J. Lu wrote:
> Don't set HAVE_AS_GDWARF_5_DEBUG_FLAG nor HAVE_AS_WORKING_DWARF_4_FLAG
> if there is an extra assembly input file in debug info generated by
> --gdwarf-5/--gdwarf-4:
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=25878
> https://sourceware.org/bugzilla/show_bug.cgi?id=26740
>
> Also replace success with dwarf4_success in the 32-bit --gdwarf-4 check.
>
> OK for master?
>
> PR bootstrap/97451
> * configure.ac (HAVE_AS_GDWARF_5_DEBUG_FLAG): Don't define if
> there is an extra assembly input file in debug info.
> (HAVE_AS_WORKING_DWARF_4_FLAG): Likewise. Replace success with
> dwarf4_success in the 32-bit --gdwarf-4 check.
> * configure: Regenerated.
The HAVE_AS_GDWARF_5_DEBUG_FLAG macro should be solely about whether
-gdwarf-5 can be passed to as, nothing else. That is because it is not only
used to decide if we can pass -gdwarf-5 to as for assembly of e.g. *.c
compilation, but also if we can pass it to as when gcc driver is invoked on
*.s and *.S. And in that case the problems with -gdwarf-N having unwanted
effects on assembly with compiler generated .debug_info etc. sections.
don't really matter.
The HAVE_AS_WORKING_DWARF_4_FLAG perhaps could be renamed to
...DWARF_N_FLAG, it is meant to check for whether we can safely pass the
option also for *.c etc. compilation when we emit debug info sections by the
compiler.
For that, the question is, are all the issues already fixed on the binutils
trunk? As in, do I get identical object files e.g. for -gdwarf-2
compilation no matter whether the compiler passes -gdwarf-2 to gas or not
(assuming dwarf 2 is the default in gas) when compiling various *.c/*.C
files? Ditto for modified gas that would default to other .debug_line
versions and corresponding gcc -gdwarf-N flag and passing vs. not passing
that -gdwarf-N to gas?
The hope is that -gdwarf-N to gas would have two functions:
1) if the assembly doesn't contain .debug* sections/.file/.loc directives,
emit debug info (mainly .debug_line) for the assembler file in order to
be able to debug those
2) if the assembly does contain .debug* sections/.file/.loc directives,
only change the version of the .debug_line generated for the .file/.loc
directives, but nothing else; keep all .debug* sections but .debug_line
as is
Jakub
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Check for working assembler --gdwarf-[45] options
2020-10-16 18:17 ` Jakub Jelinek
@ 2020-10-16 18:29 ` H.J. Lu
2020-10-17 13:23 ` [PATCH] Update check for working assembler --gdwarf-4 option H.J. Lu
0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2020-10-16 18:29 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: GCC Patches
On Fri, Oct 16, 2020 at 11:17 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Fri, Oct 16, 2020 at 10:58:34AM -0700, H.J. Lu wrote:
> > Don't set HAVE_AS_GDWARF_5_DEBUG_FLAG nor HAVE_AS_WORKING_DWARF_4_FLAG
> > if there is an extra assembly input file in debug info generated by
> > --gdwarf-5/--gdwarf-4:
> >
> > https://sourceware.org/bugzilla/show_bug.cgi?id=25878
> > https://sourceware.org/bugzilla/show_bug.cgi?id=26740
> >
> > Also replace success with dwarf4_success in the 32-bit --gdwarf-4 check.
> >
> > OK for master?
> >
> > PR bootstrap/97451
> > * configure.ac (HAVE_AS_GDWARF_5_DEBUG_FLAG): Don't define if
> > there is an extra assembly input file in debug info.
> > (HAVE_AS_WORKING_DWARF_4_FLAG): Likewise. Replace success with
> > dwarf4_success in the 32-bit --gdwarf-4 check.
> > * configure: Regenerated.
>
> The HAVE_AS_GDWARF_5_DEBUG_FLAG macro should be solely about whether
> -gdwarf-5 can be passed to as, nothing else. That is because it is not only
> used to decide if we can pass -gdwarf-5 to as for assembly of e.g. *.c
> compilation, but also if we can pass it to as when gcc driver is invoked on
> *.s and *.S. And in that case the problems with -gdwarf-N having unwanted
> effects on assembly with compiler generated .debug_info etc. sections.
> don't really matter.
>
> The HAVE_AS_WORKING_DWARF_4_FLAG perhaps could be renamed to
> ...DWARF_N_FLAG, it is meant to check for whether we can safely pass the
> option also for *.c etc. compilation when we emit debug info sections by the
> compiler.
>
> For that, the question is, are all the issues already fixed on the binutils
> trunk? As in, do I get identical object files e.g. for -gdwarf-2
Not yet. This patch:
https://sourceware.org/pipermail/binutils/2020-October/113744.html
is needed for binutils master branch. BTW, binutils 2.35 and 2.35.1 are
broken.
> compilation no matter whether the compiler passes -gdwarf-2 to gas or not
> (assuming dwarf 2 is the default in gas) when compiling various *.c/*.C
> files? Ditto for modified gas that would default to other .debug_line
> versions and corresponding gcc -gdwarf-N flag and passing vs. not passing
> that -gdwarf-N to gas?
>
> The hope is that -gdwarf-N to gas would have two functions:
> 1) if the assembly doesn't contain .debug* sections/.file/.loc directives,
> emit debug info (mainly .debug_line) for the assembler file in order to
> be able to debug those
> 2) if the assembly does contain .debug* sections/.file/.loc directives,
> only change the version of the .debug_line generated for the .file/.loc
> directives, but nothing else; keep all .debug* sections but .debug_line
> as is
--
H.J.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Update check for working assembler --gdwarf-4 option
2020-10-16 18:29 ` H.J. Lu
@ 2020-10-17 13:23 ` H.J. Lu
2020-10-24 15:28 ` V2 " H.J. Lu
0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2020-10-17 13:23 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 2945 bytes --]
On Fri, Oct 16, 2020 at 11:29 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Oct 16, 2020 at 11:17 AM Jakub Jelinek <jakub@redhat.com> wrote:
> >
> > On Fri, Oct 16, 2020 at 10:58:34AM -0700, H.J. Lu wrote:
> > > Don't set HAVE_AS_GDWARF_5_DEBUG_FLAG nor HAVE_AS_WORKING_DWARF_4_FLAG
> > > if there is an extra assembly input file in debug info generated by
> > > --gdwarf-5/--gdwarf-4:
> > >
> > > https://sourceware.org/bugzilla/show_bug.cgi?id=25878
> > > https://sourceware.org/bugzilla/show_bug.cgi?id=26740
> > >
> > > Also replace success with dwarf4_success in the 32-bit --gdwarf-4 check.
> > >
> > > OK for master?
> > >
> > > PR bootstrap/97451
> > > * configure.ac (HAVE_AS_GDWARF_5_DEBUG_FLAG): Don't define if
> > > there is an extra assembly input file in debug info.
> > > (HAVE_AS_WORKING_DWARF_4_FLAG): Likewise. Replace success with
> > > dwarf4_success in the 32-bit --gdwarf-4 check.
> > > * configure: Regenerated.
> >
> > The HAVE_AS_GDWARF_5_DEBUG_FLAG macro should be solely about whether
> > -gdwarf-5 can be passed to as, nothing else. That is because it is not only
> > used to decide if we can pass -gdwarf-5 to as for assembly of e.g. *.c
> > compilation, but also if we can pass it to as when gcc driver is invoked on
> > *.s and *.S. And in that case the problems with -gdwarf-N having unwanted
> > effects on assembly with compiler generated .debug_info etc. sections.
> > don't really matter.
> >
> > The HAVE_AS_WORKING_DWARF_4_FLAG perhaps could be renamed to
> > ...DWARF_N_FLAG, it is meant to check for whether we can safely pass the
> > option also for *.c etc. compilation when we emit debug info sections by the
> > compiler.
> >
> > For that, the question is, are all the issues already fixed on the binutils
> > trunk? As in, do I get identical object files e.g. for -gdwarf-2
>
> Not yet. This patch:
>
> https://sourceware.org/pipermail/binutils/2020-October/113744.html
>
> is needed for binutils master branch. BTW, binutils 2.35 and 2.35.1 are
> broken.
>
> > compilation no matter whether the compiler passes -gdwarf-2 to gas or not
> > (assuming dwarf 2 is the default in gas) when compiling various *.c/*.C
> > files? Ditto for modified gas that would default to other .debug_line
> > versions and corresponding gcc -gdwarf-N flag and passing vs. not passing
> > that -gdwarf-N to gas?
> >
> > The hope is that -gdwarf-N to gas would have two functions:
> > 1) if the assembly doesn't contain .debug* sections/.file/.loc directives,
> > emit debug info (mainly .debug_line) for the assembler file in order to
> > be able to debug those
> > 2) if the assembly does contain .debug* sections/.file/.loc directives,
> > only change the version of the .debug_line generated for the .file/.loc
> > directives, but nothing else; keep all .debug* sections but .debug_line
> > as is
>
Here is the updated patch. OK for master?
--
H.J.
[-- Attachment #2: 0001-Update-check-for-working-assembler-gdwarf-4-option.patch --]
[-- Type: text/x-patch, Size: 8497 bytes --]
From 583bcc56d03ef49df2fd33d2879aa24ba9abe4ce Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 16 Oct 2020 05:59:51 -0700
Subject: [PATCH] Update check for working assembler --gdwarf-4 option
Rename HAVE_AS_WORKING_DWARF_4_FLAG to HAVE_AS_WORKING_DWARF_N_FLAG
Don't set HAVE_AS_WORKING_DWARF_N_FLAG if --gdwarf-5/--gdwarf-4 generate
an extra assembly input file in debug info from compiler generated
.debug_line:
https://sourceware.org/bugzilla/show_bug.cgi?id=25878
https://sourceware.org/bugzilla/show_bug.cgi?id=26740
Also replace success with dwarf4_success in the 32-bit --gdwarf-4 check.
PR bootstrap/97451
* configure.ac (HAVE_AS_WORKING_DWARF_4_FLAG): Renamed to ...
(HAVE_AS_WORKING_DWARF_N_FLAG): This. Don't define if there is
an extra assembly input file in debug info. Replace success
with dwarf4_success in the 32-bit --gdwarf-4 check.
* dwarf2out.c (asm_outputs_debug_line_str): Check
HAVE_AS_WORKING_DWARF_N_FLAG instead of
HAVE_AS_WORKING_DWARF_4_FLAG.
* gcc.c (ASM_DEBUG_SPEC): Likewise.
(ASM_DEBUG_OPTION_SPEC): Likewise.
* config.in: Regenerated.
* configure: Likewise.
---
gcc/config.in | 6 ++---
gcc/configure | 57 ++++++++++++++++++++++++++++++++++++++++++++----
gcc/configure.ac | 36 +++++++++++++++++++++++++++---
gcc/dwarf2out.c | 2 +-
gcc/gcc.c | 4 ++--
5 files changed, 92 insertions(+), 13 deletions(-)
diff --git a/gcc/config.in b/gcc/config.in
index 3657c46f349..b7c3107bfe3 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -719,10 +719,10 @@
#endif
-/* Define if your assembler supports --gdwarf-4 even with compiler generated
- .debug_line */
+/* Define if your assembler supports --gdwarf-4/--gdwarf-5 even with compiler
+ generated .debug_line. */
#ifndef USED_FOR_TARGET
-#undef HAVE_AS_WORKING_DWARF_4_FLAG
+#undef HAVE_AS_WORKING_DWARF_N_FLAG
#endif
diff --git a/gcc/configure b/gcc/configure
index abff47d30eb..b3f0fbec4f8 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -28701,7 +28701,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_debug_line_32_flag" >&5
$as_echo "$gcc_cv_as_debug_line_32_flag" >&6; }
if test $gcc_cv_as_debug_line_32_flag = yes; then
- success=yes
+ dwarf4_success=yes
fi
else
@@ -28741,6 +28741,7 @@ fi
fi
if test $dwarf4_success = yes; then
+ dwarf4_success=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --gdwarf-4 not refusing compiler generated .debug_line" >&5
$as_echo_n "checking assembler for --gdwarf-4 not refusing compiler generated .debug_line... " >&6; }
if ${gcc_cv_as_dwarf_4_debug_line_flag+:} false; then :
@@ -28772,9 +28773,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_dwarf_4_debug_line_flag" >&5
$as_echo "$gcc_cv_as_dwarf_4_debug_line_flag" >&6; }
if test $gcc_cv_as_dwarf_4_debug_line_flag = yes; then
-
-$as_echo "#define HAVE_AS_WORKING_DWARF_4_FLAG 1" >>confdefs.h
-
+ dwarf4_success=yes
fi
break
@@ -28785,6 +28784,56 @@ fi
dwarf4_line_sz=5
done
+ conftest_s="\
+ .text
+ .globl foo
+ .type foo, %function
+foo:
+ $insn
+ .size foo, .-foo
+ .file 1 \"foo.c\"
+"
+ if test $dwarf4_success = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for working --gdwarf-4/--gdwarf-5 for all sources" >&5
+$as_echo_n "checking assembler for working --gdwarf-4/--gdwarf-5 for all sources... " >&6; }
+if ${gcc_cv_as_working_gdwarf_n_flag+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_working_gdwarf_n_flag=no
+ if test x$gcc_cv_as != x; then
+ $as_echo "$conftest_s" > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags --gdwarf-4 -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ if test x$gcc_cv_readelf != x \
+ && $gcc_cv_readelf -w conftest.o 2>&1 \
+ | grep conftest.s > /dev/null 2>&1; then
+ gcc_cv_as_working_gdwarf_n_flag=no
+ else
+ gcc_cv_as_working_gdwarf_n_flag=yes
+ fi
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_working_gdwarf_n_flag" >&5
+$as_echo "$gcc_cv_as_working_gdwarf_n_flag" >&6; }
+
+
+ if test $gcc_cv_as_working_gdwarf_n_flag = yes; then
+
+$as_echo "#define HAVE_AS_WORKING_DWARF_N_FLAG 1" >>confdefs.h
+
+ fi
+ fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --gstabs option" >&5
$as_echo_n "checking assembler for --gstabs option... " >&6; }
if ${gcc_cv_as_gstabs_flag+:} false; then :
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 26a5d8e3619..614833a0040 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5364,7 +5364,7 @@ foo:
gcc_GAS_CHECK_FEATURE([assembly of compiler generated 32-bit .debug_line],
gcc_cv_as_debug_line_32_flag,
[elf,2,36,0], [], [$conftest_s],,
- [success=yes])
+ [dwarf4_success=yes])
else
gcc_GAS_CHECK_FEATURE([assembly of compiler generated 64-bit .debug_line],
gcc_cv_as_debug_line_64_flag,
@@ -5372,11 +5372,11 @@ foo:
[dwarf4_success=yes])
fi
if test $dwarf4_success = yes; then
+ dwarf4_success=no
gcc_GAS_CHECK_FEATURE([--gdwarf-4 not refusing compiler generated .debug_line],
gcc_cv_as_dwarf_4_debug_line_flag,
[elf,2,36,0], [--gdwarf-4], [$conftest_s],,
- [AC_DEFINE(HAVE_AS_WORKING_DWARF_4_FLAG, 1,
-[Define if your assembler supports --gdwarf-4 even with compiler generated .debug_line])])
+ [dwarf4_success=yes])
break
fi
dwarf4_debug_info_size=0x36
@@ -5385,6 +5385,36 @@ foo:
dwarf4_line_sz=5
done
+ conftest_s="\
+ .text
+ .globl foo
+ .type foo, %function
+foo:
+ $insn
+ .size foo, .-foo
+ .file 1 \"foo.c\"
+"
+ if test $dwarf4_success = yes; then
+ gcc_GAS_CHECK_FEATURE([working --gdwarf-4/--gdwarf-5 for all sources],
+ gcc_cv_as_working_gdwarf_n_flag,,
+ [--gdwarf-4],
+ [$conftest_s],
+ [changequote(,)dnl
+ if test x$gcc_cv_readelf != x \
+ && $gcc_cv_readelf -w conftest.o 2>&1 \
+ | grep conftest.s > /dev/null 2>&1; then
+ gcc_cv_as_working_gdwarf_n_flag=no
+ else
+ gcc_cv_as_working_gdwarf_n_flag=yes
+ fi
+ changequote([,])dnl])
+ if test $gcc_cv_as_working_gdwarf_n_flag = yes; then
+ AC_DEFINE(HAVE_AS_WORKING_DWARF_N_FLAG, 1,
+[Define if your assembler supports --gdwarf-4/--gdwarf-5 even with
+ compiler generated .debug_line.])
+ fi
+ fi
+
gcc_GAS_CHECK_FEATURE([--gstabs option],
gcc_cv_as_gstabs_flag,
[elf,2,11,0], [--gstabs], [$insn],,
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ba93a6c3d81..534877babfb 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -11884,7 +11884,7 @@ asm_outputs_debug_line_str (void)
return true;
else
{
-#if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_4_FLAG)
+#if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG)
return !dwarf_split_debug_info && dwarf_version >= 5;
#else
return false;
diff --git a/gcc/gcc.c b/gcc/gcc.c
index ff7b6c4a320..81137bb169f 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -879,7 +879,7 @@ proper position among the other output files. */
/* Define ASM_DEBUG_SPEC to be a spec suitable for translating '-g'
to the assembler, when compiling assembly sources only. */
#ifndef ASM_DEBUG_SPEC
-# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_4_FLAG)
+# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG)
/* If --gdwarf-N is supported and as can handle even compiler generated
.debug_line with it, supply --gdwarf-N in ASM_DEBUG_OPTION_SPEC rather
than in ASM_DEBUG_SPEC, so that it applies to both .s and .c etc.
@@ -920,7 +920,7 @@ proper position among the other output files. */
/* Define ASM_DEBUG_OPTION_SPEC to be a spec suitable for translating '-g'
to the assembler when compiling all sources. */
#ifndef ASM_DEBUG_OPTION_SPEC
-# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_4_FLAG)
+# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG)
# define ASM_DEBUG_OPTION_DWARF_OPT \
"%{%:dwarf-version-gt(4):--gdwarf-5 ;" \
"%:dwarf-version-gt(3):--gdwarf-4 ;" \
--
2.26.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* V2 [PATCH] Update check for working assembler --gdwarf-4 option
2020-10-17 13:23 ` [PATCH] Update check for working assembler --gdwarf-4 option H.J. Lu
@ 2020-10-24 15:28 ` H.J. Lu
2020-10-24 15:55 ` Jakub Jelinek
0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2020-10-24 15:28 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 3243 bytes --]
On Sat, Oct 17, 2020 at 6:23 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Oct 16, 2020 at 11:29 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Fri, Oct 16, 2020 at 11:17 AM Jakub Jelinek <jakub@redhat.com> wrote:
> > >
> > > On Fri, Oct 16, 2020 at 10:58:34AM -0700, H.J. Lu wrote:
> > > > Don't set HAVE_AS_GDWARF_5_DEBUG_FLAG nor HAVE_AS_WORKING_DWARF_4_FLAG
> > > > if there is an extra assembly input file in debug info generated by
> > > > --gdwarf-5/--gdwarf-4:
> > > >
> > > > https://sourceware.org/bugzilla/show_bug.cgi?id=25878
> > > > https://sourceware.org/bugzilla/show_bug.cgi?id=26740
> > > >
> > > > Also replace success with dwarf4_success in the 32-bit --gdwarf-4 check.
> > > >
> > > > OK for master?
> > > >
> > > > PR bootstrap/97451
> > > > * configure.ac (HAVE_AS_GDWARF_5_DEBUG_FLAG): Don't define if
> > > > there is an extra assembly input file in debug info.
> > > > (HAVE_AS_WORKING_DWARF_4_FLAG): Likewise. Replace success with
> > > > dwarf4_success in the 32-bit --gdwarf-4 check.
> > > > * configure: Regenerated.
> > >
> > > The HAVE_AS_GDWARF_5_DEBUG_FLAG macro should be solely about whether
> > > -gdwarf-5 can be passed to as, nothing else. That is because it is not only
> > > used to decide if we can pass -gdwarf-5 to as for assembly of e.g. *.c
> > > compilation, but also if we can pass it to as when gcc driver is invoked on
> > > *.s and *.S. And in that case the problems with -gdwarf-N having unwanted
> > > effects on assembly with compiler generated .debug_info etc. sections.
> > > don't really matter.
> > >
> > > The HAVE_AS_WORKING_DWARF_4_FLAG perhaps could be renamed to
> > > ...DWARF_N_FLAG, it is meant to check for whether we can safely pass the
> > > option also for *.c etc. compilation when we emit debug info sections by the
> > > compiler.
> > >
> > > For that, the question is, are all the issues already fixed on the binutils
> > > trunk? As in, do I get identical object files e.g. for -gdwarf-2
> >
> > Not yet. This patch:
> >
> > https://sourceware.org/pipermail/binutils/2020-October/113744.html
> >
> > is needed for binutils master branch. BTW, binutils 2.35 and 2.35.1 are
> > broken.
> >
> > > compilation no matter whether the compiler passes -gdwarf-2 to gas or not
> > > (assuming dwarf 2 is the default in gas) when compiling various *.c/*.C
> > > files? Ditto for modified gas that would default to other .debug_line
> > > versions and corresponding gcc -gdwarf-N flag and passing vs. not passing
> > > that -gdwarf-N to gas?
> > >
> > > The hope is that -gdwarf-N to gas would have two functions:
> > > 1) if the assembly doesn't contain .debug* sections/.file/.loc directives,
> > > emit debug info (mainly .debug_line) for the assembler file in order to
> > > be able to debug those
> > > 2) if the assembly does contain .debug* sections/.file/.loc directives,
> > > only change the version of the .debug_line generated for the .file/.loc
> > > directives, but nothing else; keep all .debug* sections but .debug_line
> > > as is
> >
>
> Here is the updated patch. OK for master?
>
The updated patch to check
https://sourceware.org/bugzilla/show_bug.cgi?id=26778
OK for master?
--
H.J.
[-- Attachment #2: 0001-Update-check-for-working-assembler-gdwarf-4-option.patch --]
[-- Type: text/x-patch, Size: 10269 bytes --]
From 7130dea1f39692a8a00e48ef119233595f9284c9 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 16 Oct 2020 05:59:51 -0700
Subject: [PATCH] Update check for working assembler --gdwarf-4 option
Rename HAVE_AS_WORKING_DWARF_4_FLAG to HAVE_AS_WORKING_DWARF_N_FLAG
Don't set HAVE_AS_WORKING_DWARF_N_FLAG if --gdwarf-5/--gdwarf-4 generate
an extra assembly input file in debug info from compiler generated
.debug_line or fail with the APP marker:
https://sourceware.org/bugzilla/show_bug.cgi?id=25878
https://sourceware.org/bugzilla/show_bug.cgi?id=26740
https://sourceware.org/bugzilla/show_bug.cgi?id=26778
Also replace success with dwarf4_success in the 32-bit --gdwarf-4 check.
PR bootstrap/97451
* configure.ac (HAVE_AS_WORKING_DWARF_4_FLAG): Renamed to ...
(HAVE_AS_WORKING_DWARF_N_FLAG): This. Don't define if there is
an extra assembly input file in debug info. Replace success
with dwarf4_success in the 32-bit --gdwarf-4 check.
* dwarf2out.c (asm_outputs_debug_line_str): Check
HAVE_AS_WORKING_DWARF_N_FLAG instead of
HAVE_AS_WORKING_DWARF_4_FLAG.
* gcc.c (ASM_DEBUG_SPEC): Likewise.
(ASM_DEBUG_OPTION_SPEC): Likewise.
* config.in: Regenerated.
* configure: Likewise.
---
gcc/config.in | 6 +--
gcc/configure | 106 +++++++++++++++++++++++++++++++++++++++++++++--
gcc/configure.ac | 59 ++++++++++++++++++++++++--
gcc/dwarf2out.c | 2 +-
gcc/gcc.c | 4 +-
5 files changed, 164 insertions(+), 13 deletions(-)
diff --git a/gcc/config.in b/gcc/config.in
index 3657c46f349..b7c3107bfe3 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -719,10 +719,10 @@
#endif
-/* Define if your assembler supports --gdwarf-4 even with compiler generated
- .debug_line */
+/* Define if your assembler supports --gdwarf-4/--gdwarf-5 even with compiler
+ generated .debug_line. */
#ifndef USED_FOR_TARGET
-#undef HAVE_AS_WORKING_DWARF_4_FLAG
+#undef HAVE_AS_WORKING_DWARF_N_FLAG
#endif
diff --git a/gcc/configure b/gcc/configure
index abff47d30eb..f96a89e8c37 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -28701,7 +28701,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_debug_line_32_flag" >&5
$as_echo "$gcc_cv_as_debug_line_32_flag" >&6; }
if test $gcc_cv_as_debug_line_32_flag = yes; then
- success=yes
+ dwarf4_success=yes
fi
else
@@ -28741,6 +28741,7 @@ fi
fi
if test $dwarf4_success = yes; then
+ dwarf4_success=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --gdwarf-4 not refusing compiler generated .debug_line" >&5
$as_echo_n "checking assembler for --gdwarf-4 not refusing compiler generated .debug_line... " >&6; }
if ${gcc_cv_as_dwarf_4_debug_line_flag+:} false; then :
@@ -28772,9 +28773,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_dwarf_4_debug_line_flag" >&5
$as_echo "$gcc_cv_as_dwarf_4_debug_line_flag" >&6; }
if test $gcc_cv_as_dwarf_4_debug_line_flag = yes; then
-
-$as_echo "#define HAVE_AS_WORKING_DWARF_4_FLAG 1" >>confdefs.h
-
+ dwarf4_success=yes
fi
break
@@ -28785,6 +28784,105 @@ fi
dwarf4_line_sz=5
done
+ if test $dwarf4_success = yes; then
+ conftest_s="\
+ .file \"foo.c\"
+ .text
+bar:
+#APP
+# 82 \"xxx.h\" 1
+ $insn
+# 0 \"\" 2
+#NO_APP
+ $insn
+foo:
+ .file 1 \"foo.c\"
+ $insn
+ .file 2 \"foo.h\"
+ ret
+"
+ dwarf4_success=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --gdwarf-4 with the APP marker" >&5
+$as_echo_n "checking assembler for --gdwarf-4 with the APP marker... " >&6; }
+if ${gcc_cv_as_dwarf_4_app_flag+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_dwarf_4_app_flag=no
+ if test x$gcc_cv_as != x; then
+ $as_echo "$conftest_s" > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags --gdwarf-4 -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ gcc_cv_as_dwarf_4_app_flag=yes
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_dwarf_4_app_flag" >&5
+$as_echo "$gcc_cv_as_dwarf_4_app_flag" >&6; }
+if test $gcc_cv_as_dwarf_4_app_flag = yes; then
+ dwarf4_success=yes
+fi
+
+ fi
+
+ if test $dwarf4_success = yes; then
+ conftest_s="\
+ .text
+ .globl foo
+ .type foo, %function
+foo:
+ $insn
+ .size foo, .-foo
+ .file 1 \"foo.c\"
+"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for working --gdwarf-4/--gdwarf-5 for all sources" >&5
+$as_echo_n "checking assembler for working --gdwarf-4/--gdwarf-5 for all sources... " >&6; }
+if ${gcc_cv_as_working_gdwarf_n_flag+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_working_gdwarf_n_flag=no
+ if test x$gcc_cv_as != x; then
+ $as_echo "$conftest_s" > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags --gdwarf-4 -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ if test x$gcc_cv_readelf != x \
+ && $gcc_cv_readelf -w conftest.o 2>&1 \
+ | grep conftest.s > /dev/null 2>&1; then
+ gcc_cv_as_working_gdwarf_n_flag=no
+ else
+ gcc_cv_as_working_gdwarf_n_flag=yes
+ fi
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_working_gdwarf_n_flag" >&5
+$as_echo "$gcc_cv_as_working_gdwarf_n_flag" >&6; }
+
+
+ if test $gcc_cv_as_working_gdwarf_n_flag = yes; then
+
+$as_echo "#define HAVE_AS_WORKING_DWARF_N_FLAG 1" >>confdefs.h
+
+ fi
+ fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --gstabs option" >&5
$as_echo_n "checking assembler for --gstabs option... " >&6; }
if ${gcc_cv_as_gstabs_flag+:} false; then :
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 26a5d8e3619..9154a5475dc 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5364,7 +5364,7 @@ foo:
gcc_GAS_CHECK_FEATURE([assembly of compiler generated 32-bit .debug_line],
gcc_cv_as_debug_line_32_flag,
[elf,2,36,0], [], [$conftest_s],,
- [success=yes])
+ [dwarf4_success=yes])
else
gcc_GAS_CHECK_FEATURE([assembly of compiler generated 64-bit .debug_line],
gcc_cv_as_debug_line_64_flag,
@@ -5372,11 +5372,11 @@ foo:
[dwarf4_success=yes])
fi
if test $dwarf4_success = yes; then
+ dwarf4_success=no
gcc_GAS_CHECK_FEATURE([--gdwarf-4 not refusing compiler generated .debug_line],
gcc_cv_as_dwarf_4_debug_line_flag,
[elf,2,36,0], [--gdwarf-4], [$conftest_s],,
- [AC_DEFINE(HAVE_AS_WORKING_DWARF_4_FLAG, 1,
-[Define if your assembler supports --gdwarf-4 even with compiler generated .debug_line])])
+ [dwarf4_success=yes])
break
fi
dwarf4_debug_info_size=0x36
@@ -5385,6 +5385,59 @@ foo:
dwarf4_line_sz=5
done
+ if test $dwarf4_success = yes; then
+ conftest_s="\
+ .file \"foo.c\"
+ .text
+bar:
+#APP
+# 82 \"xxx.h\" 1
+ $insn
+# 0 \"\" 2
+#NO_APP
+ $insn
+foo:
+ .file 1 \"foo.c\"
+ $insn
+ .file 2 \"foo.h\"
+ ret
+"
+ dwarf4_success=no
+ gcc_GAS_CHECK_FEATURE([--gdwarf-4 with the APP marker],
+ gcc_cv_as_dwarf_4_app_flag,,
+ [--gdwarf-4], [$conftest_s],, [dwarf4_success=yes])
+ fi
+
+ if test $dwarf4_success = yes; then
+ conftest_s="\
+ .text
+ .globl foo
+ .type foo, %function
+foo:
+ $insn
+ .size foo, .-foo
+ .file 1 \"foo.c\"
+"
+ gcc_GAS_CHECK_FEATURE([working --gdwarf-4/--gdwarf-5 for all sources],
+ gcc_cv_as_working_gdwarf_n_flag,,
+ [--gdwarf-4],
+ [$conftest_s],
+ [changequote(,)dnl
+ if test x$gcc_cv_readelf != x \
+ && $gcc_cv_readelf -w conftest.o 2>&1 \
+ | grep conftest.s > /dev/null 2>&1; then
+ gcc_cv_as_working_gdwarf_n_flag=no
+ else
+ gcc_cv_as_working_gdwarf_n_flag=yes
+ fi
+ changequote([,])dnl])
+ if test $gcc_cv_as_working_gdwarf_n_flag = yes; then
+ AC_DEFINE(HAVE_AS_WORKING_DWARF_N_FLAG, 1,
+[Define if your assembler supports --gdwarf-4/--gdwarf-5 even with
+ compiler generated .debug_line.])
+ fi
+ fi
+
gcc_GAS_CHECK_FEATURE([--gstabs option],
gcc_cv_as_gstabs_flag,
[elf,2,11,0], [--gstabs], [$insn],,
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ba93a6c3d81..534877babfb 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -11884,7 +11884,7 @@ asm_outputs_debug_line_str (void)
return true;
else
{
-#if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_4_FLAG)
+#if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG)
return !dwarf_split_debug_info && dwarf_version >= 5;
#else
return false;
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 337c27442a3..cdf4d4f2403 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -880,7 +880,7 @@ proper position among the other output files. */
/* Define ASM_DEBUG_SPEC to be a spec suitable for translating '-g'
to the assembler, when compiling assembly sources only. */
#ifndef ASM_DEBUG_SPEC
-# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_4_FLAG)
+# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG)
/* If --gdwarf-N is supported and as can handle even compiler generated
.debug_line with it, supply --gdwarf-N in ASM_DEBUG_OPTION_SPEC rather
than in ASM_DEBUG_SPEC, so that it applies to both .s and .c etc.
@@ -921,7 +921,7 @@ proper position among the other output files. */
/* Define ASM_DEBUG_OPTION_SPEC to be a spec suitable for translating '-g'
to the assembler when compiling all sources. */
#ifndef ASM_DEBUG_OPTION_SPEC
-# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_4_FLAG)
+# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG)
# define ASM_DEBUG_OPTION_DWARF_OPT \
"%{%:dwarf-version-gt(4):--gdwarf-5 ;" \
"%:dwarf-version-gt(3):--gdwarf-4 ;" \
--
2.26.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: V2 [PATCH] Update check for working assembler --gdwarf-4 option
2020-10-24 15:28 ` V2 " H.J. Lu
@ 2020-10-24 15:55 ` Jakub Jelinek
0 siblings, 0 replies; 6+ messages in thread
From: Jakub Jelinek @ 2020-10-24 15:55 UTC (permalink / raw)
To: H.J. Lu; +Cc: GCC Patches
On Sat, Oct 24, 2020 at 08:28:08AM -0700, H.J. Lu wrote:
> The updated patch to check
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=26778
>
> OK for master?
Ok, thanks.
> From 7130dea1f39692a8a00e48ef119233595f9284c9 Mon Sep 17 00:00:00 2001
> From: "H.J. Lu" <hjl.tools@gmail.com>
> Date: Fri, 16 Oct 2020 05:59:51 -0700
> Subject: [PATCH] Update check for working assembler --gdwarf-4 option
>
> Rename HAVE_AS_WORKING_DWARF_4_FLAG to HAVE_AS_WORKING_DWARF_N_FLAG
> Don't set HAVE_AS_WORKING_DWARF_N_FLAG if --gdwarf-5/--gdwarf-4 generate
> an extra assembly input file in debug info from compiler generated
> .debug_line or fail with the APP marker:
>
> https://sourceware.org/bugzilla/show_bug.cgi?id=25878
> https://sourceware.org/bugzilla/show_bug.cgi?id=26740
> https://sourceware.org/bugzilla/show_bug.cgi?id=26778
>
> Also replace success with dwarf4_success in the 32-bit --gdwarf-4 check.
>
> PR bootstrap/97451
> * configure.ac (HAVE_AS_WORKING_DWARF_4_FLAG): Renamed to ...
> (HAVE_AS_WORKING_DWARF_N_FLAG): This. Don't define if there is
> an extra assembly input file in debug info. Replace success
> with dwarf4_success in the 32-bit --gdwarf-4 check.
> * dwarf2out.c (asm_outputs_debug_line_str): Check
> HAVE_AS_WORKING_DWARF_N_FLAG instead of
> HAVE_AS_WORKING_DWARF_4_FLAG.
> * gcc.c (ASM_DEBUG_SPEC): Likewise.
> (ASM_DEBUG_OPTION_SPEC): Likewise.
> * config.in: Regenerated.
> * configure: Likewise.
> ---
> gcc/config.in | 6 +--
> gcc/configure | 106 +++++++++++++++++++++++++++++++++++++++++++++--
> gcc/configure.ac | 59 ++++++++++++++++++++++++--
> gcc/dwarf2out.c | 2 +-
> gcc/gcc.c | 4 +-
> 5 files changed, 164 insertions(+), 13 deletions(-)
>
> diff --git a/gcc/config.in b/gcc/config.in
> index 3657c46f349..b7c3107bfe3 100644
> --- a/gcc/config.in
> +++ b/gcc/config.in
> @@ -719,10 +719,10 @@
> #endif
>
>
> -/* Define if your assembler supports --gdwarf-4 even with compiler generated
> - .debug_line */
> +/* Define if your assembler supports --gdwarf-4/--gdwarf-5 even with compiler
> + generated .debug_line. */
> #ifndef USED_FOR_TARGET
> -#undef HAVE_AS_WORKING_DWARF_4_FLAG
> +#undef HAVE_AS_WORKING_DWARF_N_FLAG
> #endif
>
>
> diff --git a/gcc/configure b/gcc/configure
> index abff47d30eb..f96a89e8c37 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -28701,7 +28701,7 @@ fi
> { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_debug_line_32_flag" >&5
> $as_echo "$gcc_cv_as_debug_line_32_flag" >&6; }
> if test $gcc_cv_as_debug_line_32_flag = yes; then
> - success=yes
> + dwarf4_success=yes
> fi
>
> else
> @@ -28741,6 +28741,7 @@ fi
>
> fi
> if test $dwarf4_success = yes; then
> + dwarf4_success=no
> { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --gdwarf-4 not refusing compiler generated .debug_line" >&5
> $as_echo_n "checking assembler for --gdwarf-4 not refusing compiler generated .debug_line... " >&6; }
> if ${gcc_cv_as_dwarf_4_debug_line_flag+:} false; then :
> @@ -28772,9 +28773,7 @@ fi
> { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_dwarf_4_debug_line_flag" >&5
> $as_echo "$gcc_cv_as_dwarf_4_debug_line_flag" >&6; }
> if test $gcc_cv_as_dwarf_4_debug_line_flag = yes; then
> -
> -$as_echo "#define HAVE_AS_WORKING_DWARF_4_FLAG 1" >>confdefs.h
> -
> + dwarf4_success=yes
> fi
>
> break
> @@ -28785,6 +28784,105 @@ fi
> dwarf4_line_sz=5
> done
>
> + if test $dwarf4_success = yes; then
> + conftest_s="\
> + .file \"foo.c\"
> + .text
> +bar:
> +#APP
> +# 82 \"xxx.h\" 1
> + $insn
> +# 0 \"\" 2
> +#NO_APP
> + $insn
> +foo:
> + .file 1 \"foo.c\"
> + $insn
> + .file 2 \"foo.h\"
> + ret
> +"
> + dwarf4_success=no
> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --gdwarf-4 with the APP marker" >&5
> +$as_echo_n "checking assembler for --gdwarf-4 with the APP marker... " >&6; }
> +if ${gcc_cv_as_dwarf_4_app_flag+:} false; then :
> + $as_echo_n "(cached) " >&6
> +else
> + gcc_cv_as_dwarf_4_app_flag=no
> + if test x$gcc_cv_as != x; then
> + $as_echo "$conftest_s" > conftest.s
> + if { ac_try='$gcc_cv_as $gcc_cv_as_flags --gdwarf-4 -o conftest.o conftest.s >&5'
> + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
> + (eval $ac_try) 2>&5
> + ac_status=$?
> + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> + test $ac_status = 0; }; }
> + then
> + gcc_cv_as_dwarf_4_app_flag=yes
> + else
> + echo "configure: failed program was" >&5
> + cat conftest.s >&5
> + fi
> + rm -f conftest.o conftest.s
> + fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_dwarf_4_app_flag" >&5
> +$as_echo "$gcc_cv_as_dwarf_4_app_flag" >&6; }
> +if test $gcc_cv_as_dwarf_4_app_flag = yes; then
> + dwarf4_success=yes
> +fi
> +
> + fi
> +
> + if test $dwarf4_success = yes; then
> + conftest_s="\
> + .text
> + .globl foo
> + .type foo, %function
> +foo:
> + $insn
> + .size foo, .-foo
> + .file 1 \"foo.c\"
> +"
> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for working --gdwarf-4/--gdwarf-5 for all sources" >&5
> +$as_echo_n "checking assembler for working --gdwarf-4/--gdwarf-5 for all sources... " >&6; }
> +if ${gcc_cv_as_working_gdwarf_n_flag+:} false; then :
> + $as_echo_n "(cached) " >&6
> +else
> + gcc_cv_as_working_gdwarf_n_flag=no
> + if test x$gcc_cv_as != x; then
> + $as_echo "$conftest_s" > conftest.s
> + if { ac_try='$gcc_cv_as $gcc_cv_as_flags --gdwarf-4 -o conftest.o conftest.s >&5'
> + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
> + (eval $ac_try) 2>&5
> + ac_status=$?
> + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> + test $ac_status = 0; }; }
> + then
> + if test x$gcc_cv_readelf != x \
> + && $gcc_cv_readelf -w conftest.o 2>&1 \
> + | grep conftest.s > /dev/null 2>&1; then
> + gcc_cv_as_working_gdwarf_n_flag=no
> + else
> + gcc_cv_as_working_gdwarf_n_flag=yes
> + fi
> + else
> + echo "configure: failed program was" >&5
> + cat conftest.s >&5
> + fi
> + rm -f conftest.o conftest.s
> + fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_working_gdwarf_n_flag" >&5
> +$as_echo "$gcc_cv_as_working_gdwarf_n_flag" >&6; }
> +
> +
> + if test $gcc_cv_as_working_gdwarf_n_flag = yes; then
> +
> +$as_echo "#define HAVE_AS_WORKING_DWARF_N_FLAG 1" >>confdefs.h
> +
> + fi
> + fi
> +
> { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --gstabs option" >&5
> $as_echo_n "checking assembler for --gstabs option... " >&6; }
> if ${gcc_cv_as_gstabs_flag+:} false; then :
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 26a5d8e3619..9154a5475dc 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -5364,7 +5364,7 @@ foo:
> gcc_GAS_CHECK_FEATURE([assembly of compiler generated 32-bit .debug_line],
> gcc_cv_as_debug_line_32_flag,
> [elf,2,36,0], [], [$conftest_s],,
> - [success=yes])
> + [dwarf4_success=yes])
> else
> gcc_GAS_CHECK_FEATURE([assembly of compiler generated 64-bit .debug_line],
> gcc_cv_as_debug_line_64_flag,
> @@ -5372,11 +5372,11 @@ foo:
> [dwarf4_success=yes])
> fi
> if test $dwarf4_success = yes; then
> + dwarf4_success=no
> gcc_GAS_CHECK_FEATURE([--gdwarf-4 not refusing compiler generated .debug_line],
> gcc_cv_as_dwarf_4_debug_line_flag,
> [elf,2,36,0], [--gdwarf-4], [$conftest_s],,
> - [AC_DEFINE(HAVE_AS_WORKING_DWARF_4_FLAG, 1,
> -[Define if your assembler supports --gdwarf-4 even with compiler generated .debug_line])])
> + [dwarf4_success=yes])
> break
> fi
> dwarf4_debug_info_size=0x36
> @@ -5385,6 +5385,59 @@ foo:
> dwarf4_line_sz=5
> done
>
> + if test $dwarf4_success = yes; then
> + conftest_s="\
> + .file \"foo.c\"
> + .text
> +bar:
> +#APP
> +# 82 \"xxx.h\" 1
> + $insn
> +# 0 \"\" 2
> +#NO_APP
> + $insn
> +foo:
> + .file 1 \"foo.c\"
> + $insn
> + .file 2 \"foo.h\"
> + ret
> +"
> + dwarf4_success=no
> + gcc_GAS_CHECK_FEATURE([--gdwarf-4 with the APP marker],
> + gcc_cv_as_dwarf_4_app_flag,,
> + [--gdwarf-4], [$conftest_s],, [dwarf4_success=yes])
> + fi
> +
> + if test $dwarf4_success = yes; then
> + conftest_s="\
> + .text
> + .globl foo
> + .type foo, %function
> +foo:
> + $insn
> + .size foo, .-foo
> + .file 1 \"foo.c\"
> +"
> + gcc_GAS_CHECK_FEATURE([working --gdwarf-4/--gdwarf-5 for all sources],
> + gcc_cv_as_working_gdwarf_n_flag,,
> + [--gdwarf-4],
> + [$conftest_s],
> + [changequote(,)dnl
> + if test x$gcc_cv_readelf != x \
> + && $gcc_cv_readelf -w conftest.o 2>&1 \
> + | grep conftest.s > /dev/null 2>&1; then
> + gcc_cv_as_working_gdwarf_n_flag=no
> + else
> + gcc_cv_as_working_gdwarf_n_flag=yes
> + fi
> + changequote([,])dnl])
> + if test $gcc_cv_as_working_gdwarf_n_flag = yes; then
> + AC_DEFINE(HAVE_AS_WORKING_DWARF_N_FLAG, 1,
> +[Define if your assembler supports --gdwarf-4/--gdwarf-5 even with
> + compiler generated .debug_line.])
> + fi
> + fi
> +
> gcc_GAS_CHECK_FEATURE([--gstabs option],
> gcc_cv_as_gstabs_flag,
> [elf,2,11,0], [--gstabs], [$insn],,
> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
> index ba93a6c3d81..534877babfb 100644
> --- a/gcc/dwarf2out.c
> +++ b/gcc/dwarf2out.c
> @@ -11884,7 +11884,7 @@ asm_outputs_debug_line_str (void)
> return true;
> else
> {
> -#if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_4_FLAG)
> +#if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG)
> return !dwarf_split_debug_info && dwarf_version >= 5;
> #else
> return false;
> diff --git a/gcc/gcc.c b/gcc/gcc.c
> index 337c27442a3..cdf4d4f2403 100644
> --- a/gcc/gcc.c
> +++ b/gcc/gcc.c
> @@ -880,7 +880,7 @@ proper position among the other output files. */
> /* Define ASM_DEBUG_SPEC to be a spec suitable for translating '-g'
> to the assembler, when compiling assembly sources only. */
> #ifndef ASM_DEBUG_SPEC
> -# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_4_FLAG)
> +# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG)
> /* If --gdwarf-N is supported and as can handle even compiler generated
> .debug_line with it, supply --gdwarf-N in ASM_DEBUG_OPTION_SPEC rather
> than in ASM_DEBUG_SPEC, so that it applies to both .s and .c etc.
> @@ -921,7 +921,7 @@ proper position among the other output files. */
> /* Define ASM_DEBUG_OPTION_SPEC to be a spec suitable for translating '-g'
> to the assembler when compiling all sources. */
> #ifndef ASM_DEBUG_OPTION_SPEC
> -# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_4_FLAG)
> +# if defined(HAVE_AS_GDWARF_5_DEBUG_FLAG) && defined(HAVE_AS_WORKING_DWARF_N_FLAG)
> # define ASM_DEBUG_OPTION_DWARF_OPT \
> "%{%:dwarf-version-gt(4):--gdwarf-5 ;" \
> "%:dwarf-version-gt(3):--gdwarf-4 ;" \
> --
> 2.26.2
>
Jakub
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-10-24 15:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16 17:58 [PATCH] Check for working assembler --gdwarf-[45] options H.J. Lu
2020-10-16 18:17 ` Jakub Jelinek
2020-10-16 18:29 ` H.J. Lu
2020-10-17 13:23 ` [PATCH] Update check for working assembler --gdwarf-4 option H.J. Lu
2020-10-24 15:28 ` V2 " H.J. Lu
2020-10-24 15:55 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).