summaryrefslogtreecommitdiff
path: root/rts/Task.h
diff options
context:
space:
mode:
authorDavid M Peixotto <dmp@rice.edu>2011-06-28 15:31:42 -0500
committerDavid M Peixotto <dmp@rice.edu>2011-10-07 16:48:34 -0500
commitdba7254566b121408e7167200d0223a531b66e8b (patch)
tree0a3bfcb739b35123822cb644db93081b46c54fca /rts/Task.h
parent29a97fded4010bd01aa0a17945c84258e285d421 (diff)
downloadhaskell-dba7254566b121408e7167200d0223a531b66e8b.tar.gz
Enable pthread_getspecific() tls for LLVM compiler
LLVM does not support the __thread attribute for thread local storage and may generate incorrect code for global register variables. We want to allow building the runtime with LLVM-based compilers such as llvm-gcc and clang, particularly for MacOS. This patch changes the gct variable used by the garbage collector to use pthread_getspecific() for thread local storage when an llvm based compiler is used to build the runtime.
Diffstat (limited to 'rts/Task.h')
-rw-r--r--rts/Task.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/rts/Task.h b/rts/Task.h
index 424af607ea..4000a045d4 100644
--- a/rts/Task.h
+++ b/rts/Task.h
@@ -241,14 +241,21 @@ void interruptWorkerTask (Task *task);
// A thread-local-storage key that we can use to get access to the
// current thread's Task structure.
#if defined(THREADED_RTS)
-#if (defined(linux_HOST_OS) && \
+#if ((defined(linux_HOST_OS) && \
(defined(i386_HOST_ARCH) || defined(x86_64_HOST_ARCH))) || \
- (defined(mingw32_HOST_OS) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
+ (defined(mingw32_HOST_OS) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 4)) && \
+ (!defined(llvm_CC_FLAVOR))
#define MYTASK_USE_TLV
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