--emulated-tls explanation?

IGotD- nise at nise.com
Tue Oct 13 10:25:35 UTC 2020


On Tuesday, 13 October 2020 at 09:32:07 UTC, Denis Feklushkin 
wrote:
> Hi!
>
> Can anyone explain what "--emulated-tls" actually do?
>
> It solves my problem with correct static variables placement on 
> ARM Cortex M3, but I don't know why.

I think it is a compatibility layer that GCC provides. Instead of 
implementing everything yourself from scratch, GCC provide a 
framework and a set of hooks you should implement.

http://www.chiark.greenend.org.uk/doc/gcc-4.9-doc/gccint.html#Emulated-TLS

It seems like GCC provides default hooks, so for example if 
threading is not enabled this TLS emulation layer is probably 
pretty stupid and do not know what a thread is. The variables are 
dynamically allocated using the C library memory allocation 
functions.

In practice you should read about the Runtime ABI for the ARM 
architecture, how TLS is implemented for ARM. For a custom system 
you have all the degrees of freedom and can do what you want and 
is usually better. ARM and GCC also offers several options how to 
implement it, static version, dynamic version, a mix, use thread 
pointer register, use a function for retrieval etc.







More information about the digitalmars-d-ldc mailing list