Always default to DWARF2_DEBUG if not specified, warn about deprecated STABS

Message ID p365p696-562n-38s1-5os2-7999s6q7s572@fhfr.qr
State New
Headers
Series Always default to DWARF2_DEBUG if not specified, warn about deprecated STABS |

Commit Message

Richard Biener Sept. 21, 2021, 2:25 p.m. UTC
  This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE
is not specified by the target and errors out if DWARF DWARF is not supported.

It also makes us warn when STABS is enabled but not the preferred
debugging type and removes the corresponding diagnostic from the Ada frontend.
The warnings are pruned from the testsuite output via prune_gcc_output.

The following target configurations now explicitely default to STABS:
 pdp11-*-*   pdp11 is a.out, dwarf support is difficult
 hppa[12]*-*-hpux10*  does not support DWARF
 hppa[12]*-*-hpux11*  likewise
note that the hppa configs have been deprecated.

Targets with DWARF support will now see
> ./cc1 -quiet t.c -gstabs
t.c: warning: STABS debugging information is obsolete and not supported anymore

that is, -gstabs will still generate STABS but use will be diagnosed
on targets where DWARF is available.

I have built all targets from contrib/config-list.mk to make sure we
don't run into the #error and the following makes the STABS usage
explicit for pdp11 and hppa with SOM.

This completes the series of deprecating STABS for GCC 12.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

OK for trunk?

Thanks,
Richard.

2021-09-21  Richard Biener  <rguenther@suse.de>

gcc/
	* defaults.h (PREFERRED_DEBUGGING_TYPE): Choose DWARF2_DEBUG
	when not set.
	* toplev.c (process_options): Warn when STABS debugging is
	enabled but not the preferred format.
	* config/pa/som.h (PREFERRED_DEBUGGING_TYPE): Define to
	DBX_DEBUG.
	* config/pdp11/pdp11.h (PREFERRED_DEBUGGING_TYPE): Likewise.

gcc/ada/
	* gcc-interface/misc.c (gnat_post_options): Do not warn
	about DBX_DEBUG use here.

gcc/testsuite/
	* lib/prune.exp: Prune STABS obsoletion message.
---
 gcc/ada/gcc-interface/misc.c |  6 ------
 gcc/config/pa/som.h          |  4 ++++
 gcc/config/pdp11/pdp11.h     |  3 +++
 gcc/defaults.h               | 29 +++++------------------------
 gcc/testsuite/lib/prune.exp  |  3 +++
 gcc/toplev.c                 |  5 +++++
 6 files changed, 20 insertions(+), 30 deletions(-)
  

Comments

Richard Biener Sept. 28, 2021, 6:14 a.m. UTC | #1
On Tue, Sep 21, 2021 at 4:26 PM Richard Biener via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE
> is not specified by the target and errors out if DWARF DWARF is not supported.
>
> It also makes us warn when STABS is enabled but not the preferred
> debugging type and removes the corresponding diagnostic from the Ada frontend.
> The warnings are pruned from the testsuite output via prune_gcc_output.
>
> The following target configurations now explicitely default to STABS:
>  pdp11-*-*   pdp11 is a.out, dwarf support is difficult
>  hppa[12]*-*-hpux10*  does not support DWARF
>  hppa[12]*-*-hpux11*  likewise
> note that the hppa configs have been deprecated.
>
> Targets with DWARF support will now see
> > ./cc1 -quiet t.c -gstabs
> t.c: warning: STABS debugging information is obsolete and not supported anymore
>
> that is, -gstabs will still generate STABS but use will be diagnosed
> on targets where DWARF is available.
>
> I have built all targets from contrib/config-list.mk to make sure we
> don't run into the #error and the following makes the STABS usage
> explicit for pdp11 and hppa with SOM.
>
> This completes the series of deprecating STABS for GCC 12.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
>
> OK for trunk?

Ping.

> Thanks,
> Richard.
>
> 2021-09-21  Richard Biener  <rguenther@suse.de>
>
> gcc/
>         * defaults.h (PREFERRED_DEBUGGING_TYPE): Choose DWARF2_DEBUG
>         when not set.
>         * toplev.c (process_options): Warn when STABS debugging is
>         enabled but not the preferred format.
>         * config/pa/som.h (PREFERRED_DEBUGGING_TYPE): Define to
>         DBX_DEBUG.
>         * config/pdp11/pdp11.h (PREFERRED_DEBUGGING_TYPE): Likewise.
>
> gcc/ada/
>         * gcc-interface/misc.c (gnat_post_options): Do not warn
>         about DBX_DEBUG use here.
>
> gcc/testsuite/
>         * lib/prune.exp: Prune STABS obsoletion message.
> ---
>  gcc/ada/gcc-interface/misc.c |  6 ------
>  gcc/config/pa/som.h          |  4 ++++
>  gcc/config/pdp11/pdp11.h     |  3 +++
>  gcc/defaults.h               | 29 +++++------------------------
>  gcc/testsuite/lib/prune.exp  |  3 +++
>  gcc/toplev.c                 |  5 +++++
>  6 files changed, 20 insertions(+), 30 deletions(-)
>
> diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
> index 96199bd4b63..87a4c8662cb 100644
> --- a/gcc/ada/gcc-interface/misc.c
> +++ b/gcc/ada/gcc-interface/misc.c
> @@ -274,12 +274,6 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
>    if (!global_options_set.x_flag_diagnostics_show_caret)
>      global_dc->show_caret = false;
>
> -  /* Warn only if STABS is not the default: we don't want to emit a warning if
> -     the user did not use a -gstabs option.  */
> -  if (PREFERRED_DEBUGGING_TYPE != DBX_DEBUG && write_symbols == DBX_DEBUG)
> -    warning (0, "STABS debugging information for Ada is obsolete and not "
> -               "supported anymore");
> -
>    /* Copy global settings to local versions.  */
>    gnat_encodings = global_options.x_gnat_encodings;
>    optimize = global_options.x_optimize;
> diff --git a/gcc/config/pa/som.h b/gcc/config/pa/som.h
> index 05cc315b9f9..36a1122b132 100644
> --- a/gcc/config/pa/som.h
> +++ b/gcc/config/pa/som.h
> @@ -21,6 +21,10 @@ along with GCC; see the file COPYING3.  If not see
>  #undef TARGET_SOM
>  #define TARGET_SOM 1
>
> +/* With SOM we can only do STABS.  */
> +#undef PREFERRED_DEBUGGING_TYPE
> +#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
> +
>  /* We do not use BINCL stabs in SOM.
>     ??? If it does not hurt, we probably should to avoid useless divergence
>     from other embedded stabs implementations.  */
> diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h
> index 9bc5e089f49..91a8ce70751 100644
> --- a/gcc/config/pdp11/pdp11.h
> +++ b/gcc/config/pdp11/pdp11.h
> @@ -54,6 +54,9 @@ along with GCC; see the file COPYING3.  If not see
>
>  #define DBX_DEBUGGING_INFO
>
> +#undef PREFERRED_DEBUGGING_TYPE
> +#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
> +
>  #define TARGET_40_PLUS         (TARGET_40 || TARGET_45)
>  #define TARGET_10              (! TARGET_40_PLUS)
>
> diff --git a/gcc/defaults.h b/gcc/defaults.h
> index ba79a8e48ed..d7f2546f2cc 100644
> --- a/gcc/defaults.h
> +++ b/gcc/defaults.h
> @@ -900,33 +900,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>  #define DEFAULT_GDB_EXTENSIONS 1
>  #endif
>
> -/* If more than one debugging type is supported, you must define
> -   PREFERRED_DEBUGGING_TYPE to choose the default.  */
> -
> -#if 1 < (defined (DBX_DEBUGGING_INFO) \
> -         + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO) \
> -         + defined (VMS_DEBUGGING_INFO))
> +/* Default to DWARF2_DEBUGGING_INFO.  Legacy targets can choose different
> +   by defining PREFERRED_DEBUGGING_TYPE.  */
>  #ifndef PREFERRED_DEBUGGING_TYPE
> -#error You must define PREFERRED_DEBUGGING_TYPE
> -#endif /* no PREFERRED_DEBUGGING_TYPE */
> -
> -/* If only one debugging format is supported, define PREFERRED_DEBUGGING_TYPE
> -   here so other code needn't care.  */
> -#elif defined DBX_DEBUGGING_INFO
> -#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
> -
> -#elif defined DWARF2_DEBUGGING_INFO || defined DWARF2_LINENO_DEBUGGING_INFO
> +#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_LINENO_DEBUGGING_INFO
>  #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
> -
> -#elif defined VMS_DEBUGGING_INFO
> -#define PREFERRED_DEBUGGING_TYPE VMS_AND_DWARF2_DEBUG
> -
> -#elif defined XCOFF_DEBUGGING_INFO
> -#define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
> -
>  #else
> -/* No debugging format is supported by this target.  */
> -#define PREFERRED_DEBUGGING_TYPE NO_DEBUG
> +#error You must define PREFERRED_DEBUGGING_TYPE if DWARF is not supported
> +#endif
>  #endif
>
>  #ifndef FLOAT_LIB_COMPARE_RETURNS_BOOL
> diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
> index fac212ecf60..131424861d5 100644
> --- a/gcc/testsuite/lib/prune.exp
> +++ b/gcc/testsuite/lib/prune.exp
> @@ -93,6 +93,9 @@ proc prune_gcc_output { text } {
>      # Ignore dsymutil warning (tool bug is actually linker)
>      regsub -all "(^|\n)\[^\n\]*could not find object file symbol for symbol\[^\n\]*" $text "" text
>
> +    # Ignore stabs obsoletion warnings
> +    regsub -all "(^|\n)\[^\n\]*\[Ww\]arning: STABS debugging information is obsolete and not supported anymore\[^\n\]*" $text "" text
> +
>      # If dg-enable-nn-line-numbers was provided, then obscure source-margin
>      # line numbers by converting them to "NN" form.
>      set text [maybe-handle-nn-line-numbers $text]
> diff --git a/gcc/toplev.c b/gcc/toplev.c
> index 14d1335e79e..8de8a92f2c6 100644
> --- a/gcc/toplev.c
> +++ b/gcc/toplev.c
> @@ -1452,6 +1452,11 @@ process_options (void)
>        && ctf_debug_info_level == CTFINFO_LEVEL_NONE)
>      write_symbols = NO_DEBUG;
>
> +  /* Warn if STABS debug gets enabled and is not the default.  */
> +  if (PREFERRED_DEBUGGING_TYPE != DBX_DEBUG && (write_symbols & DBX_DEBUG))
> +    warning (0, "STABS debugging information is obsolete and not "
> +            "supported anymore");
> +
>    if (write_symbols == NO_DEBUG)
>      ;
>  #if defined(DBX_DEBUGGING_INFO)
> --
> 2.31.1
  
Li, Pan2 via Gcc-patches Sept. 28, 2021, 1:18 p.m. UTC | #2
> On Sep 28, 2021, at 2:14 AM, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 
> On Tue, Sep 21, 2021 at 4:26 PM Richard Biener via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>> 
>> This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE
>> is not specified by the target and errors out if DWARF DWARF is not supported.
>> 
>> ...
>> 
>> This completes the series of deprecating STABS for GCC 12.
>> 
>> Bootstrapped and tested on x86_64-unknown-linux-gnu.
>> 
>> OK for trunk?
> 
> Ping.

pdp11 is fine.

	paul
  
Richard Biener Oct. 15, 2021, 8:23 a.m. UTC | #3
On Tue, 28 Sep 2021, Koning, Paul wrote:

> 
> 
> > On Sep 28, 2021, at 2:14 AM, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > 
> > On Tue, Sep 21, 2021 at 4:26 PM Richard Biener via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> >> 
> >> This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE
> >> is not specified by the target and errors out if DWARF DWARF is not supported.
> >> 
> >> ...
> >> 
> >> This completes the series of deprecating STABS for GCC 12.
> >> 
> >> Bootstrapped and tested on x86_64-unknown-linux-gnu.
> >> 
> >> OK for trunk?
> > 
> > Ping.
> 
> pdp11 is fine.

I have now pushed this and the related changes.html update.

Richard.
  
Jan-Benedict Glaw Oct. 23, 2021, 8 p.m. UTC | #4
Hi Richard,

On Tue, 2021-09-21 16:25:19 +0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> I have built all targets from contrib/config-list.mk to make sure we
> don't run into the #error and the following makes the STABS usage
> explicit for pdp11 and hppa with SOM.

I'm running build tests based on config-list.mk as well and see a good
number of targets failing, all about the same, ie. for moxie-elf:

[all 2021-10-17 00:01:19] /usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c  -DIN_GCC_FRONTEND -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o default-d.o -MT default-d.o -MMD -MP -MF ./.deps/default-d.TPo ../../gcc/gcc/config/default-d.c
[all 2021-10-17 00:01:19] In file included from ./tm_d.h:9,
[all 2021-10-17 00:01:19]                  from ../../gcc/gcc/config/default-d.c:22:
[all 2021-10-17 00:01:19] ../../gcc/gcc/defaults.h:908:2: error: #error You must define PREFERRED_DEBUGGING_TYPE if DWARF is not supported
[all 2021-10-17 00:01:19]   908 | #error You must define PREFERRED_DEBUGGING_TYPE if DWARF is not supported
[all 2021-10-17 00:01:19]       |  ^~~~~
[all 2021-10-17 00:01:20] make[1]: *** [Makefile:2330: default-d.o] Error 1
[all 2021-10-17 00:01:21] make[1]: Leaving directory '/var/lib/laminar/run/gcc-moxie-elf/13/toolchain-build/gcc'
[all 2021-10-17 00:01:21] make: *** [Makefile:4423: all-gcc] Error 2

Shall I try to ping all the maintainers?

MfG, JBG

--
  
Jeff Law Oct. 23, 2021, 10:19 p.m. UTC | #5
On 10/23/2021 2:00 PM, Jan-Benedict Glaw wrote:
> Hi Richard,
>
> On Tue, 2021-09-21 16:25:19 +0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>> I have built all targets from contrib/config-list.mk to make sure we
>> don't run into the #error and the following makes the STABS usage
>> explicit for pdp11 and hppa with SOM.
> I'm running build tests based on config-list.mk as well and see a good
> number of targets failing, all about the same, ie. for moxie-elf:
That's odd.  My moxie-elf (and all the others I test) aren't seeing this.

http://gcc.gnu.org/jenkins

Jeff
  
Richard Biener Oct. 24, 2021, 6:36 a.m. UTC | #6
On October 23, 2021 10:00:05 PM GMT+02:00, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
>Hi Richard,
>
>On Tue, 2021-09-21 16:25:19 +0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>> I have built all targets from contrib/config-list.mk to make sure we
>> don't run into the #error and the following makes the STABS usage
>> explicit for pdp11 and hppa with SOM.
>
>I'm running build tests based on config-list.mk as well and see a good
>number of targets failing, all about the same, ie. for moxie-elf:

That's odd. I did test the patch using config-list.mk - the patch sat in the comit tree for quite a while since that exercise (but unchanged), but I doubt anything significant changed in between. 

>[all 2021-10-17 00:01:19] /usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c  -DIN_GCC_FRONTEND -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o default-d.o -MT default-d.o -MMD -MP -MF ./.deps/default-d.TPo ../../gcc/gcc/config/default-d.c
>[all 2021-10-17 00:01:19] In file included from ./tm_d.h:9,
>[all 2021-10-17 00:01:19]                  from ../../gcc/gcc/config/default-d.c:22:
>[all 2021-10-17 00:01:19] ../../gcc/gcc/defaults.h:908:2: error: #error You must define PREFERRED_DEBUGGING_TYPE if DWARF is not supported

Is that building the D frontend? I remember restricting the builds to C... 

I will check what's up with this next week. 

>[all 2021-10-17 00:01:19]   908 | #error You must define PREFERRED_DEBUGGING_TYPE if DWARF is not supported
>[all 2021-10-17 00:01:19]       |  ^~~~~
>[all 2021-10-17 00:01:20] make[1]: *** [Makefile:2330: default-d.o] Error 1
>[all 2021-10-17 00:01:21] make[1]: Leaving directory '/var/lib/laminar/run/gcc-moxie-elf/13/toolchain-build/gcc'
>[all 2021-10-17 00:01:21] make: *** [Makefile:4423: all-gcc] Error 2
>
>Shall I try to ping all the maintainers?
>
>MfG, JBG
>
  
Jan-Benedict Glaw Oct. 24, 2021, 7:20 a.m. UTC | #7
Hi Richard,

On Sun, 2021-10-24 08:36:36 +0200, Richard Biener <rguenther@suse.de> wrote:
> On October 23, 2021 10:00:05 PM GMT+02:00, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> >On Tue, 2021-09-21 16:25:19 +0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> >> I have built all targets from contrib/config-list.mk to make sure we
> >> don't run into the #error and the following makes the STABS usage
> >> explicit for pdp11 and hppa with SOM.
> >
> >I'm running build tests based on config-list.mk as well and see a good
> >number of targets failing, all about the same, ie. for moxie-elf:
> 
> That's odd. I did test the patch using config-list.mk - the patch
> sat in the comit tree for quite a while since that exercise (but
> unchanged), but I doubt anything significant changed in between. 
> 
> >[all 2021-10-17 00:01:19] /usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c  -DIN_GCC_FRONTEND -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o default-d.o -MT default-d.o -MMD -MP -MF ./.deps/default-d.TPo ../../gcc/gcc/config/default-d.c
> >[all 2021-10-17 00:01:19] In file included from ./tm_d.h:9,
> >[all 2021-10-17 00:01:19]                  from ../../gcc/gcc/config/default-d.c:22:
> >[all 2021-10-17 00:01:19] ../../gcc/gcc/defaults.h:908:2: error: #error You must define PREFERRED_DEBUGGING_TYPE if DWARF is not supported
> 
> Is that building the D frontend? I remember restricting the builds to C... 

Probably. I configure as

.../gcc/configure --target=moxie-elf --enable-werror-always
--enable-languages=all --disable-gcov --disable-shared
--disable-threads --without-headers
--prefix=/var/lib/laminar/run/gcc-moxie-elf/13/toolchain-install

MfG, JBG

--
  
Richard Biener Oct. 25, 2021, 8:25 a.m. UTC | #8
On Sun, 24 Oct 2021, Jan-Benedict Glaw wrote:

> Hi Richard,
> 
> On Sun, 2021-10-24 08:36:36 +0200, Richard Biener <rguenther@suse.de> wrote:
> > On October 23, 2021 10:00:05 PM GMT+02:00, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> > >On Tue, 2021-09-21 16:25:19 +0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > >> I have built all targets from contrib/config-list.mk to make sure we
> > >> don't run into the #error and the following makes the STABS usage
> > >> explicit for pdp11 and hppa with SOM.
> > >
> > >I'm running build tests based on config-list.mk as well and see a good
> > >number of targets failing, all about the same, ie. for moxie-elf:
> > 
> > That's odd. I did test the patch using config-list.mk - the patch
> > sat in the comit tree for quite a while since that exercise (but
> > unchanged), but I doubt anything significant changed in between. 
> > 
> > >[all 2021-10-17 00:01:19] /usr/lib/gcc-snapshot/bin/g++ -fno-PIE -c 
> > >-DIN_GCC_FRONTEND -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE 
> > >-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall 
> > >-Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag 
> > >-Wmissing-format-attribute -Woverloaded-virtual -pedantic 
> > >-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror 
> > >-fno-common -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. 
> > >-I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include 
> > >-I../../gcc/gcc/../libcody -I../../gcc/gcc/../libdecnumber 
> > >-I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber 
> > >-I../../gcc/gcc/../libbacktrace -o default-d.o -MT default-d.o -MMD 
> > >-MP -MF ./.deps/default-d.TPo ../../gcc/gcc/config/default-d.c [all 
> > >2021-10-17 00:01:19] In file included from ./tm_d.h:9, [all 
> > >2021-10-17 00:01:19] from ../../gcc/gcc/config/default-d.c:22: [all 
> > >2021-10-17 00:01:19] ../../gcc/gcc/defaults.h:908:2: error: #error 
> > >You must define PREFERRED_DEBUGGING_TYPE if DWARF is not supported
> > 
> > Is that building the D frontend? I remember restricting the builds to C... 
> 
> Probably. I configure as
> 
> .../gcc/configure --target=moxie-elf --enable-werror-always
> --enable-languages=all --disable-gcov --disable-shared
> --disable-threads --without-headers
> --prefix=/var/lib/laminar/run/gcc-moxie-elf/13/toolchain-install

So it looks like tm_d.h is much more stripped down compared to regular
tm_p.h but also oddly enough config/default-d.c includes tm_d.h
while config/default-c.c explicitely documents itself to not do that.

In particular tm_d.h includes defaults.h which now has the requirement
that either PREFERRED_DEBUGGING_TYPE is defined or DWARF2_DEBUGGING_INFO
but the latter is usually picked up from config/elfos.h or similar
which are headers _not_ included via tm_d.h.

The old defaults.h resulted in NO_DEBUG if no PREFERRED_DEBUGGING_TYPE
and no DWARF2_DEBUGGING_INFO was defined.

I also note that default-d.o is not built on x86_64-linux?  Looks
like that's built only for

if [ "$target_has_targetdm" = "no" ]; then
  d_target_objs="$d_target_objs default-d.o"
fi

I note that for example config/glibc-d.c includes tm.h and tm_p.h
which would end up in proper definitions.

So ... for moxie-elf, did D really end up with NO_DEBUG previously?
Is that "correct" for D or was that a bug?  moxie-elf seems to use
default-c.c as well but that does not end including defaults.h.

Is it maybe a bug that tm_d.h includes defaults.h at all?  Should
"d defaults" be in a defaults-d.h instead?  If I remove the
defaults.h include from tm_d.h the build for moxie-elf succeeds.

Ian?  Joseph?

Thanks,
Richard.
  
Joseph Myers Oct. 26, 2021, 1:28 a.m. UTC | #9
On Mon, 25 Oct 2021, Richard Biener via Gcc-patches wrote:

> So it looks like tm_d.h is much more stripped down compared to regular
> tm_p.h but also oddly enough config/default-d.c includes tm_d.h
> while config/default-c.c explicitely documents itself to not do that.

I think the intent of that comment in default-c.c (which I wrote) was that 
if a separate tm_c.h is needed, it should use its own headers, disjoint 
from those used by tm.h.  In particular, as noted in the original patch 
submission 
<https://gcc.gnu.org/legacy-ml/gcc-patches/2011-04/msg00434.html>, that 
avoids making macros used only to define hooks visible throughout the 
compiler.

> Is it maybe a bug that tm_d.h includes defaults.h at all?  Should

It's a bug that it includes defaults.h, and a bug that it includes 
${cpu_type}/${cpu_type}.h.  Any macros used only to define D hooks should 
be in completely separate headers that aren't used elsewhere in the 
compiler.

> "d defaults" be in a defaults-d.h instead?  If I remove the

Yes, and likewise any target-specific overrides of such macros should be 
in a separate header, not ${cpu_type}/${cpu_type}.h.
  
Li, Pan2 via Gcc-patches Oct. 29, 2021, 2:48 p.m. UTC | #10
> On 26/10/2021 03:28 Joseph Myers <joseph@codesourcery.com> wrote:
> 
>  
> On Mon, 25 Oct 2021, Richard Biener via Gcc-patches wrote:
> 
> > So it looks like tm_d.h is much more stripped down compared to regular
> > tm_p.h but also oddly enough config/default-d.c includes tm_d.h
> > while config/default-c.c explicitely documents itself to not do that.
> 
> I think the intent of that comment in default-c.c (which I wrote) was that 
> if a separate tm_c.h is needed, it should use its own headers, disjoint 
> from those used by tm.h.  In particular, as noted in the original patch 
> submission 
> <https://gcc.gnu.org/legacy-ml/gcc-patches/2011-04/msg00434.html>, that 
> avoids making macros used only to define hooks visible throughout the 
> compiler.
> 
> > Is it maybe a bug that tm_d.h includes defaults.h at all?  Should
> 
> It's a bug that it includes defaults.h, and a bug that it includes 
> ${cpu_type}/${cpu_type}.h.  Any macros used only to define D hooks should 
> be in completely separate headers that aren't used elsewhere in the 
> compiler.
> 
> > "d defaults" be in a defaults-d.h instead?  If I remove the
> 
> Yes, and likewise any target-specific overrides of such macros should be 
> in a separate header, not ${cpu_type}/${cpu_type}.h.
> 

So the what default-d.c is doing, is pulling down per-CPU back-end information to populate the targetdm structure where there's a supported CPU, but not platform.  The why it is doing that was I wanted to avoid both having #ifdef's in the D front-end, and altering gcc/target.def.

It seems then that either all TARGET_D_ macros should be moved to ${cpu_type}/${cpu_type}-d.h, or do one of alternatives I was trying to avoid.

Iain.
  
Jan-Benedict Glaw Aug. 28, 2022, 7:50 a.m. UTC | #11
On Tue, 2021-09-21 16:25:19 +0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE
> is not specified by the target and errors out if DWARF DWARF is not supported.

While I think the pdp11 bits arreved, the rest did not (yet). Just
checked my auto-builder logs. When building current HEAD as

	../gcc/configure --prefix=... --enable-werror-always \
		--enable-languages=all --disable-gcov \
		--disable-shared --disable-threads --without-headers \
		--target=...
	make V=1 all-gcc

ALL of these targets won't build right now:
	aarch64-elf
	aarch64-rtems
	alpha64-dec-vms
	alpha-dec-vms
	arm-eabi
	arm-rtems
	arm-symbianelf
	arm-uclinux_eabi
	bfin-elf
	bfin-rtems
	bfin-uclinux
	c6x-elf
	c6x-uclinux
	cris-elf
	fido-elf
	fr30-elf
	ft32-elf
	i686-elf
	i686-lynxos
	i686-nto-qnx
	i686-pc-msdosdjgpp
	i686-rtems
	i686-wrs-vxworks
	i686-wrs-vxworksae
	lm32-elf
	lm32-rtems
	lm32-uclinux
	m32c-elf
	m68k-elf
	m68k-rtems
	m68k-uclinux
	moxie-elf
	moxie-rtems
	moxie-uclinux
	powerpc-eabi
	powerpc-eabialtivec
	powerpc-eabisim
	powerpc-eabisimaltivec
	powerpc-ibm-aix7.1
	powerpc-ibm-aix7.2
	powerpcle-eabi
	powerpcle-eabisim
	powerpcle-elf
	powerpc-lynxos
	powerpc-rtems
	powerpc-wrs-vxworks
	powerpc-wrs-vxworksmils
	powerpc-xilinx-eabi
	ppc-elf
	s390x-ibm-tpf
	sh-elf
	sh-rtems
	sh-superh-elf
	sh-wrs-vxworks
	sparc64-elf
	sparc64-rtems
	sparc-elf
	sparc-leon-elf
	sparc-rtems
	sparc-wrs-vxworks
	visium-elf
	x86_64-elf --with-fpmath=sse
	x86_64-rtems
	xtensa-elf

So I'd like to reignite the discussion about a DWARF2 fallback. :)

Thanks,
  Jan-Benedict

--
  
Jeff Law Aug. 28, 2022, 9:32 p.m. UTC | #12
On 8/28/2022 1:50 AM, Jan-Benedict Glaw wrote:
> On Tue, 2021-09-21 16:25:19 +0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>> This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE
>> is not specified by the target and errors out if DWARF DWARF is not supported.
> While I think the pdp11 bits arreved, the rest did not (yet). Just
> checked my auto-builder logs. When building current HEAD as
>
> 	../gcc/configure --prefix=... --enable-werror-always \
> 		--enable-languages=all --disable-gcov \
> 		--disable-shared --disable-threads --without-headers \
> 		--target=...
> 	make V=1 all-gcc
>
> ALL of these targets won't build right now:
> 	aarch64-elf
> 	aarch64-rtems
> 	alpha64-dec-vms
> 	alpha-dec-vms
> 	arm-eabi
> 	arm-rtems
> 	arm-symbianelf
> 	arm-uclinux_eabi
> 	bfin-elf
> 	bfin-rtems
> 	bfin-uclinux
> 	c6x-elf
> 	c6x-uclinux
> 	cris-elf
> 	fido-elf
> 	fr30-elf
> 	ft32-elf
> 	i686-elf
> 	i686-lynxos
> 	i686-nto-qnx
> 	i686-pc-msdosdjgpp
> 	i686-rtems
> 	i686-wrs-vxworks
> 	i686-wrs-vxworksae
> 	lm32-elf
> 	lm32-rtems
> 	lm32-uclinux
> 	m32c-elf
> 	m68k-elf
> 	m68k-rtems
> 	m68k-uclinux
> 	moxie-elf
> 	moxie-rtems
> 	moxie-uclinux
> 	powerpc-eabi
> 	powerpc-eabialtivec
> 	powerpc-eabisim
> 	powerpc-eabisimaltivec
> 	powerpc-ibm-aix7.1
> 	powerpc-ibm-aix7.2
> 	powerpcle-eabi
> 	powerpcle-eabisim
> 	powerpcle-elf
> 	powerpc-lynxos
> 	powerpc-rtems
> 	powerpc-wrs-vxworks
> 	powerpc-wrs-vxworksmils
> 	powerpc-xilinx-eabi
> 	ppc-elf
> 	s390x-ibm-tpf
> 	sh-elf
> 	sh-rtems
> 	sh-superh-elf
> 	sh-wrs-vxworks
> 	sparc64-elf
> 	sparc64-rtems
> 	sparc-elf
> 	sparc-leon-elf
> 	sparc-rtems
> 	sparc-wrs-vxworks
> 	visium-elf
> 	x86_64-elf --with-fpmath=sse
> 	x86_64-rtems
> 	xtensa-elf
Umm, most of those -elf targets do build.  See:

http://law-sandy.freeddns.org:8080


Jeff
  
Jan-Benedict Glaw Aug. 29, 2022, 8:11 p.m. UTC | #13
Hi Jeff!

On Sun, 2022-08-28 15:32:53 -0600, Jeff Law via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> On 8/28/2022 1:50 AM, Jan-Benedict Glaw wrote:
> > On Tue, 2021-09-21 16:25:19 +0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > > This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE
> > > is not specified by the target and errors out if DWARF DWARF is not supported.
> > While I think the pdp11 bits arreved, the rest did not (yet). Just
> > checked my auto-builder logs. When building current HEAD as
> > 
> > 	../gcc/configure --prefix=... --enable-werror-always \
> > 		--enable-languages=all --disable-gcov \
> > 		--disable-shared --disable-threads --without-headers \
> > 		--target=...
> > 	make V=1 all-gcc
> > 
> > ALL of these targets won't build right now:
[...]
> Umm, most of those -elf targets do build.  See:
> 
> http://law-sandy.freeddns.org:8080

Another builder. :)  Randomly picking xtensa-elf, you're configuring
as

+ ../../gcc/configure --disable-analyzer --with-system-libunwind
--with-newlib --without-headers --disable-threads --disable-shared
--enable-languages=c,c++
--prefix=/home/jlaw/jenkins/workspace/xtensa-elf/xtensa-elf-obj/gcc/../../xtensa-elf-installed
--target=xtensa-elf

I guess the main difference that lets my builds fail might be
--enable-languages=all (vs. c,c++ in your case.)

Maybe you'd give that a try? (...and I'll trigger a build with just
c,c++ on my builder.)

MfG, JBG

--
  
Jeff Law Aug. 31, 2022, 4:05 p.m. UTC | #14
On 8/29/2022 2:11 PM, Jan-Benedict Glaw wrote:
> Hi Jeff!
>
> On Sun, 2022-08-28 15:32:53 -0600, Jeff Law via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>> On 8/28/2022 1:50 AM, Jan-Benedict Glaw wrote:
>>> On Tue, 2021-09-21 16:25:19 +0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>>>> This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE
>>>> is not specified by the target and errors out if DWARF DWARF is not supported.
>>> While I think the pdp11 bits arreved, the rest did not (yet). Just
>>> checked my auto-builder logs. When building current HEAD as
>>>
>>> 	../gcc/configure --prefix=... --enable-werror-always \
>>> 		--enable-languages=all --disable-gcov \
>>> 		--disable-shared --disable-threads --without-headers \
>>> 		--target=...
>>> 	make V=1 all-gcc
>>>
>>> ALL of these targets won't build right now:
> [...]
>> Umm, most of those -elf targets do build.  See:
>>
>> http://law-sandy.freeddns.org:8080
> Another builder. :)  Randomly picking xtensa-elf, you're configuring
> as
>
> + ../../gcc/configure --disable-analyzer --with-system-libunwind
> --with-newlib --without-headers --disable-threads --disable-shared
> --enable-languages=c,c++
> --prefix=/home/jlaw/jenkins/workspace/xtensa-elf/xtensa-elf-obj/gcc/../../xtensa-elf-installed
> --target=xtensa-elf
>
> I guess the main difference that lets my builds fail might be
> --enable-languages=all (vs. c,c++ in your case.)
>
> Maybe you'd give that a try? (...and I'll trigger a build with just
> c,c++ on my builder.)
I can, particularly now that the tester builds everything in a docker 
container -- it really didn't like having Ada tests (for example) 
appearing and disappearing based on whether or not the host had an Ada 
compiler installed.  I've also brought the computing resources in-house 
(literally, in my house), so I'm not worried about running out of Amazon 
credits anymore.

Jeff
  
Jan-Benedict Glaw Sept. 7, 2022, 10:50 a.m. UTC | #15
Hi!

On Mon, 2022-08-29 22:11:35 +0200, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> On Sun, 2022-08-28 15:32:53 -0600, Jeff Law via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > On 8/28/2022 1:50 AM, Jan-Benedict Glaw wrote:
> > > On Tue, 2021-09-21 16:25:19 +0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > > > This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE
> > > > is not specified by the target and errors out if DWARF DWARF is not supported.
> > > While I think the pdp11 bits arreved, the rest did not (yet). Just
> > > checked my auto-builder logs. When building current HEAD as
> > > 
> > > 	../gcc/configure --prefix=... --enable-werror-always \
> > > 		--enable-languages=all --disable-gcov \
> > > 		--disable-shared --disable-threads --without-headers \
> > > 		--target=...
> > > 	make V=1 all-gcc
> > > 
> > > ALL of these targets won't build right now:
> [...]
> > Umm, most of those -elf targets do build.  See:
> > 
> > http://law-sandy.freeddns.org:8080
> 
> Another builder. :)  Randomly picking xtensa-elf, you're configuring
> as
> 
> + ../../gcc/configure --disable-analyzer --with-system-libunwind
> --with-newlib --without-headers --disable-threads --disable-shared
> --enable-languages=c,c++
> --prefix=/home/jlaw/jenkins/workspace/xtensa-elf/xtensa-elf-obj/gcc/../../xtensa-elf-installed
> --target=xtensa-elf
> 
> I guess the main difference that lets my builds fail might be
> --enable-languages=all (vs. c,c++ in your case.)
> 
> Maybe you'd give that a try? (...and I'll trigger a build with just
> c,c++ on my builder.)

So ... just building for --enable-languages=c,c++ usually works for
the *-elf targets, but I'm interested in building as much code as
possible. Is it expected that with --enable-languages=all, all those
targets will break? Can we have a sane default here, or need the
maintainers decide for any given debug format?

Thanks,
  Jan-Benedict

--
  
Richard Biener Sept. 7, 2022, 11:57 a.m. UTC | #16
On Wed, Sep 7, 2022 at 12:51 PM Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
>
> Hi!
>
> On Mon, 2022-08-29 22:11:35 +0200, Jan-Benedict Glaw <jbglaw@lug-owl.de> wrote:
> > On Sun, 2022-08-28 15:32:53 -0600, Jeff Law via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > > On 8/28/2022 1:50 AM, Jan-Benedict Glaw wrote:
> > > > On Tue, 2021-09-21 16:25:19 +0200, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > > > > This makes defaults.h choose DWARF2_DEBUG if PREFERRED_DEBUGGING_TYPE
> > > > > is not specified by the target and errors out if DWARF DWARF is not supported.
> > > > While I think the pdp11 bits arreved, the rest did not (yet). Just
> > > > checked my auto-builder logs. When building current HEAD as
> > > >
> > > >   ../gcc/configure --prefix=... --enable-werror-always \
> > > >           --enable-languages=all --disable-gcov \
> > > >           --disable-shared --disable-threads --without-headers \
> > > >           --target=...
> > > >   make V=1 all-gcc
> > > >
> > > > ALL of these targets won't build right now:
> > [...]
> > > Umm, most of those -elf targets do build.  See:
> > >
> > > http://law-sandy.freeddns.org:8080
> >
> > Another builder. :)  Randomly picking xtensa-elf, you're configuring
> > as
> >
> > + ../../gcc/configure --disable-analyzer --with-system-libunwind
> > --with-newlib --without-headers --disable-threads --disable-shared
> > --enable-languages=c,c++
> > --prefix=/home/jlaw/jenkins/workspace/xtensa-elf/xtensa-elf-obj/gcc/../../xtensa-elf-installed
> > --target=xtensa-elf
> >
> > I guess the main difference that lets my builds fail might be
> > --enable-languages=all (vs. c,c++ in your case.)
> >
> > Maybe you'd give that a try? (...and I'll trigger a build with just
> > c,c++ on my builder.)
>
> So ... just building for --enable-languages=c,c++ usually works for
> the *-elf targets, but I'm interested in building as much code as
> possible. Is it expected that with --enable-languages=all, all those
> targets will break? Can we have a sane default here, or need the
> maintainers decide for any given debug format?

It's not expected that they break - when targets do not decide on a default
format and they can handle DWARF that is automatically selected.  And
that shouldn't change whether you enable some language or not.

Richard.

>
> Thanks,
>   Jan-Benedict
>
> --
  

Patch

diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index 96199bd4b63..87a4c8662cb 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -274,12 +274,6 @@  gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
   if (!global_options_set.x_flag_diagnostics_show_caret)
     global_dc->show_caret = false;
 
-  /* Warn only if STABS is not the default: we don't want to emit a warning if
-     the user did not use a -gstabs option.  */
-  if (PREFERRED_DEBUGGING_TYPE != DBX_DEBUG && write_symbols == DBX_DEBUG)
-    warning (0, "STABS debugging information for Ada is obsolete and not "
-		"supported anymore");
-
   /* Copy global settings to local versions.  */
   gnat_encodings = global_options.x_gnat_encodings;
   optimize = global_options.x_optimize;
diff --git a/gcc/config/pa/som.h b/gcc/config/pa/som.h
index 05cc315b9f9..36a1122b132 100644
--- a/gcc/config/pa/som.h
+++ b/gcc/config/pa/som.h
@@ -21,6 +21,10 @@  along with GCC; see the file COPYING3.  If not see
 #undef TARGET_SOM
 #define TARGET_SOM 1
 
+/* With SOM we can only do STABS.  */
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
+
 /* We do not use BINCL stabs in SOM.
    ??? If it does not hurt, we probably should to avoid useless divergence
    from other embedded stabs implementations.  */
diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h
index 9bc5e089f49..91a8ce70751 100644
--- a/gcc/config/pdp11/pdp11.h
+++ b/gcc/config/pdp11/pdp11.h
@@ -54,6 +54,9 @@  along with GCC; see the file COPYING3.  If not see
 
 #define DBX_DEBUGGING_INFO
 
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
+
 #define TARGET_40_PLUS		(TARGET_40 || TARGET_45)
 #define TARGET_10		(! TARGET_40_PLUS)
 
diff --git a/gcc/defaults.h b/gcc/defaults.h
index ba79a8e48ed..d7f2546f2cc 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -900,33 +900,14 @@  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define DEFAULT_GDB_EXTENSIONS 1
 #endif
 
-/* If more than one debugging type is supported, you must define
-   PREFERRED_DEBUGGING_TYPE to choose the default.  */
-
-#if 1 < (defined (DBX_DEBUGGING_INFO) \
-         + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO) \
-         + defined (VMS_DEBUGGING_INFO))
+/* Default to DWARF2_DEBUGGING_INFO.  Legacy targets can choose different
+   by defining PREFERRED_DEBUGGING_TYPE.  */
 #ifndef PREFERRED_DEBUGGING_TYPE
-#error You must define PREFERRED_DEBUGGING_TYPE
-#endif /* no PREFERRED_DEBUGGING_TYPE */
-
-/* If only one debugging format is supported, define PREFERRED_DEBUGGING_TYPE
-   here so other code needn't care.  */
-#elif defined DBX_DEBUGGING_INFO
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
-#elif defined DWARF2_DEBUGGING_INFO || defined DWARF2_LINENO_DEBUGGING_INFO
+#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_LINENO_DEBUGGING_INFO
 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
-
-#elif defined VMS_DEBUGGING_INFO
-#define PREFERRED_DEBUGGING_TYPE VMS_AND_DWARF2_DEBUG
-
-#elif defined XCOFF_DEBUGGING_INFO
-#define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
-
 #else
-/* No debugging format is supported by this target.  */
-#define PREFERRED_DEBUGGING_TYPE NO_DEBUG
+#error You must define PREFERRED_DEBUGGING_TYPE if DWARF is not supported
+#endif
 #endif
 
 #ifndef FLOAT_LIB_COMPARE_RETURNS_BOOL
diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
index fac212ecf60..131424861d5 100644
--- a/gcc/testsuite/lib/prune.exp
+++ b/gcc/testsuite/lib/prune.exp
@@ -93,6 +93,9 @@  proc prune_gcc_output { text } {
     # Ignore dsymutil warning (tool bug is actually linker)
     regsub -all "(^|\n)\[^\n\]*could not find object file symbol for symbol\[^\n\]*" $text "" text
 
+    # Ignore stabs obsoletion warnings
+    regsub -all "(^|\n)\[^\n\]*\[Ww\]arning: STABS debugging information is obsolete and not supported anymore\[^\n\]*" $text "" text
+
     # If dg-enable-nn-line-numbers was provided, then obscure source-margin
     # line numbers by converting them to "NN" form.
     set text [maybe-handle-nn-line-numbers $text]
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 14d1335e79e..8de8a92f2c6 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1452,6 +1452,11 @@  process_options (void)
       && ctf_debug_info_level == CTFINFO_LEVEL_NONE)
     write_symbols = NO_DEBUG;
 
+  /* Warn if STABS debug gets enabled and is not the default.  */
+  if (PREFERRED_DEBUGGING_TYPE != DBX_DEBUG && (write_symbols & DBX_DEBUG))
+    warning (0, "STABS debugging information is obsolete and not "
+	     "supported anymore");
+
   if (write_symbols == NO_DEBUG)
     ;
 #if defined(DBX_DEBUGGING_INFO)