diff mbox series

Disable -gsplit-dwarf for all LTO debug

Message ID alpine.LSU.2.20.1804121328300.18265@zhemvz.fhfr.qr
State New
Headers show
Series Disable -gsplit-dwarf for all LTO debug | expand

Commit Message

Richard Biener April 12, 2018, 11:35 a.m. UTC
The following disables split-dwarf for the LTO part of the early debug
(keeping it for the fat part) and makes sure the driver doesn't
see -gsplit-dwarf in effect.

That works for all but the compile stage and slim objects
(the default) which then ends up generating an empty .dwo file.
I'm not sure where to prune for this case given that 
-fno-fat-lto-objects seems to be just ignored if it isn't supported.

Note that we need the dwarf2out.c part as otherwise the late
references cannot be resolved since the debug is copied from .o to .dwo
files early.

Opinions?

Thanks,
Richard.

2018-04-12  Richard Biener  <rguenther@suse.de>

	* lto-wrapper.c (run_gcc): Add -gno-split-dwarf to cancel
	any such option from compile or link time in a way visible
	to the driver.
	* dwarf2out.c (add_top_level_skeleton_die_attrs): Avoid adding
	DW_AT_GNU_pubnames twice.
	(dwarf2out_early_finish): Unconditionally call add_AT_pubnames.
	Disable dwarf_split_debug_info around the early LTO DWARF emission
	and remove then dead code.

Comments

Jakub Jelinek April 12, 2018, 11:38 a.m. UTC | #1
On Thu, Apr 12, 2018 at 01:35:46PM +0200, Richard Biener wrote:
> 
> The following disables split-dwarf for the LTO part of the early debug
> (keeping it for the fat part) and makes sure the driver doesn't
> see -gsplit-dwarf in effect.
> 
> That works for all but the compile stage and slim objects
> (the default) which then ends up generating an empty .dwo file.
> I'm not sure where to prune for this case given that 
> -fno-fat-lto-objects seems to be just ignored if it isn't supported.
> 
> Note that we need the dwarf2out.c part as otherwise the late
> references cannot be resolved since the debug is copied from .o to .dwo
> files early.

Wouldn't it be better to just sorry on the -flto -gsplit-dwarf combination?
It really isn't clear what the user is asking for in that case and what
exactly he wants.

	Jakub
Richard Biener April 12, 2018, 12:06 p.m. UTC | #2
On Thu, 12 Apr 2018, Jakub Jelinek wrote:

> On Thu, Apr 12, 2018 at 01:35:46PM +0200, Richard Biener wrote:
> > 
> > The following disables split-dwarf for the LTO part of the early debug
> > (keeping it for the fat part) and makes sure the driver doesn't
> > see -gsplit-dwarf in effect.
> > 
> > That works for all but the compile stage and slim objects
> > (the default) which then ends up generating an empty .dwo file.
> > I'm not sure where to prune for this case given that 
> > -fno-fat-lto-objects seems to be just ignored if it isn't supported.
> > 
> > Note that we need the dwarf2out.c part as otherwise the late
> > references cannot be resolved since the debug is copied from .o to .dwo
> > files early.
> 
> Wouldn't it be better to just sorry on the -flto -gsplit-dwarf combination?
> It really isn't clear what the user is asking for in that case and what
> exactly he wants.

Certainly easier though then not necessary at this point (nor is this
patch of course).

It might be reasonable to keep -gsplit-dwarf working for the fat part
of the object -- OTOH I think that support for fat LTO objects should
be removed at some point as well...

Richard.
diff mbox series

Patch

Index: gcc/lto-wrapper.c
===================================================================
--- gcc/lto-wrapper.c	(revision 259337)
+++ gcc/lto-wrapper.c	(working copy)
@@ -1123,6 +1123,7 @@  run_gcc (unsigned argc, char *argv[])
   append_compiler_options (&argv_obstack, fdecoded_options,
 			   fdecoded_options_count);
   append_linker_options (&argv_obstack, decoded_options, decoded_options_count);
+  obstack_ptr_grow (&argv_obstack, "-gno-split-dwarf");
 
   /* Scan linker driver arguments for things that are of relevance to us.  */
   for (j = 1; j < decoded_options_count; ++j)
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 259337)
+++ gcc/dwarf2out.c	(working copy)
@@ -11105,7 +11105,8 @@  add_top_level_skeleton_die_attrs (dw_die
   add_skeleton_AT_string (die, dwarf_AT (DW_AT_dwo_name), dwo_file_name);
   if (comp_dir != NULL)
     add_skeleton_AT_string (die, DW_AT_comp_dir, comp_dir);
-  add_AT_pubnames (die);
+  if (!get_AT (die, DW_AT_GNU_pubnames))
+    add_AT_pubnames (die);
   add_AT_lineptr (die, DW_AT_GNU_addr_base, debug_addr_section_label);
 }
 
@@ -31811,11 +31812,8 @@  dwarf2out_early_finish (const char *file
     note_variable_value (node->die);
 
   /* The AT_pubnames attribute needs to go in all skeleton dies, including
-     both the main_cu and all skeleton TUs.  Making this call unconditional
-     would end up either adding a second copy of the AT_pubnames attribute, or
-     requiring a special case in add_top_level_skeleton_die_attrs.  */
-  if (!dwarf_split_debug_info)
-    add_AT_pubnames (comp_unit_die ());
+     both the main_cu and all skeleton TUs.  */
+  add_AT_pubnames (comp_unit_die ());
 
   /* The early debug phase is now finished.  */
   early_dwarf_finished = true;
@@ -31824,6 +31822,11 @@  dwarf2out_early_finish (const char *file
   if (!flag_generate_lto && !flag_generate_offload)
     return;
 
+  /* For the early LTO DWARF we do not want split DWARF because it really
+     doesn't make much sense.  */
+  int saved_dwarf_split_debug_info = dwarf_split_debug_info;
+  dwarf_split_debug_info = 0;
+
   /* Now as we are going to output for LTO initialize sections and labels
      to the LTO variants.  We don't need a random-seed postfix as other
      LTO sections as linking the LTO debug sections into one in a partial
@@ -31858,12 +31861,6 @@  dwarf2out_early_finish (const char *file
 
   save_macinfo_strings ();
 
-  if (dwarf_split_debug_info)
-    {
-      unsigned int index = 0;
-      debug_str_hash->traverse_noresize<unsigned int *, index_string> (&index);
-    }
-
   /* Output all of the compilation units.  We put the main one last so that
      the offsets are available to output_pubnames.  */
   for (limbo_die_node *node = limbo_die_list; node; node = node->next)
@@ -31884,9 +31881,7 @@  dwarf2out_early_finish (const char *file
          attributes.  */
       if (debug_info_level >= DINFO_LEVEL_TERSE)
         add_AT_lineptr (ctnode->root_die, DW_AT_stmt_list,
-                        (!dwarf_split_debug_info
-                         ? debug_line_section_label
-                         : debug_skeleton_line_section_label));
+                        debug_line_section_label);
 
       output_comdat_type_unit (ctnode);
       *slot = ctnode;
@@ -31939,6 +31934,8 @@  dwarf2out_early_finish (const char *file
 
   /* Switch back to the text section.  */
   switch_to_section (text_section);
+
+  dwarf_split_debug_info = saved_dwarf_split_debug_info;
 }
 
 /* Reset all state within dwarf2out.c so that we can rerun the compiler