Patchwork [libitm,darwin] PR52220 move dummy functions definition

login
register
mail settings
Submitter Patrick Marlier
Date Feb. 15, 2012, 11:39 p.m.
Message ID <4F3C4236.1070701@gmail.com>
Download mbox | patch
Permalink /patch/141433/
State New
Headers show

Comments

Patrick Marlier - Feb. 15, 2012, 11:39 p.m.
Hi,

In PR/52220, eh-1.C fails because the dummy function 
__cxa_allocate_exception is used instead of the one from libstdc++. 
Indeed, the function is defined in libitm and thus is used.
The fix consists to move the dummy function definitions to darwin-crt-tm.c.

This fix was mainly contributed by Iain Sandoe.
This was approved off-list by Mike Stump.

Committed and tested on darwin 10/11.
--
Patrick.

libitm/
2012-02-15  Iain Sandoe  <iains@gcc.gnu.org>
	    Patrick Marlier  <patrick.marlier@gmail.com>

	PR libitm/52220
	* alloc_cpp.cc: No dummy definitions for darwin.
	* eh_cpp.cc: Likewise.

libgcc/
2012-02-15  Iain Sandoe  <iains@gcc.gnu.org>
	    Patrick Marlier  <patrick.marlier@gmail.com>

	PR libitm/52220
	* config/darwin-crt-tm.c: Generate dummy functions.
IainS - Feb. 15, 2012, 11:48 p.m.
On 15 Feb 2012, at 23:39, Patrick Marlier wrote:

> 	PR libitm/52220
> 	* alloc_cpp.cc: No dummy definitions for darwin.
> 	* eh_cpp.cc: Likewise.
>
> libgcc/
> 2012-02-15  Iain Sandoe  <iains@gcc.gnu.org>
> 	    Patrick Marlier  <patrick.marlier@gmail.com>
>
> 	PR libitm/52220
> 	* config/darwin-crt-tm.c: Generate dummy functions.
> <darwin-pr52220.patch>

thanks for taking care of this.
Iain
Jack Howarth - Feb. 16, 2012, 1:24 a.m.
On Wed, Feb 15, 2012 at 11:48:29PM +0000, Iain Sandoe wrote:
>
> On 15 Feb 2012, at 23:39, Patrick Marlier wrote:
>
>> 	PR libitm/52220
>> 	* alloc_cpp.cc: No dummy definitions for darwin.
>> 	* eh_cpp.cc: Likewise.
>>
>> libgcc/
>> 2012-02-15  Iain Sandoe  <iains@gcc.gnu.org>
>> 	    Patrick Marlier  <patrick.marlier@gmail.com>
>>
>> 	PR libitm/52220
>> 	* config/darwin-crt-tm.c: Generate dummy functions.
>> <darwin-pr52220.patch>
>
> thanks for taking care of this.
> Iain

Iain,
   We are still failing...

FAIL: libitm.c++/eh-1.C execution test

on x86_64-apple-darwin11 as the committed patch is missing
those changes from darwin-pie4.patch which addressed PR52220.
         Jack

Patch

Index: libitm/alloc_cpp.cc
===================================================================
--- libitm/alloc_cpp.cc	(revision 184291)
+++ libitm/alloc_cpp.cc	(working copy)
@@ -60,7 +60,7 @@  extern void _ZdlPvRKSt9nothrow_t (void *, c_nothro
 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)
+#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined (__MACH__)
 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 184291)
+++ libitm/eh_cpp.cc	(working copy)
@@ -39,7 +39,7 @@  extern void *__cxa_begin_catch (void *) WEAK;
 extern void *__cxa_end_catch (void) WEAK;
 extern void __cxa_tm_cleanup (void *, void *, unsigned int) WEAK;
 
-#if !defined (HAVE_ELF_STYLE_WEAKREF)
+#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined (__MACH__)
 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 184291)
+++ libgcc/config/darwin-crt-tm.c	(working copy)
@@ -39,6 +39,7 @@  see the files COPYING3 and COPYING.RUNTIME respect
 #endif
 
 #define WEAK __attribute__((weak))
+#define UNUSED __attribute__((unused))
 
 extern void _ITM_registerTMCloneTable (void *, size_t) WEAK;
 extern void _ITM_deregisterTMCloneTable (void *) WEAK;
@@ -103,3 +104,46 @@  void __doTMdeRegistrations (void)
 }
 
 #endif
+
+/* 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; }
+