diff --git a/lib/Interpreter/IncrementalParser.cpp b/lib/Interpreter/IncrementalParser.cpp index b17324dc..7c1f6b1c 100644 --- a/lib/Interpreter/IncrementalParser.cpp +++ b/lib/Interpreter/IncrementalParser.cpp @@ -98,7 +98,6 @@ namespace cling { const std::string& PCHFileName = m_CI->getInvocation ().getPreprocessorOpts().ImplicitPCHInclude; if (!PCHFileName.empty()) { - Transaction* CurT = beginTransaction(CO); m_CI->createPCHExternalASTSource(PCHFileName, true /*DisablePCHValidation*/, @@ -124,8 +123,12 @@ namespace cling { if (External) External->StartTranslationUnit(m_Consumer); + // DO NOT commit the transactions here: static initialization in these + // transactions requires gCling through local_cxa_atexit(), but that has not + // been defined yet! if (Transaction* EndedT = endTransaction(CurT)) result.push_back(EndedT); + } IncrementalParser::~IncrementalParser() { diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp index d839c182..bc5c7c18 100644 --- a/lib/Interpreter/Interpreter.cpp +++ b/lib/Interpreter/Interpreter.cpp @@ -198,7 +198,9 @@ namespace cling { else IncludeCRuntime(); - for (llvm::SmallVectorImpl::const_iterator + // Commit the transactions, now that gCling is set up. It is needed for + // static initialization in these transactions through local_cxa_atexit(). + for (llvm::SmallVectorImpl::const_iterator I = IncrParserTransactions.begin(), E = IncrParserTransactions.end(); I != E; ++I) m_IncrParser->commitTransaction(*I);