This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

3.3 PATCH: Handle mips gas 2.13 -mdebug switch


As discussed in the thread starting at

	http://sources.redhat.com/ml/binutils/2002-06/msg00605.html

the introduction of the new -mdebug switch in gas 2.12.9x introduced a
considerable number of gcc testsuite failures.  I observed the same when
using gas 2.12.90 configured for mips-sgi-irix5.3 for my new
mips-sgi-irix6*o32 configuration.  The problem is that the assembler
requires the new -mdebug switch to correctly assemble input files with
stabs-in-mdebug or ecoff-in-mdebug debugging information.

The following patch fixes a large part of the problem:

* It detects if the assembler used supports the -mdebug switch at all.

* If so, it defines a new mdebug_asm_spec to handle the core of the
  problem:

** If the default debugging format is DWARF-2, only gcc invokations with
   -gstabs* or -gcoff* need to pass -mdebug on to gas.

** If the default debugging format is Stabs or ECOFF, -mdebug must be
   always passed unless -gdwarf-2* is specified.

  The problem is that the test for PREFERRED_DEBUGGING_TYPE cannot be
  performed at compile time for the same reasons leading to

	http://gcc.gnu.org/ml/gcc-patches/2002-07/msg00208.html

  Therefore, I needed a way to initialize parts of EXTRA_SPECS at compile
  time.  The new EXTRA_SPECS_INIT implemented and documented below does
  this.

This patch doesn't correctly handle ASM_DEBUG_SPEC yet.  It gets the
necessary -mdebug flag indirectly via ASM_SPEC, but the default
ASM_DEBUG_SPEC is wrong on systems that have ECOFF_DEBUGGING defined as
well:

With DWARF-2 the default, gcc -gcoff -c asm.s invokes gas with --gdwarf2
(which is clearly wrong) and -mdebug (correct).

With Stabs the default, --gstabs isn't passed without any -g switch (which
may be correct, I don't know for sure), but again -gcoff causes gas to be
invoked with --gstabs -mdebug.

This will have to wait for a follow-up patch, though.  One problem is that
a correct default for a mips ASM_DEBUG_SPEC cannot be defined in mips.h
since many target headers later redefine PREFERRED_DEBUGGING_TYPE.  This
either needs to go to gcc.c as well, or we need a new common header (to be
included after all the target headers) to correctly define ASM_DEBUG_SPEC
at this point.

Bootstrapped on mips-sgi-irix6.2o32 with gas 2.12.90 both with and without
--without-stabs (i.e. with either DWARF2_DEBUG or DBX_DEBUG), gas 2.12.1
and native as (which don't have -mdebug).

Ok for mainline?

	Rainer


Wed Jul 17 20:41:46 2002  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* config/mips/mips.h (MDEBUG_ASM_SPEC): Define.
	(ASM_SPEC): Use it.
	(EXTRA_SPECS): Add mdebug_asm_spec.
	(EXTRA_SPECS_INIT): Define.

	* gcc.c (struct spec_list_1): Remove const from ptr.
	(extra_specs_1): Remove const.
	(init_spec): Use EXTRA_SPECS_INIT if defined.
	* doc/tm.texi (EXTRA_SPECS, EXTRA_SPECS_INIT): Document.
	
	* configure.in: Test for gas -mdebug flag.
	* configure: Regenerate.
	* config.in: Likewise.
	
Index: gcc/gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.327
diff -u -p -r1.327 gcc.c
--- gcc/gcc.c	5 Jul 2002 12:33:52 -0000	1.327
+++ gcc/gcc.c	19 Jul 2002 17:03:43 -0000
@@ -1410,10 +1410,10 @@ static struct spec_list static_specs[] =
 struct spec_list_1
 {
   const char *const name;
-  const char *const ptr;
+  const char *ptr;
 };
 
-static const struct spec_list_1 extra_specs_1[] = { EXTRA_SPECS };
+static struct spec_list_1 extra_specs_1[] = { EXTRA_SPECS };
 static struct spec_list *extra_specs = (struct spec_list *) 0;
 #endif
 
@@ -1466,6 +1466,12 @@ init_spec ()
 
   if (verbose_flag)
     notice ("Using built-in specs.\n");
+
+#ifdef EXTRA_SPECS_INIT
+  for (i = ARRAY_SIZE (extra_specs_1) - 1; i >= 0; i--)
+    if (extra_specs_1[i].ptr == NULL)
+      EXTRA_SPECS_INIT (extra_specs_1[i].name, extra_specs_1[i].ptr);
+#endif
 
 #ifdef EXTRA_SPECS
   extra_specs = (struct spec_list *)
Index: gcc/config/mips/mips.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.h,v
retrieving revision 1.199
diff -u -p -r1.199 mips.h
--- gcc/config/mips/mips.h	17 Jul 2002 09:24:08 -0000	1.199
+++ gcc/config/mips/mips.h	19 Jul 2002 17:03:47 -0000
@@ -969,6 +969,17 @@ extern int mips_abi;
 #define SUBTARGET_ASM_SPEC ""
 #endif
 
+/* Beginning with gas 2.13, -mdebug must be passed to correctly handle COFF
+   and stabs debugging info.  */
+#ifdef HAVE_AS_MDEBUG_DEBUG_FLAG
+#define MDEBUG_ASM_SPEC					\
+	(PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG)	\
+	 ? "%{gcoff*|gstabs*:-mdebug}"			\
+	 : "%{!gdwarf-2*:-mdebug}")
+#else
+#define MDEBUG_ASM_SPEC ""
+#endif
+
 /* ASM_SPEC is the set of arguments to pass to the assembler.  */
 
 #undef ASM_SPEC
@@ -977,6 +988,7 @@ extern int mips_abi;
 %{mips16:%{!mno-mips16:-mips16}} %{mno-mips16:-no-mips16} \
 %(subtarget_asm_optimizing_spec) \
 %(subtarget_asm_debugging_spec) \
+%(mdebug_asm_spec) \
 %{membedded-pic} \
 %{mabi=32:-32}%{mabi=o32:-32}%{mabi=n32:-n32}%{mabi=64:-64}%{mabi=n64:-64} \
 %(target_asm_spec) \
@@ -1093,10 +1105,19 @@ extern int mips_abi;
   { "subtarget_mips_as_asm_spec", SUBTARGET_MIPS_AS_ASM_SPEC }, 	\
   { "subtarget_asm_optimizing_spec", SUBTARGET_ASM_OPTIMIZING_SPEC },	\
   { "subtarget_asm_debugging_spec", SUBTARGET_ASM_DEBUGGING_SPEC },	\
+  { "mdebug_asm_spec", NULL },						\
   { "subtarget_asm_spec", SUBTARGET_ASM_SPEC },				\
   { "endian_spec", ENDIAN_SPEC },					\
   SUBTARGET_EXTRA_SPECS
 
+/* mdebug_asm_spec needs to be initialized at run-time.  */
+
+#define EXTRA_SPECS_INIT(NAME, PTR)					\
+do {									\
+  if (strcmp (NAME, "mdebug_asm_spec") == 0)				\
+    PTR = MDEBUG_ASM_SPEC;						\
+} while (0);
+
 #ifndef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS
 #endif
Index: gcc/doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.145
diff -u -p -r1.145 tm.texi
--- gcc/doc/tm.texi	16 Jul 2002 02:16:45 -0000	1.145
+++ gcc/doc/tm.texi	19 Jul 2002 17:03:58 -0000
@@ -278,7 +278,10 @@ Define this macro to provide additional 
 
 The definition should be an initializer for an array of structures,
 containing a string constant, that defines the specification name, and a
-string constant that provides the specification.
+string constant that provides the specification.  If the specification
+needs to be initialized at run-time, use a @code{NULL} specification in
+@code{EXTRA_SPECS} to signal this and perform the real initialization in
+@code{EXTRA_SPECS_INIT} below.
 
 Do not define this macro if it does not need to do anything.
 
@@ -321,6 +324,14 @@ while the @file{config/rs6000/eabiaix.h}
 #undef CPP_SYSV_DEFAULT
 #define CPP_SYSV_DEFAULT "-D_CALL_AIX"
 @end smallexample
+
+@findex EXTRA_SPECS_INIT
+@item EXTRA_SPECS_INIT (@var{name}, @var{ptr})
+If any specification in @code{EXTRA_SPECS} needs to be initialized at
+run-time, @code{EXTRA_SPECS_INIT} is invoked for each @code{NULL}
+element in @code{EXTRA_SPECS} with @code{@var{name}} set to the
+specification name to initialize and should assign the proper
+specification to @code{@var{ptr}}.
 
 @findex LINK_LIBGCC_SPECIAL
 @item LINK_LIBGCC_SPECIAL


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]