Intended usage of _GLIBCXX_HAVE_TLS / emutls symbols on OSX

Iain Sandoe
Thu Jan 9 21:30:00 GMT 2020

Hello Dave,

For GCC on OSX, at present, TLS is only supported via emuTLS.

Dave Gittins <> wrote:

> Update: I believe this is resolved by adding -lgcc_s.1 to the build
> command. (gcc does this automatically)

This is correct - the support for emulated TLS is in the shared libgcc.

> So in case anyone else runs into this, here is my working build
> command to build with clang on OSX against the gcc 7.5 std lib:
> usr/local/Cellar/llvm@7/7.1.0_1/bin/clang++ -isystem
> /usr/local/Cellar/gcc@7/7.5.0/include/c++/7.5.0 -isystem
> /usr/local/Cellar/gcc@7/7.5.0/include/c++/7.5.0/x86_64-apple-darwin18.7.0
> -isystem /usr/local/Cellar/gcc@7/7.5.0/include/c++/7.5.0/backward -L
> /usr/local/Cellar/gcc@7/7.5.0/lib/gcc/7 -nostdinc++ -stdlib=libstdc++
> -std=c++17  -femulated-tls -lgcc_s.1 example.cpp -o example

> I would still like to know whether the change to _GLIBCXX_HAVE_TLS was
> intentional, though.

GCC on OSX has had emulated TLS since it was introduced (sometime in 4.x
IIRC) so I suppose one might argue that recognising the support is a fixed  

However, at this moment, I don’t recall any specific change that was  
at this, so will do some review locally.

will reply here if there’s anything useful to add after that review,

More information about the Gcc-help mailing list