From: Zachary Turner Date: Tue, 10 Jun 2014 23:17:11 +0000 (+0000) Subject: Revert "Clang changes to support LLVM removal of runtime multithreading" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a438edc06abbe6f78fc5cc692b6aaecf0730eb08;p=clang Revert "Clang changes to support LLVM removal of runtime multithreading" This reverts r210601. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210604 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 7320bbd085..4d296d46b7 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -2556,8 +2556,8 @@ buildPieces(unsigned NameFlags, bool IsMemberRefExpr, // Misc. API hooks. //===----------------------------------------------------------------------===// -static llvm::sys::Mutex LoggingMutex; -static std::once_flag InstalledErrorHandlerFlag; +static llvm::sys::Mutex EnableMultithreadingMutex; +static bool EnabledMultithreading; static void fatal_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag) { @@ -2575,8 +2575,15 @@ CXIndex clang_createIndex(int excludeDeclarationsFromPCH, if (!getenv("LIBCLANG_DISABLE_CRASH_RECOVERY")) llvm::CrashRecoveryContext::Enable(); - std::call_once(InstalledErrorHandlerFlag, - []() {llvm::install_fatal_error_handler(fatal_error_handler, nullptr);}); + // 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) @@ -6952,7 +6959,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();