Patchwork [Revisedx2] Fix PR libitm/55693

login
register
mail settings
Submitter Jack Howarth
Date Feb. 8, 2013, 6:50 p.m.
Message ID <20130208185008.GA21292@bromo.med.uc.edu>
Download mbox | patch
Permalink /patch/219246/
State New
Headers show

Comments

Jack Howarth - Feb. 8, 2013, 6:50 p.m.
The attached patch eliminates, PR55693, the failure of the libitm.c++/eh-1.C execution test on
darwin10 and later. With the introduction of c++ weak-symbol coalescing in Mac OS X 10.6, dyld no
longer looks up weak symbols that reside in object files rather than shared libraries. This prevents
the weak symbols for the dummy functions in libgcc/config/darwin-crt-tm.c from being replaced
by those in the libstdc++ shared library. It appears that these dummy functions are not actually
required. Thus the hack for adding dummy symbols to libgcc/config/darwin-crt-tm.c is reverted.
Also, the previous hack of not declaring the dummy symbols in libitm/alloc_cpp.cc and libitm/eh_cpp.cc
on darwin is reverted as this produces undefined symbols for the combination of darwin10 with Xcode 4.2
(where HAVE_ELF_STYLE_WEAKREF is undefined). Bootstrap and regression tested on powerpc-apple-darwin9 
with Xcode 3.1.4, x86_64-apple-darwin10 with Xcode 4.2 as well as for x86_64-apple-darwin12 with
Xcode 4.6.
            Okay for gcc trunk after testing on intel darwin9?
                                Jack
/libgcc

2013-02-08  Iain Sandoe  <iain@codesourcery.com>
	    Jack Howarth  <howarth@bromo.med.uc.edu>
	    Patrick Marlier  <patrick.marlier@gmail.com>

	PR libitm/55693
	* config/darwin-crt-tm.c: Remove dummy functions hack.

/gcc

2013-02-08  Iain Sandoe  <iain@codesourcery.com>
	    Jack Howarth  <howarth@bromo.med.uc.edu>
	    Patrick Marlier  <patrick.marlier@gmail.com>

	PR libitm/55693
	* gcc/config/darwin.h: Replace ENDFILE_SPEC with TM_DESTRUCTOR and
	define ENDFILE_SPEC as TM_DESTRUCTOR.
	* config/i386/darwin.h (ENDFILE_SPEC): Use TM_DESTRUCTOR.

/libitm

2013-02-08  Iain Sandoe  <iain@codesourcery.com>
	    Jack Howarth  <howarth@bromo.med.uc.edu>
	    Patrick Marlier  <patrick.marlier@gmail.com>

	PR libitm/55693
	* alloc_cpp.cc:  Enable function declarations on darwin.
	* eh_cpp.cc:  Likewise.

Patch

Index: libitm/alloc_cpp.cc
===================================================================
--- libitm/alloc_cpp.cc	(revision 195885)
+++ libitm/alloc_cpp.cc	(working copy)
@@ -60,7 +60,7 @@  extern void _ZdlPvRKSt9nothrow_t (void *
 extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
 extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
 
-#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined (__MACH__)
+#if !defined (HAVE_ELF_STYLE_WEAKREF) 
 void *_ZnwX (size_t) { return NULL; }
 void _ZdlPv (void *) { return; }
 void *_ZnaX (size_t) { return NULL; }
Index: libitm/eh_cpp.cc
===================================================================
--- libitm/eh_cpp.cc	(revision 195885)
+++ libitm/eh_cpp.cc	(working copy)
@@ -39,7 +39,7 @@  extern void *__cxa_begin_catch (void *) 
 extern void __cxa_end_catch (void) WEAK;
 extern void __cxa_tm_cleanup (void *, void *, unsigned int) WEAK;
 
-#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined (__MACH__)
+#if !defined (HAVE_ELF_STYLE_WEAKREF) 
 void *__cxa_allocate_exception (size_t) { return NULL; }
 void __cxa_throw (void *, void *, void *) { return; }
 void *__cxa_begin_catch (void *) { return NULL; }
Index: libgcc/config/darwin-crt-tm.c
===================================================================
--- libgcc/config/darwin-crt-tm.c	(revision 195885)
+++ libgcc/config/darwin-crt-tm.c	(working copy)
@@ -39,7 +39,6 @@  see the files COPYING3 and COPYING.RUNTI
 #endif
 
 #define WEAK __attribute__((weak))
-#define UNUSED __attribute__((unused))
 
 extern void _ITM_registerTMCloneTable (void *, size_t) WEAK;
 extern void _ITM_deregisterTMCloneTable (void *) WEAK;
@@ -103,46 +102,4 @@  void __doTMdeRegistrations (void)
     _ITM_deregisterTMCloneTable (tmct);
 }
 
-/* Provide dummy functions to satisfy linkage for versions of the Darwin 
-   tool-chain that that can't handle undefined weak refs at the link stage.
-   ??? Define these dummy functions only when !HAVE_ELF_STYLE_WEAKREF. */
-
-extern void *__cxa_allocate_exception (size_t) WEAK;
-extern void __cxa_throw (void *, void *, void *) WEAK;
-extern void *__cxa_begin_catch (void *) WEAK;
-extern void *__cxa_end_catch (void) WEAK;
-extern void __cxa_tm_cleanup (void *, void *, unsigned int) WEAK;
-
-extern void *_ZnwX (size_t) WEAK;
-extern void _ZdlPv (void *) WEAK;
-extern void *_ZnaX (size_t) WEAK;
-extern void _ZdaPv (void *) WEAK;
-
-typedef const struct nothrow_t { } *c_nothrow_p;
-
-extern void *_ZnwXRKSt9nothrow_t (size_t, c_nothrow_p) WEAK;
-extern void _ZdlPvRKSt9nothrow_t (void *, c_nothrow_p) WEAK;
-extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) WEAK;
-extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) WEAK;
-
-void *__cxa_allocate_exception (size_t s UNUSED) { return NULL; }
-void __cxa_throw (void * a UNUSED, void * b UNUSED, void * c UNUSED)
-  { return; }
-void *__cxa_begin_catch (void * a UNUSED) { return NULL; }
-void *__cxa_end_catch (void) { return NULL; }
-void __cxa_tm_cleanup (void * a UNUSED, void * b UNUSED, unsigned int c UNUSED)
-  { return; }
-
-void *_ZnwX (size_t s UNUSED) { return NULL; }
-void _ZdlPv (void * a UNUSED) { return; }
-void *_ZnaX (size_t s UNUSED) { return NULL; }
-void _ZdaPv (void * a UNUSED) { return; }
-
-void *_ZnwXRKSt9nothrow_t (size_t s UNUSED, c_nothrow_p b UNUSED)
-  { return NULL; }
-void _ZdlPvRKSt9nothrow_t (void * a UNUSED, c_nothrow_p b UNUSED)  { return; }
-void *_ZnaXRKSt9nothrow_t (size_t s UNUSED, c_nothrow_p b UNUSED)
-  { return NULL; }
-void _ZdaPvRKSt9nothrow_t (void * a UNUSED, c_nothrow_p b UNUSED) { return; }
-
 #endif
Index: gcc/config/i386/darwin.h
===================================================================
--- gcc/config/i386/darwin.h	(revision 195885)
+++ gcc/config/i386/darwin.h	(working copy)
@@ -131,8 +131,7 @@  extern int darwin_emit_branch_islands;
   "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
    %{mpc32:crtprec32.o%s} \
    %{mpc64:crtprec64.o%s} \
-   %{mpc80:crtprec80.o%s} \
-   %{fgnu-tm: -lcrttme.o}"
+   %{mpc80:crtprec80.o%s}" TM_DESTRUCTOR
 
 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS                                   \
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h	(revision 195885)
+++ gcc/config/darwin.h	(working copy)
@@ -363,7 +363,8 @@  extern GTY(()) int darwin_ms_struct;
   %{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}"
 
 /* We want a destructor last in the list.  */
-#define ENDFILE_SPEC "%{fgnu-tm: -lcrttme.o}"
+#define TM_DESTRUCTOR "%{fgnu-tm: -lcrttme.o}"
+#define ENDFILE_SPEC TM_DESTRUCTOR
 
 #define DARWIN_EXTRA_SPECS						\
   { "darwin_crt1", DARWIN_CRT1_SPEC },					\