Thread-local storage

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Thread-local storage

Eli Zaretskii
Is thread-local storage with the __thread qualifier supposed to work
in MinGW GCC?  Specifically, with GCC 4.9.3 built by Keith and using
Binutils 2.26 (that I built myself)?

I've built today the release candidate of libmpfr 3.1.4 with those
tools.  The configure script ran a test of TLS, which succeeded.
However, almost all the tests in the test suite failed.  Debugging
pointed to TLS (some per-thread variable got a zero value instead of a
positive one), so I rebuilt without TLS -- and the tests all passed.
The official MinGW port of an older version of libmpfr was built
without TLS (config.log in the source tarball indicates that the TLS
test failed when that port was built).

This library builds as a DLL.  I know about the gotchas with loading
DLLs that use TLS, but AFAIK this is only relevant to DLLs loaded with
LoadLibrary.  In the case in point, the DLL was loaded because the
test programs were linked against libmpfr.

Does anyone know if this feature is supposed to work?  If it is, is
there something special that a shared library should do beyond using
the __thread qualifier?  Does linking with static libgcc have any
influence on this?


Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:[hidden email]?subject=unsubscribe