diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2014-06-24 13:50:01 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2014-06-24 13:50:01 +0000 |
commit | cb12cf7743747bb780c9286d9b3f3d3205fd2cee (patch) | |
tree | 4b43e43f7c6e3ae2c7600636bb23b95f09aa7b03 | |
parent | 9f4aa8c03413adc6d5946f33c39697c6961680f2 (diff) | |
download | clang-cb12cf7743747bb780c9286d9b3f3d3205fd2cee.tar.gz clang-cb12cf7743747bb780c9286d9b3f3d3205fd2cee.tar.bz2 clang-cb12cf7743747bb780c9286d9b3f3d3205fd2cee.tar.xz |
Revert r211121 (and r211285), "Change libclang initialization to use std::call_once instead of"
It broke mingw builder and cygwin-clang stage2, possibly lack of tls in <mutex>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211593 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/libclang/CIndex.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 45e5786095..787c28b21e 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -51,7 +51,6 @@ #include "llvm/Support/Threading.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" -#include <mutex> #ifdef __APPLE__ #include <pthread.h> @@ -2573,8 +2572,8 @@ buildPieces(unsigned NameFlags, bool IsMemberRefExpr, // Misc. API hooks. //===----------------------------------------------------------------------===// -static llvm::sys::Mutex LoggingMutex; -static std::once_flag LibclangGlobalInitFlag; +static llvm::sys::Mutex EnableMultithreadingMutex; +static bool EnabledMultithreading; static void fatal_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag) { @@ -2584,10 +2583,6 @@ static void fatal_error_handler(void *user_data, const std::string& reason, ::abort(); } -static void initializeLibClang() { - llvm::install_fatal_error_handler(fatal_error_handler, nullptr); -} - extern "C" { CXIndex clang_createIndex(int excludeDeclarationsFromPCH, int displayDiagnostics) { @@ -2596,7 +2591,15 @@ CXIndex clang_createIndex(int excludeDeclarationsFromPCH, if (!getenv("LIBCLANG_DISABLE_CRASH_RECOVERY")) llvm::CrashRecoveryContext::Enable(); - std::call_once(LibclangGlobalInitFlag, initializeLibClang); + // Enable support for multithreading in LLVM. + { + llvm::sys::ScopedLock L(EnableMultithreadingMutex); + if (!EnabledMultithreading) { + llvm::install_fatal_error_handler(fatal_error_handler, nullptr); + llvm::llvm_start_multithreaded(); + EnabledMultithreading = true; + } + } CIndexer *CIdxr = new CIndexer(); if (excludeDeclarationsFromPCH) @@ -6974,7 +6977,7 @@ Logger &cxindex::Logger::operator<<(const llvm::format_object_base &Fmt) { cxindex::Logger::~Logger() { LogOS.flush(); - llvm::sys::ScopedLock L(LoggingMutex); + llvm::sys::ScopedLock L(EnableMultithreadingMutex); static llvm::TimeRecord sBeginTR = llvm::TimeRecord::getCurrentTime(); |