While testing the proposed patch to eliminate race conditions in indirect value
profiling...

http://gcc.gnu.org/ml/gcc-patches/2008-12/msg00892.html

I found that the many profile testcases failed due unresolved symbols such
as...
__emutls_v.__gcov_indirect_call_counters and
___emutls_v.__gcov_indirect_call_callee".
A review of the later stage libgcc builds revealed that the -DHAVE_CC_TLS flag
was passed
without the associated -DUSE_EMUTLS. The current test for setting -DHAVE_CC_TLS
is based
on the test program...

__thread int a; int b; int main() { return a = b; }

which while it fails under the Apple system gcc 4.2.1 compiler with the
error...

thread_test.c:1: error: thread-local storage not supported for this target

compiles without error and runs fine under the newly built xgcc compiler (due
to
the emutls support). The easy fix appears to be...

2010-03-27  Jack Howarth <howa...@bromo.med.uc.edu>

        * config.host (tmake_file): Add t-emutls for *-*-darwin*.
        * t-emutls: New file.

Index: libgcc/config.host
===================================================================
--- libgcc/config.host  (revision 157779)
+++ libgcc/config.host  (working copy)
@@ -597,6 +597,12 @@
 esac

 case ${host} in
+*-*-darwin*)
+       tmake_file="${tmake_file} t-emutls"
+       ;;
+esac
+
+case ${host} in
 i[34567]86-*-darwin* | x86_64-*-darwin* | \
   i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu | \
   i[34567]86-*-linux* | x86_64-*-linux* | \
Index: libgcc/config/t-emutls 
===================================================================
--- libgcc/config/t-emutls      (revision 0)
+++ libgcc/config/t-emutls      (revision 0)
@@ -0,0 +1,2 @@
+# Use emulated thread-local storage
+INTERNAL_CFLAGS += -DUSE_EMUTLS

which bootstraps fine on both x86_64-apple-darwin9 and x86_64-apple-darwin10
with the proposed race condition patch...

Index: gcc/tree-profile.c
===================================================================
--- gcc/tree-profile.c  (revision 157765)
+++ gcc/tree-profile.c  (working copy)
@@ -82,6 +82,7 @@
   TREE_PUBLIC (ic_void_ptr_var) = 0;
   DECL_ARTIFICIAL (ic_void_ptr_var) = 1;
   DECL_INITIAL (ic_void_ptr_var) = NULL;
+  DECL_TLS_MODEL (ic_void_ptr_var) = decl_default_tls_model (ic_void_ptr_var);
   varpool_finalize_decl (ic_void_ptr_var);

   gcov_type_ptr = build_pointer_type (get_gcov_type ());
@@ -93,6 +94,7 @@
   TREE_PUBLIC (ic_gcov_type_ptr_var) = 0;
   DECL_ARTIFICIAL (ic_gcov_type_ptr_var) = 1;
   DECL_INITIAL (ic_gcov_type_ptr_var) = NULL;
+  DECL_TLS_MODEL (ic_gcov_type_ptr_var) = decl_default_tls_model
(ic_gcov_type_ptr_var);
   varpool_finalize_decl (ic_gcov_type_ptr_var);
 }

with no regressions in the testsuite (particularly the profile section). I
assume when the race
condition fix is committed other targets that use emutls will need to be added
to the 
case statement.


-- 
           Summary: libgcc built with -DHAVE_CC_TLS against xgcc when emutls
                    in use
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: howarth at nitro dot med dot uc dot edu
 GCC build triplet: *-apple-darwin*
  GCC host triplet: *-apple-darwin*
GCC target triplet: *-apple-darwin*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43553

Reply via email to