Hello,

From what I understand, if I have some code that contains a _Thread_local 
variable, and I compile it to a shared library, then all accesses to the 
variable go through __tls_get_addr(). However, if I compile it to a static 
library, the access happens without that function (on x64, it uses %fs). 

My question is: how can I force Clang to use __tls_get_addr() even in static 
libraries? 

Compiling with `-fpic`, `-fpie` or `-ftls-model=global-dynamic` doesn't seem to 
work, neither does futzing around with extern or volatile. Also, I understand 
that this will cause performance degradation.

For reference, here (https://pastebin.com/raw/xUZyAk2h) is the code generated 
when compiling as Static Library, and here (https://pastebin.com/raw/9Ys6Ey60) 
is the same with a Shared Library.

- Naman Dixit
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to