Patchwork Fix PR libitm/55693

login
register
mail settings
Submitter Jack Howarth
Date Feb. 6, 2013, 2:12 p.m.
Message ID <20130206141201.GA4484@bromo.med.uc.edu>
Download mbox | patch
Permalink /patch/218631/
State New
Headers show

Comments

Jack Howarth - Feb. 6, 2013, 2:12 p.m.
The attached patch eliminates the failure of the libitm.c++/eh-1.C execution test on darwin10
and later, PR55693. 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
weak symbols for the dummy functions in libgcc/config/darwin-crt-tm.c from being replaced by those
in the libstdc++ shared library. The solution is not to define these dummy symbols when targeting
Mac OS X 10.6 or later (where the tool chain properly handles undefined weak refs in the linker).
Tested on x86_64-apple-darwin10 with Xcode 3.2.6, x86_64-apple-darwin11 and x86_64-apple-darwin12
with Xcode 4.5.2/4.6. Note that this fix requires functional dynamic lookup of undefined symbols
which is broken for the buggy linkers in Xcode 4.2 up to but not including Xcode 4.4 due to
radr://10466868. Since the Xcode 4.x was only briefly available to 10.6 users and the libitm.c++/eh-1.C 
execution test is already broken on 10.6, they should revert to Xcode 3.2.6 to achieve the fix.
Users on 10.7 and later have access to Xcode 4.4 and later without the undefined dynamic lookup bug.
Okay for gcc trunk?
        Jack
/libgcc

2013-02-06  Iain Sandoe  <iain@codesourcery.com>
	    Jack Howarth  <howarth@bromo.med.uc.edu>

	PR libitm/55693
	* config/darwin-crt-tm.c: Provide dummy functions only prior to 10.6.

/gcc

2013-02-06  Iain Sandoe  <iain@codesourcery.com>
	    Jack Howarth  <howarth@bromo.med.uc.edu>

	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.

Patch

Index: libgcc/config/darwin-crt-tm.c
===================================================================
--- libgcc/config/darwin-crt-tm.c	(revision 195764)
+++ libgcc/config/darwin-crt-tm.c	(working copy)
@@ -103,9 +103,12 @@  void __doTMdeRegistrations (void)
     _ITM_deregisterTMCloneTable (tmct);
 }
 
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+            __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__  < 1060
+
 /* 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. */
+   Don't define for 10.6 or later with faster weak-symbol coalescing. */
 
 extern void *__cxa_allocate_exception (size_t) WEAK;
 extern void __cxa_throw (void *, void *, void *) WEAK;
@@ -144,5 +147,5 @@  void _ZdlPvRKSt9nothrow_t (void * a UNUS
 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
 #endif
Index: gcc/config/i386/darwin.h
===================================================================
--- gcc/config/i386/darwin.h	(revision 195764)
+++ 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 195764)
+++ 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 },					\