Why does Apple clang disallow C++11 thread_local when 'official' clang supports it

The clang compiler included with Xcode 8 and later supports the C++11 thread_local keyword. This functionality was added to the Xcode 8 beta as discussed in the WWDC 2016 video "What's New in LLVM", beginning at the 5:50 mark. (external transcript)

The sample program listed in the question compiles and runs with Xcode 8 GM under OS X 10.11.6 and produces the intended output. It has subsequently been re-tested with Xcode 9.3 under macOS 10.13.4, and with Xcode 10.2.1 under macOS 10.14.4, and continues to behave as intended.

Regarding iOS, I found by experimentation that thread_local is supported for iOS 9 and later, but not for iOS 8.4 or earlier.


For Xcode 7.x and earlier, here is an answer from 2014 from an Apple engineer on the old Apple Developer Forum (no longer accessible):

We don't support the thread_local implementation from the open-source Clang because we believe we can provide a higher-performance implementation for our platforms using various features in the dynamic linker. Such an implementation would be ABI-incompatible with the implementation in the open-source Clang, so we won't support thread_local until we get an implementation we can live with for the foreseeable future.

A subsequent post confirms that thread_local is still not supported in Xcode 6.3.

Tags:

Xcode

C++11

Clang