Replace thread_local with boost equivalent

The new version of clang (Apple LLVM version 6.1.0) as shipped with Xcode 6.3, disabled TLS. According to http://clang.llvm.org/cxx_status.html, in order to support `thread_local`, the C++ runtime library from g++-4.8 or later is needed.

For now, we can use the boost `thread_specific_ptr`. This is probably a reasonable solution since 1) it should be portable with old and future versions of (Apple's) clang and 2) requires no additional dependencies.
This commit is contained in:
Ronald Wampler
2015-04-22 21:47:53 -04:00
committed by Allan Odgaard
parent 23509380cb
commit 172ce9d428
2 changed files with 8 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
#include "info.h"
#include <boost/thread/tss.hpp>
#include <oak/debug.h>
/* CrashReporter info */
@@ -58,8 +59,11 @@ namespace
static stack_t& stack ()
{
thread_local stack_t stack;
return stack;
static boost::thread_specific_ptr<stack_t> stackPtr;
if(!stackPtr.get())
stackPtr.reset(new stack_t);
return *stackPtr;
}
}

2
target
View File

@@ -28,6 +28,8 @@ LN_FLAGS += -rpath @executable_path/../Frameworks
CXX_FLAGS += -I"$capnp_prefix/include"
LN_FLAGS += -L"$capnp_prefix/lib"
LN_FLAGS += -lboost_thread-mt
PRELUDE = Shared/PCH/prelude.*
TARGETS = vendor/*/target