[llvm-dev] How to use thread local storage with ORC JIT?

Lang Hames via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 11 10:52:38 PST 2021


>
> In your 15 February email you said you tried that and it didn't help...?
>
> >Ohhh right!
> I did try it…. Thanks for the reminder >o<


I think you will need to compile both the JIT'd code and the executor
process with -femulated-tls and include at least one thread-local in the
executor in order for this to work: If you only compile your JIT'd code
with -femulated-tls then you'll have a reference to __emutls_get_address as
you've seen, but no definition for it. That symbol would usually be pulled
in from compiler-rt by the static linker, but you're running under the JIT.
Your two options are to either add compiler-rt to your JIT (this is
untested on Windows, and consequently risky), or to compile your executor
with -femulated-tls and include at least one thread local in it -- this
will force the static linker to compile __emutls_get_address into your
executor (lower risk, but may not work if __emutls_get_address is marked
non-exported from compiler-rt).

-- Lang.

On Wed, Mar 3, 2021 at 5:15 AM Gaier, Bjoern <Bjoern.Gaier at horiba.com>
wrote:

> Ohhh right!
> I did try it…. Thanks for the reminder >o<
>
>
>
> *From:* Geoff Levner <glevner at gmail.com>
> *Sent:* 03 March 2021 10:02
> *To:* Gaier, Bjoern <Bjoern.Gaier at horiba.com>
> *Cc:* Lang Hames <lhames at gmail.com>; David Blaikie <dblaikie at gmail.com>;
> LLVM Developers Mailing List <llvm-dev at lists.llvm.org>
> *Subject:* Re: [llvm-dev] How to use thread local storage with ORC JIT?
>
>
>
> Bjoern,
>
>
>
> In your 15 February email you said you tried that and it didn't help...?
>
>
>
> Geoff
>
>
>
> On Wed, Mar 3, 2021 at 8:24 AM Gaier, Bjoern via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
> Hey Lang,
>
>
>
> I can’t remember anymore but I think I haven’t tried with -femulated-tls.
>
> <snip>
>
> Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
> USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert
> Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210311/2a7cd2a4/attachment.html>


More information about the llvm-dev mailing list