Skip to content

Commit

Permalink
Match declarations of at_quick_exit and __cxa_atexit symbols for libc…
Browse files Browse the repository at this point in the history
…++ and C++17

On Linux, the same adjustments are needed as for libstdc++ and libc++,
so turn the condition into just #ifdef __linux__. However, since the
__cxa_atexit function is declared as extern "C" in libc++, we cannot
add "noexcept" to it, as is done for libstdc++.
  • Loading branch information
amadio committed Dec 9, 2017
1 parent 1b7aa57 commit 2a30661
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions interpreter/cling/lib/Interpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ namespace cling {
if (auto M = T->getModule()) {
for (const llvm::StringRef& Sym : Syms) {
const llvm::GlobalValue* GV = M->getNamedValue(Sym);
#if defined(__GLIBCXX__) && !defined(__APPLE__)
#if defined(__linux__)
// libstdc++ mangles at_quick_exit on Linux when g++ < 5
if (!GV && Sym.equals("at_quick_exit"))
GV = M->getNamedValue("_Z13at_quick_exitPFvvE");
Expand Down Expand Up @@ -404,13 +404,17 @@ namespace cling {

// Intercept all atexit calls, as the Interpreter and functions will be long
// gone when the -native- versions invoke them.
#if defined(__GLIBCXX__) && !defined(__APPLE__)
#if defined(__linux__)
const char* LinkageCxx = "extern \"C++\"";
const char* Attr = LangOpts.CPlusPlus ? " throw () " : "";
const char* cxa_atexit_is_noexcept = LangOpts.CPlusPlus ? " noexcept" : "";
#else
const char* LinkageCxx = Linkage;
const char* Attr = "";
#endif

#if defined(__GLIBCXX__)
const char* cxa_atexit_is_noexcept = LangOpts.CPlusPlus ? " noexcept" : "";
#else
const char* cxa_atexit_is_noexcept = "";
#endif

Expand Down

0 comments on commit 2a30661

Please sign in to comment.