This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[PATCH]: fix for PR target/14650


Here's my attempt to fix PR target/14650.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14650

Basically, the problem is that the native irix6 assembler is lame and
is missing certain features.  These problems only manifest under
certain ABIs that irix has.

We want the testsuite to test these features when using GAS, but
bypass when native.  There currently doesn't appear to be any way to
detect GAS in testcases, so I decided to add one.


The first issue I looked at is whether we care about detecting GAS in
the general case, or just when it makes a difference.  It doesn't seem
to be useful to figure out that we'd be using gas on a linux-gnu box.
However on a couple of platforms, notably irix and hpux, GAS
apparently makes a big feature difference.

So I decided to check TARGET_GAS.  This macro is only defined at all
by a couple of backends.  This macro will be 0 or 1 depending on
whether gas is in use.  In fact it appears to be a runtime switch, so
you can turn gas assembly output on and off without reconfiguring.

Second, I had to pick a name for the macro that appears in user code.
I picked __SWITCH_GAS__ because TARGET_GAS sounds like it should
appear for all GAS targets.  It's only when gas is "switchable" that
it seemed this should be set (either to 0 or 1.)

Tested against 3.4 on mips-sgi-irix6.5, it cures testsuite noise from:
g++.dg/parse/attr-ctor1.C for o32,
gcc.c-torture/compile/20031023-1.c, 20031023-2.c & 20031023-3.c for n64 
and gcc.dg/compat/sdata-1 for o32.

I also bootstrapped against 3.5 on sparc-sun-solaris2.7 and there were
no regressions.

Ok for mainline?
Ok to queue for 3.4.1?

		Thanks,
		--Kaveh

PS: Oh yes, I'll document the macro in cpp.texi in a followup if the
approach is approved and we settle on a macro name.



2004-03-23  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	PR target/14650
	* c-cppbuiltin.c (c_cpp_builtins): Define __SWITCH_GAS__.

testsuite:
	* g++.dg/parse/attr-ctor1.C: Check for the Irix o32 ABI and the
	native assembler.
	* gcc.c-torture/compile/20031023-1.c: Check for the Irix n64 ABI
	and the native assembler.
	* gcc.dg/compat/sdata-section.h: Check for the Irix o32 ABI and
	the native assembler.

diff -rup orig/egcc-CVS20040319/gcc/c-cppbuiltin.c egcc-CVS20040319/gcc/c-cppbuiltin.c
--- orig/egcc-CVS20040319/gcc/c-cppbuiltin.c	Thu Mar  4 20:01:15 2004
+++ egcc-CVS20040319/gcc/c-cppbuiltin.c	Sat Mar 20 10:32:32 2004
@@ -408,6 +408,14 @@ c_cpp_builtins (cpp_reader *pfile)
   if (c_dialect_objc () && flag_next_runtime)
     cpp_define (pfile, "__NEXT_RUNTIME__");
 
+  /* We define this if the use of GAS is switchable at runtime.  */
+#ifdef TARGET_GAS
+  if (TARGET_GAS)
+    cpp_define (pfile, "__SWITCH_GAS__=1");
+  else
+    cpp_define (pfile, "__SWITCH_GAS__=0");
+#endif
+
   /* A straightforward target hook doesn't work, because of problems
      linking that hook's body when part of non-C front ends.  */
 # define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM)
diff -rup orig/egcc-CVS20040319/gcc/testsuite/g++.dg/parse/attr-ctor1.C egcc-CVS20040319/gcc/testsuite/g++.dg/parse/attr-ctor1.C
--- orig/egcc-CVS20040319/gcc/testsuite/g++.dg/parse/attr-ctor1.C	Thu Feb 19 20:02:08 2004
+++ egcc-CVS20040319/gcc/testsuite/g++.dg/parse/attr-ctor1.C	Sat Mar 20 11:06:52 2004
@@ -4,6 +4,12 @@
 
 // Requires section attribute support
 
+#if defined _ABIO32 && _MIPS_SIM == _ABIO32 && !__SWITCH_GAS__
+/* The native assembler for the mips-irix6 o32 ABI doesn't support
+   named sections.  */
+#define __attribute__(x)
+#endif
+
 class A
 {
     __attribute__((section("whatever"))) A(); // { dg-bogus "" "" { xfail hppa*-*-hpux* } }
diff -rup orig/egcc-CVS20040319/gcc/testsuite/gcc.c-torture/compile/20031023-1.c egcc-CVS20040319/gcc/testsuite/gcc.c-torture/compile/20031023-1.c
--- orig/egcc-CVS20040319/gcc/testsuite/gcc.c-torture/compile/20031023-1.c	Mon Oct 27 05:52:48 2003
+++ egcc-CVS20040319/gcc/testsuite/gcc.c-torture/compile/20031023-1.c	Sat Mar 20 11:00:56 2004
@@ -4,7 +4,9 @@
 
 #include <limits.h>
 
-#if LONG_MAX < 8 * ASIZE
+#if LONG_MAX < 8 * ASIZE \
+  || (defined _ABI64 && _MIPS_SIM == _ABI64 && !__SWITCH_GAS__)
+/* The native assembler for mips-irix6 n64 ABI doesn't support >4G frames.  */
 # undef ASIZE
 # define ASIZE 4096
 #endif
diff -rup orig/egcc-CVS20040319/gcc/testsuite/gcc.dg/compat/sdata-section.h egcc-CVS20040319/gcc/testsuite/gcc.dg/compat/sdata-section.h
--- orig/egcc-CVS20040319/gcc/testsuite/gcc.dg/compat/sdata-section.h	Mon Jan  5 20:01:08 2004
+++ egcc-CVS20040319/gcc/testsuite/gcc.dg/compat/sdata-section.h	Sat Mar 20 11:04:17 2004
@@ -1,4 +1,7 @@
-#ifdef __mips
+/* The native assembler for the mips-irix6 o32 ABI doesn't support
+   named sections.  */
+#if defined __mips && \
+  (__SWITCH_GAS__ || !(defined _ABIO32 && _MIPS_SIM == _ABIO32))
 #define SDATA_SECTION __attribute__((__section__(".sdata")))
 #else
 #define SDATA_SECTION


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