debug: Pass --gdwarf-N to assembler if fixed gas is detected during configure

> > As for the test assembly, I'd say we should take
> > #define F void foo (void) {}
> > F
> > compile it with
> > gcc -S -O2 -g1 -dA -gno-as-loc-support -fno-merge-debug-strings
> > remove .cfi_* directives, remove the ret instruction, change @function
> > and @progbits to %function and %progbits, change .uleb128 to just .byte,
> > I think all the values should be small enough, maybe change .value to
> > .2byte and .long to .4byte (whatever is most portable across different
> > arches and gas versions), simplify (shorten) strings and adjust
> > sizes, and do something with the .quad directives, that is dependent on
> > the address size, perhaps just take those attributes out and adjust
> > .debug_abbrev?  Finally, remove all comments (emit them in the first case
> > just to better understand the debug info).
>
> I'm afraid it is hard to avoid the .quad or .8byte.
> Here is a 64-bit address version that assembles fine by both x86_64 and
> aarch64 as.
> Unfortunately doesn't fail with broken gas versions with -gdwarf-2 without
> the nop, so we'll need at least a nop in there.
> Fortunately gcc/configure.ac already determines the right nop insn for the
> target, in $insn.
> So I guess what we want next is have the 32-bit version of this with .4byte
> instead of .8byte and just let's try to assemble both versions, first
> without -gdwarf-2 and the one that succeeds assemble again with -gdwarf-2
> and check for the duplicate .debug_line sections error.

Ok, here it is in patch form.
I've briefly tested it, with the older binutils I have around (no --gdwarf-N
support), with latest gas (--gdwarf-N that can be passed to as even when
compiling C/C++ etc. code and emitting .debug_line) and latest gas with Mark's fix
reverted (--gdwarf-N support, but can only pass it to as when assembling
user .s/.S files, not when compiling C/C++ etc.).

2020-10-07  Jakub Jelinek  <jakub@redhat.com>

	* configure.ac (HAVE_AS_GDWARF_5_DEBUG_FLAG,
	HAVE_AS_WORKING_DWARF_4_FLAG): New tests.
	* gcc.c (ASM_DEBUG_DWARF_OPTION): Define.
	(ASM_DEBUG_SPEC): Use ASM_DEBUG_DWARF_OPTION instead of
	"--gdwarf2".  Use %{cond:opt1;:opt2} style.
	(ASM_DEBUG_OPTION_DWARF_OPT): Define.
	(ASM_DEBUG_OPTION_SPEC): Define.
	(asm_debug_option): New variable.
	(asm_options): Add "%(asm_debug_option)".
	(static_specs): Add asm_debug_option entry.
	(static_spec_functions): Add dwarf-version-gt.
	(debug_level_greater_than_spec_func): New function.
	* config/darwin.h (ASM_DEBUG_OPTION_SPEC): Define.
	* config/darwin9.h (ASM_DEBUG_OPTION_SPEC): Redefine.
	* config.in: Regenerated.
	* configure: Regenerated.
This commit is contained in:
Jakub Jelinek 2020-10-07 10:55:35 +02:00
parent e91c34262d
commit 6923255e35
6 changed files with 588 additions and 4 deletions

View File

@ -394,6 +394,12 @@
#endif
/* Define if your assembler supports the --gdwarf-5 option. */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_GDWARF_5_DEBUG_FLAG
#endif
/* Define if your assembler supports .gnu_attribute. */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_GNU_ATTRIBUTE
@ -713,6 +719,13 @@
#endif
/* Define if your assembler supports --gdwarf-4 even with compiler generated
.debug_line */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_WORKING_DWARF_4_FLAG
#endif
/* Define if your assembler supports -xbrace_comment option. */
#ifndef USED_FOR_TARGET
#undef HAVE_AS_XBRACE_COMMENT_OPTION

View File

@ -476,6 +476,7 @@ extern GTY(()) int darwin_ms_struct;
debugging data. */
#define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{!gdwarf*:--gstabs}}}"
#define ASM_DEBUG_OPTION_SPEC ""
#define ASM_FINAL_SPEC \
"%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform} %<gsplit-dwarf"

View File

@ -41,6 +41,9 @@ along with GCC; see the file COPYING3. If not see
#undef ASM_DEBUG_SPEC
#define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{gstabs:--gstabs}}}"
#undef ASM_DEBUG_OPTION_SPEC
#define ASM_DEBUG_OPTION_SPEC ""
#undef ASM_OUTPUT_ALIGNED_COMMON
#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
do { \

310
gcc/configure vendored
View File

@ -28475,6 +28475,316 @@ $as_echo "#define HAVE_AS_GDWARF2_DEBUG_FLAG 1" >>confdefs.h
fi
{ $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 :
$as_echo_n "(cached) " >&6
else
gcc_cv_as_gdwarf_5_flag=no
if test $in_tree_gas = yes; then
if test $in_tree_gas_is_elf = yes \
&& test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 36 \) \* 1000 + 0`
then gcc_cv_as_gdwarf_5_flag=yes
fi
elif test x$gcc_cv_as != x; then
$as_echo "$insn" > 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
gcc_cv_as_gdwarf_5_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_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
fi
dwarf4_debug_info_size=0x46
dwarf4_high_pc_form=7
dwarf4_debug_aranges_size=0x2c
dwarf4_line_sz=9
for dwarf4_addr_size in 8 4; do
conftest_s="\
.file \"a.c\"
.text
.Ltext0:
.p2align 4
.globl foo
.type foo, %function
foo:
.LFB0:
.LM1:
$insn
.LM2:
.LFE0:
.size foo, .-foo
.Letext0:
.section .debug_info,\"\",%progbits
.Ldebug_info0:
.4byte $dwarf4_debug_info_size
.2byte 0x4
.4byte .Ldebug_abbrev0
.byte 0x$dwarf4_addr_size
.byte 0x1
.ascii \"GNU C17\\0\"
.byte 0xc
.ascii \"a.c\\0\"
.ascii \"/\\0\"
.${dwarf4_addr_size}byte .Ltext0
.${dwarf4_addr_size}byte .Letext0-.Ltext0
.4byte .Ldebug_line0
.byte 0x2
.ascii \"foo\\0\"
.byte 0x1
.byte 0x2
.byte 0x1
.${dwarf4_addr_size}byte .LFB0
.${dwarf4_addr_size}byte .LFE0-.LFB0
.byte 0x1
.byte 0x9c
.byte 0
.section .debug_abbrev,\"\",%progbits
.Ldebug_abbrev0:
.byte 0x1
.byte 0x11
.byte 0x1
.byte 0x25
.byte 0x8
.byte 0x13
.byte 0xb
.byte 0x3
.byte 0x8
.byte 0x1b
.byte 0x8
.byte 0x11
.byte 0x1
.byte 0x12
.byte 0x$dwarf4_high_pc_form
.byte 0x10
.byte 0x17
.byte 0
.byte 0
.byte 0x2
.byte 0x2e
.byte 0
.byte 0x3f
.byte 0x19
.byte 0x3
.byte 0x8
.byte 0x3a
.byte 0xb
.byte 0x3b
.byte 0xb
.byte 0x39
.byte 0xb
.byte 0x11
.byte 0x1
.byte 0x12
.byte 0x$dwarf4_high_pc_form
.byte 0x40
.byte 0x18
.byte 0
.byte 0
.byte 0
.section .debug_aranges,\"\",%progbits
.4byte $dwarf4_debug_aranges_size
.2byte 0x2
.4byte .Ldebug_info0
.byte 0x8
.byte 0
.2byte 0
.2byte 0
.${dwarf4_addr_size}byte .Ltext0
.${dwarf4_addr_size}byte .Letext0-.Ltext0
.${dwarf4_addr_size}byte 0
.${dwarf4_addr_size}byte 0
.section .debug_line,\"\",%progbits
.Ldebug_line0:
.4byte .LELT0-.LSLT0
.LSLT0:
.2byte 0x4
.4byte .LELTP0-.LASLTP0
.LASLTP0:
.byte 0x1
.byte 0x1
.byte 0x1
.byte 0xf6
.byte 0xf2
.byte 0xd
.byte 0
.byte 0x1
.byte 0x1
.byte 0x1
.byte 0x1
.byte 0
.byte 0
.byte 0
.byte 0x1
.byte 0
.byte 0
.byte 0x1
.byte 0
.ascii \"a.c\\0\"
.byte 0
.byte 0
.byte 0
.byte 0
.LELTP0:
.byte 0
.byte 0x$dwarf4_line_sz
.byte 0x2
.${dwarf4_addr_size}byte .LM1
.byte 0x18
.byte 0x5
.byte 0x1
.byte 0
.byte 0x$dwarf4_line_sz
.byte 0x2
.${dwarf4_addr_size}byte .LM2
.byte 0x1
.byte 0x5
.byte 0x1
.byte 0
.byte 0x$dwarf4_line_sz
.byte 0x2
.${dwarf4_addr_size}byte .Letext0
.byte 0
.byte 0x1
.byte 0x1
.LELT0:
.section .debug_str,\"\",%progbits
.ident \"GCC\"
"
dwarf4_success=no
if test $dwarf4_addr_size = 4; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for assembly of compiler generated 32-bit .debug_line" >&5
$as_echo_n "checking assembler for assembly of compiler generated 32-bit .debug_line... " >&6; }
if ${gcc_cv_as_debug_line_32_flag+:} false; then :
$as_echo_n "(cached) " >&6
else
gcc_cv_as_debug_line_32_flag=no
if test $in_tree_gas = yes; then
if test $in_tree_gas_is_elf = yes \
&& test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 36 \) \* 1000 + 0`
then gcc_cv_as_debug_line_32_flag=yes
fi
elif test x$gcc_cv_as != x; then
$as_echo "$conftest_s" > conftest.s
if { ac_try='$gcc_cv_as $gcc_cv_as_flags -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_debug_line_32_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_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
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for assembly of compiler generated 64-bit .debug_line" >&5
$as_echo_n "checking assembler for assembly of compiler generated 64-bit .debug_line... " >&6; }
if ${gcc_cv_as_debug_line_64_flag+:} false; then :
$as_echo_n "(cached) " >&6
else
gcc_cv_as_debug_line_64_flag=no
if test $in_tree_gas = yes; then
if test $in_tree_gas_is_elf = yes \
&& test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 36 \) \* 1000 + 0`
then gcc_cv_as_debug_line_64_flag=yes
fi
elif test x$gcc_cv_as != x; then
$as_echo "$conftest_s" > conftest.s
if { ac_try='$gcc_cv_as $gcc_cv_as_flags -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_debug_line_64_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_debug_line_64_flag" >&5
$as_echo "$gcc_cv_as_debug_line_64_flag" >&6; }
if test $gcc_cv_as_debug_line_64_flag = yes; then
dwarf4_success=yes
fi
fi
if test $dwarf4_success = yes; then
{ $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 :
$as_echo_n "(cached) " >&6
else
gcc_cv_as_dwarf_4_debug_line_flag=no
if test $in_tree_gas = yes; then
if test $in_tree_gas_is_elf = yes \
&& test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 36 \) \* 1000 + 0`
then gcc_cv_as_dwarf_4_debug_line_flag=yes
fi
elif 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_debug_line_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_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
fi
break
fi
dwarf4_debug_info_size=0x36
dwarf4_high_pc_form=6
dwarf4_debug_aranges_size=0x1c
dwarf4_line_sz=5
done
{ $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 :

View File

@ -5197,6 +5197,194 @@ if test x"$insn" != x; then
[AC_DEFINE(HAVE_AS_GDWARF2_DEBUG_FLAG, 1,
[Define if your assembler supports the --gdwarf2 option.])])
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.])])
dwarf4_debug_info_size=0x46
dwarf4_high_pc_form=7
dwarf4_debug_aranges_size=0x2c
dwarf4_line_sz=9
for dwarf4_addr_size in 8 4; do
conftest_s="\
.file \"a.c\"
.text
.Ltext0:
.p2align 4
.globl foo
.type foo, %function
foo:
.LFB0:
.LM1:
$insn
.LM2:
.LFE0:
.size foo, .-foo
.Letext0:
.section .debug_info,\"\",%progbits
.Ldebug_info0:
.4byte $dwarf4_debug_info_size
.2byte 0x4
.4byte .Ldebug_abbrev0
.byte 0x$dwarf4_addr_size
.byte 0x1
.ascii \"GNU C17\\0\"
.byte 0xc
.ascii \"a.c\\0\"
.ascii \"/\\0\"
.${dwarf4_addr_size}byte .Ltext0
.${dwarf4_addr_size}byte .Letext0-.Ltext0
.4byte .Ldebug_line0
.byte 0x2
.ascii \"foo\\0\"
.byte 0x1
.byte 0x2
.byte 0x1
.${dwarf4_addr_size}byte .LFB0
.${dwarf4_addr_size}byte .LFE0-.LFB0
.byte 0x1
.byte 0x9c
.byte 0
.section .debug_abbrev,\"\",%progbits
.Ldebug_abbrev0:
.byte 0x1
.byte 0x11
.byte 0x1
.byte 0x25
.byte 0x8
.byte 0x13
.byte 0xb
.byte 0x3
.byte 0x8
.byte 0x1b
.byte 0x8
.byte 0x11
.byte 0x1
.byte 0x12
.byte 0x$dwarf4_high_pc_form
.byte 0x10
.byte 0x17
.byte 0
.byte 0
.byte 0x2
.byte 0x2e
.byte 0
.byte 0x3f
.byte 0x19
.byte 0x3
.byte 0x8
.byte 0x3a
.byte 0xb
.byte 0x3b
.byte 0xb
.byte 0x39
.byte 0xb
.byte 0x11
.byte 0x1
.byte 0x12
.byte 0x$dwarf4_high_pc_form
.byte 0x40
.byte 0x18
.byte 0
.byte 0
.byte 0
.section .debug_aranges,\"\",%progbits
.4byte $dwarf4_debug_aranges_size
.2byte 0x2
.4byte .Ldebug_info0
.byte 0x8
.byte 0
.2byte 0
.2byte 0
.${dwarf4_addr_size}byte .Ltext0
.${dwarf4_addr_size}byte .Letext0-.Ltext0
.${dwarf4_addr_size}byte 0
.${dwarf4_addr_size}byte 0
.section .debug_line,\"\",%progbits
.Ldebug_line0:
.4byte .LELT0-.LSLT0
.LSLT0:
.2byte 0x4
.4byte .LELTP0-.LASLTP0
.LASLTP0:
.byte 0x1
.byte 0x1
.byte 0x1
.byte 0xf6
.byte 0xf2
.byte 0xd
.byte 0
.byte 0x1
.byte 0x1
.byte 0x1
.byte 0x1
.byte 0
.byte 0
.byte 0
.byte 0x1
.byte 0
.byte 0
.byte 0x1
.byte 0
.ascii \"a.c\\0\"
.byte 0
.byte 0
.byte 0
.byte 0
.LELTP0:
.byte 0
.byte 0x$dwarf4_line_sz
.byte 0x2
.${dwarf4_addr_size}byte .LM1
.byte 0x18
.byte 0x5
.byte 0x1
.byte 0
.byte 0x$dwarf4_line_sz
.byte 0x2
.${dwarf4_addr_size}byte .LM2
.byte 0x1
.byte 0x5
.byte 0x1
.byte 0
.byte 0x$dwarf4_line_sz
.byte 0x2
.${dwarf4_addr_size}byte .Letext0
.byte 0
.byte 0x1
.byte 0x1
.LELT0:
.section .debug_str,\"\",%progbits
.ident \"GCC\"
"
dwarf4_success=no
if test $dwarf4_addr_size = 4; then
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])
else
gcc_GAS_CHECK_FEATURE([assembly of compiler generated 64-bit .debug_line],
gcc_cv_as_debug_line_64_flag,
[elf,2,36,0], [], [$conftest_s],,
[dwarf4_success=yes])
fi
if test $dwarf4_success = yes; then
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])])
break
fi
dwarf4_debug_info_size=0x36
dwarf4_high_pc_form=6
dwarf4_debug_aranges_size=0x1c
dwarf4_line_sz=5
done
gcc_GAS_CHECK_FEATURE([--gstabs option],
gcc_cv_as_gstabs_flag,
[elf,2,11,0], [--gstabs], [$insn],,

View File

@ -430,6 +430,7 @@ static const char *pass_through_libs_spec_func (int, const char **);
static const char *dumps_spec_func (int, const char **);
static const char *greater_than_spec_func (int, const char **);
static const char *debug_level_greater_than_spec_func (int, const char **);
static const char *dwarf_version_greater_than_spec_func (int, const char **);
static const char *find_fortran_preinclude_file (int, const char **);
static char *convert_white_space (char *);
static char *quote_spec (char *);
@ -876,22 +877,39 @@ proper position among the other output files. */
#endif /* HAVE_LD_COMPRESS_DEBUG >= 2 */
/* Define ASM_DEBUG_SPEC to be a spec suitable for translating '-g'
to the assembler. */
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 --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.
compilations. */
# define ASM_DEBUG_DWARF_OPTION ""
# elif defined(HAVE_AS_GDWARF_5_DEBUG_FLAG)
# define ASM_DEBUG_DWARF_OPTION "%{%:dwarf-version-gt(4):--gdwarf-5;" \
"%:dwarf-version-gt(3):--gdwarf-4;" \
"%:dwarf-version-gt(2):--gdwarf-3;" \
":--gdwarf2}"
# else
# define ASM_DEBUG_DWARF_OPTION "--gdwarf2"
# endif
# if defined(DBX_DEBUGGING_INFO) && defined(DWARF2_DEBUGGING_INFO) \
&& defined(HAVE_AS_GDWARF2_DEBUG_FLAG) && defined(HAVE_AS_GSTABS_DEBUG_FLAG)
# define ASM_DEBUG_SPEC \
(PREFERRED_DEBUGGING_TYPE == DBX_DEBUG \
? "%{%:debug-level-gt(0):" \
"%{gdwarf*:--gdwarf2}%{!gdwarf*:%{g*:--gstabs}}}" ASM_MAP \
"%{gdwarf*:" ASM_DEBUG_DWARF_OPTION "};" \
":%{g*:--gstabs}}" ASM_MAP \
: "%{%:debug-level-gt(0):" \
"%{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}}}" ASM_MAP)
"%{gstabs*:--gstabs;" \
":%{g*:" ASM_DEBUG_DWARF_OPTION "}}}" ASM_MAP)
# else
# if defined(DBX_DEBUGGING_INFO) && defined(HAVE_AS_GSTABS_DEBUG_FLAG)
# define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):--gstabs}}" ASM_MAP
# endif
# if defined(DWARF2_DEBUGGING_INFO) && defined(HAVE_AS_GDWARF2_DEBUG_FLAG)
# define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):--gdwarf2}}" ASM_MAP
# define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):" \
ASM_DEBUG_DWARF_OPTION "}}" ASM_MAP
# endif
# endif
#endif
@ -899,6 +917,32 @@ proper position among the other output files. */
# define ASM_DEBUG_SPEC ""
#endif
/* 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)
# define ASM_DEBUG_OPTION_DWARF_OPT \
"%{%:dwarf-version-gt(4):--gdwarf-5 ;" \
"%:dwarf-version-gt(3):--gdwarf-4 ;" \
"%:dwarf-version-gt(2):--gdwarf-3 ;" \
":--gdwarf2 }"
# if defined(DBX_DEBUGGING_INFO) && defined(DWARF2_DEBUGGING_INFO)
# define ASM_DEBUG_OPTION_SPEC \
(PREFERRED_DEBUGGING_TYPE == DBX_DEBUG \
? "%{%:debug-level-gt(0):" \
"%{gdwarf*:" ASM_DEBUG_OPTION_DWARF_OPT "}}" \
: "%{%:debug-level-gt(0):" \
"%{!gstabs*:%{g*:" ASM_DEBUG_OPTION_DWARF_OPT "}}}")
# elif defined(DWARF2_DEBUGGING_INFO)
# define ASM_DEBUG_OPTION_SPEC "%{g*:%{%:debug-level-gt(0):" \
ASM_DEBUG_OPTION_DWARF_OPT "}}"
# endif
# endif
#endif
#ifndef ASM_DEBUG_OPTION_SPEC
# define ASM_DEBUG_OPTION_SPEC ""
#endif
/* Here is the spec for running the linker, after compiling all files. */
/* This is overridable by the target in case they need to specify the
@ -1113,6 +1157,7 @@ proper position among the other output files. */
#endif
static const char *asm_debug = ASM_DEBUG_SPEC;
static const char *asm_debug_option = ASM_DEBUG_OPTION_SPEC;
static const char *cpp_spec = CPP_SPEC;
static const char *cc1_spec = CC1_SPEC;
static const char *cc1plus_spec = CC1PLUS_SPEC;
@ -1212,6 +1257,7 @@ static const char *asm_options =
to the assembler equivalents. */
"%{v} %{w:-W} %{I*} "
#endif
"%(asm_debug_option)"
ASM_COMPRESS_DEBUG_SPEC
"%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}";
@ -1608,6 +1654,7 @@ static struct spec_list static_specs[] =
{
INIT_STATIC_SPEC ("asm", &asm_spec),
INIT_STATIC_SPEC ("asm_debug", &asm_debug),
INIT_STATIC_SPEC ("asm_debug_option", &asm_debug_option),
INIT_STATIC_SPEC ("asm_final", &asm_final_spec),
INIT_STATIC_SPEC ("asm_options", &asm_options),
INIT_STATIC_SPEC ("invoke_as", &invoke_as),
@ -1690,6 +1737,7 @@ static const struct spec_function static_spec_functions[] =
{ "dumps", dumps_spec_func },
{ "gt", greater_than_spec_func },
{ "debug-level-gt", debug_level_greater_than_spec_func },
{ "dwarf-version-gt", dwarf_version_greater_than_spec_func },
{ "fortran-preinclude-file", find_fortran_preinclude_file},
#ifdef EXTRA_SPEC_FUNCTIONS
EXTRA_SPEC_FUNCTIONS
@ -10614,6 +10662,27 @@ debug_level_greater_than_spec_func (int argc, const char **argv)
return NULL;
}
/* Returns "" if dwarf_version is greater than ARGV[ARGC-1].
Otherwise, return NULL. */
static const char *
dwarf_version_greater_than_spec_func (int argc, const char **argv)
{
char *converted;
if (argc != 1)
fatal_error (input_location,
"wrong number of arguments to %%:dwarf-version-gt");
long arg = strtol (argv[0], &converted, 10);
gcc_assert (converted != argv[0]);
if (dwarf_version > arg)
return "";
return NULL;
}
static void
path_prefix_reset (path_prefix *prefix)
{