Skip to content

cling PR 169 #745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions interpreter/cling/lib/Interpreter/IncrementalExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ IncrementalExecutor::IncrementalExecutor(clang::DiagnosticsEngine& diags,
m_AtExitFuncs.reserve(256);

std::unique_ptr<TargetMachine> TM(CreateHostTargetMachine(CI));

TM->Options.EmulatedTLS = 1;

m_BackendPasses.reset(new BackendPasses(CI.getCodeGenOpts(),
CI.getTargetOpts(),
CI.getLangOpts(),
Expand Down
12 changes: 12 additions & 0 deletions interpreter/cling/lib/Interpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@

using namespace clang;

extern "C" void* __emutls_get_address(struct __emutls_control*);

namespace {

// Forward cxa_atexit for global d'tors.
Expand Down Expand Up @@ -267,6 +269,16 @@ namespace cling {
}
}
}
#ifdef LLVM_ON_WIN32
// FIXME: Using emulated TLS LLVM doesn't respect external TLS data.
// By passing itself as the argument to __emutls_get_address, it can
// return a pointer to the current thread's _Init_thread_epoch.
// This obviously handles only one case, and would need to be rethought
// to properly support extern __declspec(thread), though hopefully that
// construct is dubious enough to never be used .
m_Executor->addSymbol("__emutls_v._Init_thread_epoch",
utils::FunctionToVoidPtr(&__emutls_get_address), true);
#endif
}

// Disable suggestions for ROOT
Expand Down
1 change: 1 addition & 0 deletions interpreter/cling/lib/Utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ endif()
add_cling_library(clingUtils OBJECT
AST.cpp
Diagnostics.cpp
EmuTLS.cpp
ParserStateRAII.cpp
Output.cpp
Paths.cpp
Expand Down
Loading