Does clang++ do threadsafe initialisation of local static variables?
GCC does, unless you turn it off with the misleadingly named -fno-threadsafe-statics.
I'm using Apple clang version 2.0 (tags/Apple/clang-139) (based on LLVM 2.9svn).
Yes, same as with GCC (so can also be turned off with -fno-threadsafe-statics)
Yes, although Apple's libcppabi implements this in a suboptimal way: with a global mutex which harms performance if many threads are using many local statics.
Source code: http://www.opensource.apple.com/source/libcppabi/libcppabi-26/src/cxa_guard.cxx
Bug report: https://bugreports.qt.io/browse/QTBUG-33967 (which led Qt to implement this differently when libcppabi is used).
I hope making more people aware of this will result in Apple fixing their code one day...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With