Windows JIT-Client and Emulated TLS

Hello LLVM-World,

yeah… It’s me again and still with the never ending (but cool) task of jitting BC files under windows.

My setup is: LLVM 7.0.0, with the corresponding Clang, Visual Studio 2017 (Clang integrated via “vix” installer) and my target is also windows x64.

I create BC files with clang-cl and have currently a new test code, which has a static variable inside a lambda function. This lambda function returns the address of this said variable.

As mention this code is compiled with clang-cl for windows in 64bit, generating a BC file.

When loading this file with my JIT-Client I get some undefined references which I could resolve - besides from two:

“__emutls_get_address” and “” (xyz is just a place holder - don’t remember what was written there)

I tried researching a bit and… I think this functions are related to emulating TLS?

So I look into the IR file but noticed that these function where not mentioned there. So I assumed they must be created by the JIT process, so I went there and looked for my “llvm::TargetOptions” and set these values explicit:

options.ThreadModel = llvm::ThreadModel::Single;

options.EmulatedTLS = false;

options.ExplicitEmulatedTLS = false;

Sadly this didn’t changed a thing… Also setting “-Xclang -fno-emulated-tls” didn’t worked, only setting the MSVC switch “/Zc:threadSafeInit-” helped but… obviously disabled TLS at all.

What options do I have? I found an implementation for “__emutls_get_address” in compiler-rt but no explanation what I should do with these “__emutls_v.”-functions. Further, can’t I just disable emulated-tls? My JIT-Client seemed to have ignored my wish…

I hope someone can help me with that :0

I’m still a beginner so… sorry for this question

Kind greetings and thank you


                                options.EmulatedTLS = false;
                                options.ExplicitEmulatedTLS = false;

It looks like you'll need to set ExplicitEmulatedTLS to true, in order
to say "I am making an explicit choice about options.EmulatedTLS":

That sadly didn't helped... the functions are still generated...