From 7390550dfe406b7e513995ccc4e80896dd7fe2bc Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Sun, 23 Mar 2014 21:08:48 +0100 Subject: [PATCH] Add comment explaining (part of) the bootstrap sequencing. --- lib/Interpreter/IncrementalParser.cpp | 5 ++++- lib/Interpreter/Interpreter.cpp | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) 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);