Skip to content

Commit

Permalink
Replace thread_local with boost equivalent
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rdwampler authored and sorbits committed Apr 30, 2015
1 parent 2350938 commit 172ce9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Frameworks/crash/src/info.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "info.h"
#include <boost/thread/tss.hpp>
#include <oak/debug.h>

/* CrashReporter info */
Expand Down Expand Up @@ -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;
}
}

Expand Down
2 changes: 2 additions & 0 deletions target
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 172ce9d

Please sign in to comment.