--emulated-tls explanation?

Denis Feklushkin feklushkin.denis at gmail.com
Tue Oct 13 10:35:57 UTC 2020

On Tuesday, 13 October 2020 at 10:25:35 UTC, IGotD- wrote:
> 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.

So, compiler knows what this platform is not supports 
multithreading and does some things wrong with thread static 
variables if "--emulated-tls" is ommited?

> The variables are dynamically allocated using the C library 
> memory allocation functions.

As I understand, variables allocated by compiler, but it uses 
internal implict call to __tls_get_addr to provide access to them.

More information about the digitalmars-d-ldc mailing list