Backported from https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b2cee5e1e89c8f939bc36fe9756befcb93d96982 diff -ur a/gcc/config/darwin.h b/gcc/config/darwin.h --- a/gcc/config/darwin.h 2021-05-14 04:42:08.000000000 -0400 +++ b/gcc/config/darwin.h 2023-11-06 08:53:27.629155053 -0500 @@ -233,12 +233,18 @@ #define DSYMUTIL "\ndsymutil" +/* Spec that controls whether the debug linker is run automatically for + a link step. This needs to be done if there is a source file on the + command line which will result in a temporary object (and debug is + enabled). */ + #define DSYMUTIL_SPEC \ "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ %{v} \ - %{gdwarf-2:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\ - %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm: \ - %{gdwarf-2:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}}}}}}}}}" + %{g*:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\ + %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.f|.f90|\ + .f95|.f03|.f77|.for|.F|.F90|.F95|.F03: \ + %{g*:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}}}}}}}}}" #define LINK_COMMAND_SPEC LINK_COMMAND_SPEC_A DSYMUTIL_SPEC @@ -469,18 +475,31 @@ /* Default ASM_DEBUG_SPEC. Darwin's as cannot currently produce dwarf debugging data. */ +#ifdef HAS_AS_STABS_DIRECTIVE +/* We only pass a debug option to the assembler if that supports stabs, since + dwarf is not uniformly supported in the assemblers. */ #define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{!gdwarf*:--gstabs}}}" +#else +#define ASM_DEBUG_SPEC "" +#endif + +#undef ASM_DEBUG_OPTION_SPEC +#define ASM_DEBUG_OPTION_SPEC "" + #define ASM_FINAL_SPEC \ "%{gsplit-dwarf:%ngsplit-dwarf is not supported on this platform } %. */ -/* Prefer DWARF2. */ -#undef PREFERRED_DEBUGGING_TYPE -#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG -#define DARWIN_PREFER_DWARF - -/* Since DWARF2 is default, conditions for running dsymutil are different. */ -#undef DSYMUTIL_SPEC -#define DSYMUTIL_SPEC \ - "%{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ - %{v} \ - %{g*:%{!gstabs*:%{%:debug-level-gt(0): -idsym}}}\ - %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm|.s|.f|.f90|.f95|.f03|.f77|.for|.F|.F90|.F95|.F03: \ - %{g*:%{!gstabs*:%{%:debug-level-gt(0): -dsym}}}}}}}}}}}" - -/* Tell collect2 to run dsymutil for us as necessary. */ -#define COLLECT_RUN_DSYMUTIL 1 - -/* Only ask as for debug data if the debug style is stabs (since as doesn't - yet generate dwarf.) */ - -#undef ASM_DEBUG_SPEC -#define ASM_DEBUG_SPEC "%{g*:%{%:debug-level-gt(0):%{gstabs:--gstabs}}}" - #undef ASM_OUTPUT_ALIGNED_COMMON #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ do { \