Patchwork [revised] PR debug/53453 ensure debug notes linked on darwin

login
register
mail settings
Submitter Jack Howarth
Date May 25, 2012, 1:17 p.m.
Message ID <20120525131720.GA20797@bromo.med.uc.edu>
Download mbox | patch
Permalink /patch/161343/
State New
Headers show

Comments

Jack Howarth - May 25, 2012, 1:17 p.m.
The attached patch solves PR53453. The upcoming dsymutil release will now issue
a warning when no debug notes are emitted for an object file on linkage. This causes
several thousand failures in the FSF gcc testsuite. The origin of this problem is
that the darwin linker requires the presence of both AT_name and AT_comp_dir attributes
for each object file otherwise their debug notes will be omitted on linkage. The 
patch adds a new TARGET_FORCE_AT_COMP_DIR target hook for darwin so that AT_comp_dir 
will be present for all object files. Bootstrap and regression tested on x86_64-apple-darwin12.

http://gcc.gnu.org/ml/gcc-testresults/2012-05/msg02331.html

Okay for gcc trunk and later gcc-4_7-branch and gcc-4_6-branch?
                  Jack
ps Note that this is a pre-existing problem on darwin and that the newer dsymutil simply
has alerted us to the issue.
pps Added correction of s/AT_comp_dir/DW_AT_comp_dir/g to gcc/target.def change.

2012-05-24  Jack Howarth  <howarth@bromo.med.uc.edu>

	PR debug/53453
	* doc/tm.texi: Update.
	* doc/tm.texi.in (SDB and DWARF) <TARGET_FORCE_AT_COMP_DIR>: Add @hook.
	* target-def (force_at_comp_dir): New hook.
	* config/darwin.h (TARGET_FORCE_AT_COMP_DIR): Define.
	* dwarf2out.c (dwarf2out_finish): Check targetm.force_at_comp_dir.
Jason Merrill - May 25, 2012, 7:36 p.m.
OK.

Jason

Patch

Index: gcc/doc/tm.texi.in
===================================================================
--- gcc/doc/tm.texi.in	(revision 187856)
+++ gcc/doc/tm.texi.in	(working copy)
@@ -9392,6 +9392,8 @@  tables, and hence is desirable if it wor
 
 @hook TARGET_WANT_DEBUG_PUB_SECTIONS
 
+@hook TARGET_FORCE_AT_COMP_DIR
+
 @hook TARGET_DELAY_SCHED2
 
 @hook TARGET_DELAY_VARTRACK
Index: gcc/target.def
===================================================================
--- gcc/target.def	(revision 187856)
+++ gcc/target.def	(working copy)
@@ -2749,6 +2749,13 @@  DEFHOOKPOD
  bool, false)
 
 DEFHOOKPOD
+(force_at_comp_dir,
+ "True if the @code{DW_AT_comp_dir} attribute should be emitted for each \
+ compilation unit.  This attribute is required for the darwin linker \
+ to emit debug information.",
+ bool, false)
+
+DEFHOOKPOD
 (delay_sched2, "True if sched2 is not to be run at its normal place.  \
 This usually means it will be run as part of machine-specific reorg.",
 bool, false)
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 187856)
+++ gcc/dwarf2out.c	(working copy)
@@ -21949,7 +21949,7 @@  dwarf2out_finish (const char *filename)
   /* Add the name for the main input file now.  We delayed this from
      dwarf2out_init to avoid complications with PCH.  */
   add_name_attribute (comp_unit_die (), remap_debug_filename (filename));
-  if (!IS_ABSOLUTE_PATH (filename))
+  if (!IS_ABSOLUTE_PATH (filename) || targetm.force_at_comp_dir)
     add_comp_dir_attribute (comp_unit_die ());
   else if (get_AT (comp_unit_die (), DW_AT_comp_dir) == NULL)
     {
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h	(revision 187856)
+++ gcc/config/darwin.h	(working copy)
@@ -414,6 +414,8 @@  extern GTY(()) int darwin_ms_struct;
 
 #define TARGET_WANT_DEBUG_PUB_SECTIONS true
 
+#define TARGET_FORCE_AT_COMP_DIR true
+
 /* When generating stabs debugging, use N_BINCL entries.  */
 
 #define DBX_USE_BINCL