Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22037

Force GCC/Clang to always issue a call to __tls_get_addr

$
0
0

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 used %fs).

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

Compiling with -fpic or -fpie doesn't seem to work, neither does futzing around with extern or volatile. Also, I understand that this will cause performance degradation, please refrain from asking me to justify my reasons behind this question.


Viewing all articles
Browse latest Browse all 22037

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>