]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Darwin: Do not emit .macinfo when dsymutil cannot consume it.
authorIain Sandoe <iain@sandoe.co.uk>
Sun, 31 Mar 2024 22:25:31 +0000 (23:25 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Mon, 29 Apr 2024 07:04:48 +0000 (08:04 +0100)
Some verions of dsymutil do not ignore .macinfo sections, but instead
ignore the entire debug in the file.

To avoid this total loss of debug, when we detect that the debug level
is g3 and the dsymutil version cannot support it, we reduce the level
to g2 and issue a note.

This behaviour can be overidden by -gstrict-dwarf (although the objects
will contain macinfo; dsymutil will not produce a .dSYM with it).

gcc/ChangeLog:

* config/darwin.c (darwin_override_options): Reduce the debug
level to 2 if dsymutil cannot handle .macinfo sections.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 3c499f8f6f7d19b21d7047efabbe6396ee1c2cac)

gcc/config/darwin.c

index a473ea79b1b3d75ead616bc2f150d5078b587e25..465e8075dfd2fdbe6ff343d6b640a87fcfc5c137 100644 (file)
@@ -3374,11 +3374,6 @@ darwin_override_options (void)
                  global_options.x_flag_objc_abi);
     }
 
-  /* Limit DWARF to the chosen version, the linker and debug linker might not
-     be able to consume newer structures.  */
-  if (!global_options_set.x_dwarf_strict)
-    dwarf_strict = 1;
-
   if (!global_options_set.x_dwarf_version)
     {
       /* External toolchains based on LLVM or clang 7+ have support for
@@ -3401,6 +3396,24 @@ darwin_override_options (void)
       global_options_set.x_dwarf_split_debug_info = 0;
     }
 
+  /* Cases where dsymutil will exclude files with .macinfo sections; we are
+     better off forcing the debug level to 2 than completely excluding the
+     files.  If strict dwarf is set, then emit the macinfo anyway.  */
+  if (debug_info_level == DINFO_LEVEL_VERBOSE
+      && (!global_options_set.x_dwarf_strict || dwarf_strict == 0)
+      && ((dsymutil_version.kind == CLANG && dsymutil_version.major >= 1500)
+         || (dsymutil_version.kind == LLVM && dsymutil_version.major >= 15)))
+    {
+      inform (input_location,
+             "%<-g3%> is not supported by the debug linker in use (set to 2)");
+      debug_info_level = DINFO_LEVEL_NORMAL;
+    }
+
+  /* Limit DWARF to the chosen version, the linker and debug linker might not
+     be able to consume newer structures.  */
+  if (!global_options_set.x_dwarf_strict)
+    dwarf_strict = 1;
+
   /* Do not allow unwind tables to be generated by default for m32.
      fnon-call-exceptions will override this, regardless of what we do.  */
   if (generating_for_darwin_version < 10