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 <r...@redhat.com>
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: Richard Henderson <r...@redhat.com>
Date:   Tue Nov 22 12:26:28 2011 -0800

    crtstuff: Dont use -fno-inline in building

diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index 23b72b9..61d4823 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -277,7 +277,7 @@ INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) 
$(HOST_LIBGCC2_CFLAGS) \
 
 # Options to use when compiling crtbegin/end.
 CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
-  -finhibit-size-directive -fno-inline -fno-exceptions \
+  -finhibit-size-directive -fno-exceptions \
   -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
   -fno-stack-protector \
   $(INHIBIT_LIBC_CFLAGS)

Reply via email to