[llvm-dev] Emulated TLS on x86_64 (Linux) with the JIT engine
Frederich Munch via llvm-dev
llvm-dev at lists.llvm.org
Wed Mar 8 09:48:41 PST 2017
I am in a simillar situation in regards to Windows, but Linux & OS X TLS seems to work.
Is there any reason or example you have of TLS not working in Linux?
________________________________
From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Bastian Hossbach via llvm-dev <llvm-dev at lists.llvm.org>
Sent: Wednesday, March 8, 2017 10:59 AM
To: llvm-dev at lists.llvm.org
Subject: [llvm-dev] Emulated TLS on x86_64 (Linux) with the JIT engine
Hi,
I'm trying to JIT-compile a part of an application at runtime using LLVM 3.9.1. The piece of code I want to JIT-compile accesses TLS variables and has been compiled offline into a bitcode file via clang 3.9.1. At runtime, that bitcode file gets loaded into a module. The module then gets passed to the following function:
void jit(llvm::Module *module) {
TargetOptions opts;
opts.EmulatedTLS = 1;
string err_str;
ExecutionEngine *engine = EngineBuilder(unique_ptr<llvm::Module>(module))
.setTargetOptions(opts)
.setErrorStr(&err_str)
.setEngineKind(EngineKind::JIT)
.setMCJITMemoryManager(std::unique_ptr<SectionMemoryManager>(new SectionMemoryManager()))
.setOptLevel(CodeGenOpt::Level::Aggressive)
.create();
engine->finalizeObject();
...
}
I already figured out that TLS on x86_64 is not supported and crashes with a corresponding LLVM error. So I switched to emulated TLS. However, this results in a new LLVM error "LLVM ERROR: Program used external function '__emutls_v.xyz_' which could not be resolved!" where xyz is one of the TLS variables. If I'm correct, all those __emutls_v variables should get replaced by invokations of __emutls_get_address().
Am I missing something? Is emulated TLS even supposed to work with the JIT enigne on x86_64?
Thanks in advance,
Bastian
_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170308/e01ecd0b/attachment.html>
More information about the llvm-dev
mailing list