[commit: ghc] master: Hopefully fix breakage on OS X w/ LLVM (0dcccf0)

Simon Marlow marlowsd at gmail.com
Thu Jan 17 21:30:08 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/0dcccf0ca650a3f6fd69e4af428e827b718f0b4b

>---------------------------------------------------------------

commit 0dcccf0ca650a3f6fd69e4af428e827b718f0b4b
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Thu Jan 17 16:42:38 2013 +0000

    Hopefully fix breakage on OS X w/ LLVM
    
    Reordering of includes in GC.c broke on OS X because gctKey is
    declared in Task.h and is needed in the storage manager.  This is
    really the wrong place for it anyway, so I've moved the gctKey pieces
    to where they should be.

>---------------------------------------------------------------

 rts/Task.c        |    9 ---------
 rts/Task.h        |    6 ------
 rts/sm/GCTDecl.h  |    2 +-
 rts/sm/GCThread.h |    4 ++++
 rts/sm/Storage.c  |    7 +++++++
 5 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/rts/Task.c b/rts/Task.c
index 78725dd..e6781a1 100644
--- a/rts/Task.c
+++ b/rts/Task.c
@@ -54,9 +54,6 @@ __thread Task *my_task;
 # else
 ThreadLocalKey currentTaskKey;
 # endif
-#ifdef llvm_CC_FLAVOR
-ThreadLocalKey gctKey;
-#endif
 #else
 Task *my_task;
 #endif
@@ -78,9 +75,6 @@ initTaskManager (void)
 #if !defined(MYTASK_USE_TLV)
 	newThreadLocalKey(&currentTaskKey);
 #endif
-#if defined(llvm_CC_FLAVOR)
-	newThreadLocalKey(&gctKey);
-#endif
         initMutex(&all_tasks_mutex);
 #endif
     }
@@ -115,9 +109,6 @@ freeTaskManager (void)
 #if !defined(MYTASK_USE_TLV)
     freeThreadLocalKey(&currentTaskKey);
 #endif
-#if defined(llvm_CC_FLAVOR)
-    freeThreadLocalKey(&gctKey);
-#endif
 #endif
 
     tasksInitialized = 0;
diff --git a/rts/Task.h b/rts/Task.h
index e5b7295..f18f154 100644
--- a/rts/Task.h
+++ b/rts/Task.h
@@ -238,12 +238,6 @@ extern __thread Task *my_task;
 #else
 extern ThreadLocalKey currentTaskKey;
 #endif
-// LLVM-based compilers do not upport the __thread attribute, so we need
-// to store the gct variable as a pthread local storage. We declare the
-// key here to keep thread local storage initialization in the same place.
-#if defined(llvm_CC_FLAVOR)
-extern ThreadLocalKey gctKey;
-#endif
 #else
 extern Task *my_task;
 #endif
diff --git a/rts/sm/GCTDecl.h b/rts/sm/GCTDecl.h
index f9c8fcb..6eb6cc2 100644
--- a/rts/sm/GCTDecl.h
+++ b/rts/sm/GCTDecl.h
@@ -52,7 +52,7 @@ extern __thread gc_thread* gct;
 // with a C compiler that uses an LLVM back end (clang or llvm-gcc) then we
 // use pthread_getspecific() to handle the thread local storage for gct.
 #define gct ((gc_thread *)(pthread_getspecific(gctKey)))
-#define DECLARE_GCT /* nothing */
+#define DECLARE_GCT ThreadLocalKey gctKey;
 
 #elif defined(sparc_HOST_ARCH)
 // On SPARC we can't pin gct to a register. Names like %l1 are just offsets
diff --git a/rts/sm/GCThread.h b/rts/sm/GCThread.h
index 7d163cb..59327bc 100644
--- a/rts/sm/GCThread.h
+++ b/rts/sm/GCThread.h
@@ -204,6 +204,10 @@ extern nat n_gc_threads;
 
 extern gc_thread **gc_threads;
 
+#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR)
+extern ThreadLocalKey gctKey;
+#endif
+
 #include "EndPrivate.h"
 
 #endif // SM_GCTHREAD_H
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index ff4f172..518ae0d 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -229,6 +229,10 @@ void storageAddCapabilities (nat from, nat to)
         }
     }
 
+#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR)
+    newThreadLocalKey(&gctKey);
+#endif
+
     initGcThreads(from, to);
 }
 
@@ -249,6 +253,9 @@ freeStorage (rtsBool free_heap)
     closeMutex(&sm_mutex);
 #endif
     stgFree(nurseries);
+#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR)
+    freeThreadLocalKey(&gctKey);
+#endif
     freeGcThreads();
 }
 





More information about the ghc-commits mailing list