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]

[IRIX 6.2] Support #pragma weak and --enable-threads=posix


I've just finished support for #pragma weak and the --enable-threads=posix
switch on IRIX 6.2.

This needs only two changes:

* iris6.h missed to copy the definition of HANDLE_SYSV_PRAGMA from svr4.h,
  although support is possible and the native (MIPSpro 7.2) cc does.

* Whereas varasm.c (assemble_alias) used ASM_OUTPUT_WEAK_ALIAS if
  ASM_OUTPUT_DEF is unavailable (as on IRIX 6), weak_finish() didn't.
  This change needs to be reflected into the definition of
  HANDLE_PRAGMA_WEAK in c-pragma.h.

With these changes, I have been able to bootstrap egcs-2.93.01 19990112
with --enable-threads=posix without unexpected regressions, i.e. only the
objc tests fail to link since the pthread_* functions are undefined.
Testresults with and without pthreads enabled are on their way to
egcs-testresults.

One issue confused me, though: while

	extern int weak;
	#pragma weak weak = _weak
and
	extern int weak __attribute__((weak, alias ("_weak")));

give identical assembly output:

	.section	.text
	.globl	weak
	.weakext	weak _weak

the other pair differs:

	extern int weak;
	#pragma weak weak

gives a weak declaration of `weak':

	.section	.text
	.globl	weak
	.weakext	weak

whereas
	extern int weak __attribute__((weak));

doesn't emit any declaration of `weak' at all:

	.option pic2
	.section	.text

This happens with egcs 1.1.1 on Solaris 2.5.1 as well.  I'd have expected
that #pragma weak and __attribute__((weak)) were equivalent.  Answering a
similar question, Mike Stump claims this is intentional, without any
explanation:

	http://www.cygnus.com/ml/egcs-bugs/1999-Jan/0091.html

What's going on here?

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Technical Faculty, University of Bielefeld

Internet: ro@TechFak.Uni-Bielefeld.DE


Wed Oct  7 22:28:38 1998  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* gcc/varasm.c (weak_finish): Use ASM_OUTPUT_WEAK_ALIAS if
	ASM_OUTPUT_DEF is missing.
	* gcc/c-pragma.h (HANDLE_PRAGMA_WEAK): Likewise.

	* gcc/config/mips/iris6.h (HANDLE_SYSV_PRAGMA): Define.

Index: gcc/c-pragma.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-pragma.h,v
retrieving revision 1.6
diff -u -p -r1.6 c-pragma.h
--- c-pragma.h	1998/12/16 20:53:55	1.6
+++ c-pragma.h	1999/01/14 13:59:34
@@ -22,9 +22,9 @@ Boston, MA 02111-1307, USA.  */
 #define _C_PRAGMA_H
 
 #ifdef HANDLE_SYSV_PRAGMA
-/* Support #pragma weak iff ASM_WEAKEN_LABEL and ASM_OUTPUT_DEF are
-   defined.  */
-#if defined (ASM_WEAKEN_LABEL) && defined (ASM_OUTPUT_DEF)
+/* Support #pragma weak iff ASM_WEAKEN_LABEL and ASM_OUTPUT_DEF
+   or ASM_OUTPUT_WEAK_ALIAS are defined.  */
+#if defined (ASM_WEAKEN_LABEL) && (defined (ASM_OUTPUT_DEF) || defined(ASM_OUTPUT_WEAK_ALIAS))
 #define HANDLE_PRAGMA_WEAK SUPPORTS_WEAK
 #endif
 
Index: gcc/varasm.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/varasm.c,v
retrieving revision 1.46
diff -u -p -r1.46 varasm.c
--- varasm.c	1998/12/16 20:58:44	1.46
+++ varasm.c	1999/01/14 13:59:51
@@ -4270,9 +4270,16 @@ weak_finish ()
       struct weak_syms *t;
       for (t = weak_decls; t; t = t->next)
 	{
+#ifdef ASM_OUTPUT_DEF
 	  ASM_WEAKEN_LABEL (asm_out_file, t->name);
 	  if (t->value)
 	    ASM_OUTPUT_DEF (asm_out_file, t->name, t->value);
+#else
+	  if (t->value)
+	    ASM_OUTPUT_WEAK_ALIAS (asm_out_file, t->name, t->value);
+	  else
+	    ASM_WEAKEN_LABEL (asm_out_file, t->name);
+#endif
 	}
     }
 #endif
Index: gcc/config/mips/iris6.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/mips/iris6.h,v
retrieving revision 1.14
diff -u -p -r1.14 iris6.h
--- iris6.h	1998/12/16 21:09:10	1.14
+++ iris6.h	1999/01/16 00:25:20
@@ -94,6 +94,10 @@ Boston, MA 02111-1307, USA.  */
 %{mabi=64: -D__mips64} \
 %{!mabi*: -D__mips64}"
 
+/* Handle #pragma weak and #pragma pack.  */
+
+#define HANDLE_SYSV_PRAGMA
+
 /* Irix 6 uses DWARF-2.  */
 #define DWARF2_DEBUGGING_INFO
 #define MIPS_DEBUGGING_INFO


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