The configure script from http://pixman.org library tries to check whether to use __thread or __declspec(thread) for TLS by compiling a small test program (basically a single line "int __declspec(thread) x;") and checking whether the compiler accepts it. The result with mingw-w64 is the following:
configure:13768: x86_64-w64-mingw32-gcc -c -g -O2 -Wall -fno-strict-aliasing conftest.c >&5
conftest.c:40:1: warning: 'thread' attribute directive ignored
configure:13768: $? = 0
configure:13776: result: __declspec(thread)
Because __declspec(thread) results in just a warning and not a compilation failure, the configure script thinks that __declspec(thread) is supported and happens to select it. You can find more details at https://bugs.freedesktop.org/show_bug.cgi?id=57591
Would it possible to promote this from a warning to an error? Or just alias __declspec(thread) to __thread? The current behaviour can be workarounded by changing the order of checks for __thread and __declspec(thread), but it is fragile and leaves little safety margin. Just imagine some other compiler doing something similar with the __thread keyword and we are in a real trouble.
Log in to post a comment.