<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>I am in a simillar situation in regards to Windows, but Linux & OS X TLS seems to work.</p>
<p></p>
<div><span style="font-size: 12pt;">Is there any reason or example you have of TLS not working in Linux?</span><span style="font-size: 12pt;"> </span></div>
<div><span style="font-size: 12pt;"><br>
</span></div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of Bastian Hossbach via llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Sent:</b> Wednesday, March 8, 2017 10:59 AM<br>
<b>To:</b> llvm-dev@lists.llvm.org<br>
<b>Subject:</b> [llvm-dev] Emulated TLS on x86_64 (Linux) with the JIT engine</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Hi,<br>
<br>
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:<br>
<br>
void jit(llvm::Module *module) {<br>
TargetOptions opts;<br>
opts.EmulatedTLS = 1;<br>
string err_str;<br>
ExecutionEngine *engine = EngineBuilder(unique_ptr<llvm::Module>(module))<br>
.setTargetOptions(opts)<br>
.setErrorStr(&err_str)<br>
.setEngineKind(EngineKind::JIT)<br>
.setMCJITMemoryManager(std::unique_ptr<SectionMemoryManager>(new SectionMemoryManager()))<br>
.setOptLevel(CodeGenOpt::Level::Aggressive)<br>
.create(); <br>
engine->finalizeObject();<br>
...<br>
}<br>
<br>
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().<br>
<br>
Am I missing something? Is emulated TLS even supposed to work with the JIT enigne on x86_64?<br>
<br>
Thanks in advance,<br>
Bastian<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
llvm-dev@lists.llvm.org<br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" id="LPlnk421351" previewremoved="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</div>
</span></font></div>
</div>
</body>
</html>