Re: Re-merge crtstuff.c from the trans-mem branch

2011-11-25 Thread Rainer Orth
Rainer Orth  writes:

> While the first patch allows Solaris 8/9 x86 bootstraps to finish
> (testsuite still running), I happened to run a Solaris 10/SPARC
> bootstrap that broke configuring stage 2 libgomp: even trivial
> executables die with a SEGV in _init.
>
> It turns out (still verifying with a fresh bootstrap) that the
> -fno-inline removal is the culprit.

All bootstraps have now completed without regressions, so the patch is
good to go from a Solaris POV.

Thanks.
Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: Re-merge crtstuff.c from the trans-mem branch

2011-11-23 Thread Rainer Orth
Richard Henderson  writes:

> On 11/22/2011 04:15 AM, Rainer Orth wrote:
>> This patch broke bootstrap on Solaris 8 and 9/x86 with Sun as which
>> doesn't support .hidden: linking the stage2 lto-plugin fails like this:
>> 
>> ld: fatal: relocation error: R_386_GOTOFF: file 
>> /var/gcc/regression/trunk/8-gcc/build/./prev-gcc/crtbegin.o: symbol 
>> __TMC_END__: relocation must bind locally
>> collect2: error: ld returned 1 exit status
>> make[4]: *** [liblto_plugin.la] Error 1
>
> Blah, of course it does.
>
> The first of these patches should fix this.  The second... well, I
> don't recall why we use -fno-inline atm.  It works for i386-linux,
> of course, to eliminate it.  But this is a twisty maze...

While the first patch allows Solaris 8/9 x86 bootstraps to finish
(testsuite still running), I happened to run a Solaris 10/SPARC
bootstrap that broke configuring stage 2 libgomp: even trivial
executables die with a SEGV in _init.

It turns out (still verifying with a fresh bootstrap) that the
-fno-inline removal is the culprit.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: Re-merge crtstuff.c from the trans-mem branch

2011-11-22 Thread Richard Henderson
On 11/22/2011 04:15 AM, Rainer Orth wrote:
> This patch broke bootstrap on Solaris 8 and 9/x86 with Sun as which
> doesn't support .hidden: linking the stage2 lto-plugin fails like this:
> 
> ld: fatal: relocation error: R_386_GOTOFF: file 
> /var/gcc/regression/trunk/8-gcc/build/./prev-gcc/crtbegin.o: symbol 
> __TMC_END__: relocation must bind locally
> collect2: error: ld returned 1 exit status
> make[4]: *** [liblto_plugin.la] Error 1

Blah, of course it does.

The first of these patches should fix this.  The second... well, I
don't recall why we use -fno-inline atm.  It works for i386-linux,
of course, to eliminate it.  But this is a twisty maze...

I can do several things: (1) leave things alone, let the "inline"
function continue to be out-of-line, (2) rewrite the code block
using a macro, (3) probably break something with the second patch.  ;-)

Thoughts?


r~
commit 371b252092b9d6aa3987ad73455d2512b9be0769
Author: Richard Henderson 
Date:   Tue Nov 22 10:33:29 2011 -0800

crtstuff: adjust tm clones for no attribute hidden

diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c
index 6f06b62..77b8d42 100644
--- a/libgcc/crtstuff.c
+++ b/libgcc/crtstuff.c
@@ -252,9 +252,51 @@ STATIC void *__JCR_LIST__[]
 
 #if USE_TM_CLONE_REGISTRY
 STATIC func_ptr __TMC_LIST__[]
-  __attribute__((unused, section(".tm_clone_table"), aligned(sizeof(void*
+  __attribute__((used, section(".tm_clone_table"), aligned(sizeof(void*
   = { };
+# ifdef HAVE_GAS_HIDDEN
 extern func_ptr __TMC_END__[] __attribute__((__visibility__ ("hidden")));
+# endif
+
+static inline void
+deregister_tm_clones (void)
+{
+  void (*fn) (void *);
+
+#ifdef HAVE_GAS_HIDDEN
+  if (__TMC_END__ - __TMC_LIST__ == 0)
+return;
+#else
+  if (__TMC_LIST__[0] == NULL)
+return;
+#endif
+
+  fn = _ITM_deregisterTMCloneTable;
+  __asm ("" : "+r" (fn));
+  if (fn)
+fn (__TMC_LIST__);
+}
+
+static inline void
+register_tm_clones (void)
+{
+  void (*fn) (void *, size_t);
+  size_t size;
+
+#ifdef HAVE_GAS_HIDDEN
+  size = (__TMC_END__ - __TMC_LIST__) / 2;
+#else
+  for (size = 0; __TMC_LIST__[size * 2] != NULL; size++)
+continue;
+#endif
+  if (size == 0)
+return;
+
+  fn = _ITM_registerTMCloneTable;
+  __asm ("" : "+r" (fn));
+  if (fn)
+fn (__TMC_LIST__, size);
+}
 #endif /* USE_TM_CLONE_REGISTRY */
 
 #if defined(INIT_SECTION_ASM_OP) || defined(INIT_ARRAY_SECTION_ASM_OP)
@@ -347,13 +389,7 @@ __do_global_dtors_aux (void)
 #endif /* !defined(FINI_ARRAY_SECTION_ASM_OP) */
 
 #if USE_TM_CLONE_REGISTRY
-  if (__TMC_END__ - __TMC_LIST__ > 0)
-{
-  void (*deregister_clones) (void *) = _ITM_deregisterTMCloneTable;
-  __asm ("" : "+r" (deregister_clones));
-  if (deregister_clones)
-   deregister_clones (__TMC_LIST__);
-}
+  deregister_tm_clones ();
 #endif /* USE_TM_CLONE_REGISTRY */
 
 #ifdef USE_EH_FRAME_REGISTRY
@@ -422,16 +458,7 @@ frame_dummy (void)
 #endif /* JCR_SECTION_NAME */
 
 #if USE_TM_CLONE_REGISTRY
-  if (__TMC_END__ - __TMC_LIST__ > 0)
-{
-  void (*register_clones) (void *, size_t) = _ITM_registerTMCloneTable;
-  __asm ("" : "+r" (register_clones));
-  if (register_clones)
-   {
- size_t size = (size_t)(__TMC_END__ - __TMC_LIST__) / 2;
- _ITM_registerTMCloneTable (__TMC_LIST__, size);
-   }
-}
+  register_tm_clones ();
 #endif /* USE_TM_CLONE_REGISTRY */
 }
 
@@ -500,13 +527,7 @@ __do_global_dtors (void)
 f ();
 
 #if USE_TM_CLONE_REGISTRY
-  if (__TMC_END__ - __TMC_LIST__ > 0)
-{
-  void (*deregister_clones) (void *) = _ITM_deregisterTMCloneTable;
-  __asm ("" : "+r" (deregister_clones));
-  if (deregister_clones)
-   deregister_clones (__TMC_LIST__);
-}
+  deregister_tm_clones ();
 #endif /* USE_TM_CLONE_REGISTRY */
 
 #ifdef USE_EH_FRAME_REGISTRY
@@ -542,16 +563,7 @@ __do_global_ctors_1(void)
 #endif
 
 #if USE_TM_CLONE_REGISTRY
-  if (__TMC_END__ - __TMC_LIST__ > 0)
-{
-  void (*register_clones) (void *, size_t) = _ITM_registerTMCloneTable;
-  __asm ("" : "+r" (register_clones));
-  if (register_clones)
-   {
- size_t size = (size_t)(__TMC_END__ - __TMC_LIST__) / 2;
- register_clones (__TMC_LIST__, size);
-   }
-}
+  register_tm_clones ();
 #endif /* USE_TM_CLONE_REGISTRY */
 }
 #endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME || USE_TM_CLONE_REGISTRY */
@@ -639,10 +651,16 @@ STATIC void *__JCR_END__[1]
 #endif /* JCR_SECTION_NAME */
 
 #if USE_TM_CLONE_REGISTRY
+# ifndef HAVE_GAS_HIDDEN
+static
+# endif
 func_ptr __TMC_END__[]
-  __attribute__((unused, section(".tm_clone_table"), aligned(sizeof(void *)),
-__visibility__ ("hidden")))
-  = { };
+  __attribute__((used, section(".tm_clone_table"), aligned(sizeof(void *
+# ifdef HAVE_GAS_HIDDEN
+  __attribute__((__visibility__ ("hidden"))) = { };
+# else
+  = { 0, 0 };
+# endif
 #endif /* USE_TM_CLONE_REGISTRY */
 
 #ifdef INIT_ARRAY_SECTION_ASM_OP
commit bd6fe04af465d65d146e7ea7fd66b4a98cecff46
Author: Rich

Re: Re-merge crtstuff.c from the trans-mem branch

2011-11-22 Thread Rainer Orth
Richard Henderson  writes:

> On 11/21/2011 02:13 PM, Richard Henderson wrote:
>> This was actually a merge error on the branch.  When crtstuff.c
>> moved to libgcc/, Aldy failed to copy the changes.
>> 
>> I've tidied things even a bit more from the branch, with the
>> introduction of the USE_TM_CLONE_REGISTRY control macro, which
>> is in turn now predicated on ELF.
>> 
>> Tested on x86_64-linux.  I'm really not sure what non-elf
>> targets really use this file...
>
> It has been pointed out to me that I'm an idiot and sent an empty attachment.
> So lets try this again...

This patch broke bootstrap on Solaris 8 and 9/x86 with Sun as which
doesn't support .hidden: linking the stage2 lto-plugin fails like this:

ld: fatal: relocation error: R_386_GOTOFF: file 
/var/gcc/regression/trunk/8-gcc/build/./prev-gcc/crtbegin.o: symbol 
__TMC_END__: relocation must bind locally
collect2: error: ld returned 1 exit status
make[4]: *** [liblto_plugin.la] Error 1

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: Re-merge crtstuff.c from the trans-mem branch

2011-11-21 Thread Patrick Marlier

On 11/21/2011 06:46 PM, Patrick Marlier wrote:

On 11/21/2011 06:14 PM, Richard Henderson wrote:

On 11/21/2011 02:13 PM, Richard Henderson wrote:
It has been pointed out to me that I'm an idiot and sent an empty attachment.
So lets try this again...


Arg... I have never said that!



+#if USE_TM_CLONE_REGISTRY
+  if (__TMC_END__ - __TMC_LIST__>  0)
+{
+  void (*register_clones) (void *, size_t) = _ITM_registerTMCloneTable;
+  __asm ("" : "+r" (register_clones));
+  if (register_clones)
+   {
+ size_t size = (size_t)(__TMC_END__ - __TMC_LIST__) / 2;
+ _ITM_registerTMCloneTable (__TMC_LIST__, size);
+   }
+}
+#endif /* USE_TM_CLONE_REGISTRY */



I guess you should call register_clones instead of
_ITM_registerTMCloneTable.

Thanks!

Patrick.

PS: Sorry if duplicated email but it seems that the first one was refused.


Re: Re-merge crtstuff.c from the trans-mem branch

2011-11-21 Thread Richard Henderson
On 11/21/2011 02:13 PM, Richard Henderson wrote:
> This was actually a merge error on the branch.  When crtstuff.c
> moved to libgcc/, Aldy failed to copy the changes.
> 
> I've tidied things even a bit more from the branch, with the
> introduction of the USE_TM_CLONE_REGISTRY control macro, which
> is in turn now predicated on ELF.
> 
> Tested on x86_64-linux.  I'm really not sure what non-elf
> targets really use this file...

It has been pointed out to me that I'm an idiot and sent an empty attachment.
So lets try this again...


r~
commit 2d171408c1652f80f20f8e4bf898cec6357a160f
Author: rth 
Date:   Mon Nov 21 22:10:06 2011 +

Fix crtstuff merge error with transactional-memory branch.

* crtstuff.c (USE_TM_CLONE_REGISTRY): Default to 1 on ELF.
(__TMC_LIST__, __TMC_END__): New.
(__do_global_dtors_aux): Call _ITM_deregisterTMCloneTable.
(__do_global_dtors): Likewise.
(frame_dummy): Call _ITM_registerTMCloneTable.
(__do_global_ctors_1): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181600 
138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 13881d8..fc2331d 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,12 @@
+2011-11-21  Richard Henderson  
+
+   * crtstuff.c (USE_TM_CLONE_REGISTRY): Default to 1 on ELF.
+   (__TMC_LIST__, __TMC_END__): New.
+   (__do_global_dtors_aux): Call _ITM_deregisterTMCloneTable.
+   (__do_global_dtors): Likewise.
+   (frame_dummy): Call _ITM_registerTMCloneTable.
+   (__do_global_ctors_1): Likewise.
+
 2011-11-21  Rainer Orth  
 
* config.host (iq2000*-*-elf*): Add iq2000/t-iq2000 to tmake_file.
diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c
index 66b2cdf..6f06b62 100644
--- a/libgcc/crtstuff.c
+++ b/libgcc/crtstuff.c
@@ -127,6 +127,10 @@ call_ ## FUNC (void)   
\
 # define HIDDEN_DTOR_LIST_END
 #endif
 
+#if !defined(USE_TM_CLONE_REGISTRY) && defined(OBJECT_FORMAT_ELF)
+# define USE_TM_CLONE_REGISTRY 1
+#endif
+
 /* We do not want to add the weak attribute to the declarations of these
routines in unwind-dw2-fde.h because that will cause the definition of
these symbols to be weak as well.
@@ -163,6 +167,10 @@ extern void __do_global_ctors_1 (void);
 /* Likewise for _Jv_RegisterClasses.  */
 extern void _Jv_RegisterClasses (void *) TARGET_ATTRIBUTE_WEAK;
 
+/* Likewise for transactional memory clone tables.  */
+extern void _ITM_registerTMCloneTable (void *, size_t) TARGET_ATTRIBUTE_WEAK;
+extern void _ITM_deregisterTMCloneTable (void *) TARGET_ATTRIBUTE_WEAK;
+
 #ifdef OBJECT_FORMAT_ELF
 
 /*  Declare a pointer to void function type.  */
@@ -242,6 +250,13 @@ STATIC void *__JCR_LIST__[]
   = { };
 #endif /* JCR_SECTION_NAME */
 
+#if USE_TM_CLONE_REGISTRY
+STATIC func_ptr __TMC_LIST__[]
+  __attribute__((unused, section(".tm_clone_table"), aligned(sizeof(void*
+  = { };
+extern func_ptr __TMC_END__[] __attribute__((__visibility__ ("hidden")));
+#endif /* USE_TM_CLONE_REGISTRY */
+
 #if defined(INIT_SECTION_ASM_OP) || defined(INIT_ARRAY_SECTION_ASM_OP)
 
 #ifdef OBJECT_FORMAT_ELF
@@ -331,6 +346,16 @@ __do_global_dtors_aux (void)
   }
 #endif /* !defined(FINI_ARRAY_SECTION_ASM_OP) */
 
+#if USE_TM_CLONE_REGISTRY
+  if (__TMC_END__ - __TMC_LIST__ > 0)
+{
+  void (*deregister_clones) (void *) = _ITM_deregisterTMCloneTable;
+  __asm ("" : "+r" (deregister_clones));
+  if (deregister_clones)
+   deregister_clones (__TMC_LIST__);
+}
+#endif /* USE_TM_CLONE_REGISTRY */
+
 #ifdef USE_EH_FRAME_REGISTRY
 #ifdef CRT_GET_RFIB_DATA
   /* If we used the new __register_frame_info_bases interface,
@@ -362,7 +387,9 @@ __do_global_dtors_aux_1 (void)
 CRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, __do_global_dtors_aux_1)
 #endif
 
-#if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
+#if defined(USE_EH_FRAME_REGISTRY) \
+|| defined(JCR_SECTION_NAME) \
+|| defined(USE_TM_CLONE_REGISTRY)
 /* Stick a call to __register_frame_info into the .init section.  For some
reason calls with no arguments work more reliably in .init, so stick the
call in another function.  */
@@ -383,6 +410,7 @@ frame_dummy (void)
 __register_frame_info (__EH_FRAME_BEGIN__, &object);
 #endif /* CRT_GET_RFIB_DATA */
 #endif /* USE_EH_FRAME_REGISTRY */
+
 #ifdef JCR_SECTION_NAME
   if (__JCR_LIST__[0])
 {
@@ -392,6 +420,19 @@ frame_dummy (void)
register_classes (__JCR_LIST__);
 }
 #endif /* JCR_SECTION_NAME */
+
+#if USE_TM_CLONE_REGISTRY
+  if (__TMC_END__ - __TMC_LIST__ > 0)
+{
+  void (*register_clones) (void *, size_t) = _ITM_registerTMCloneTable;
+  __asm ("" : "+r" (register_clones));
+  if (register_clones)
+   {
+ size_t size = (size_t)(__TMC_END__ - __TMC_LIST__) / 2;
+ _ITM_registerTMCloneTable (__TMC_LIST__, size);
+   }
+}
+#endif /* USE_TM_CLONE_REGISTRY */
 }
 
 

Re-merge crtstuff.c from the trans-mem branch

2011-11-21 Thread Richard Henderson
This was actually a merge error on the branch.  When crtstuff.c
moved to libgcc/, Aldy failed to copy the changes.

I've tidied things even a bit more from the branch, with the
introduction of the USE_TM_CLONE_REGISTRY control macro, which
is in turn now predicated on ELF.

Tested on x86_64-linux.  I'm really not sure what non-elf
targets really use this file...


r~