Ken Cunningham via llvm-dev
2018-Dec-10 06:52 UTC
[llvm-dev] using emulated-tls on Darwin 8, 9, 10
On 2018-12-08, at 2:27 PM, Ken Cunningham wrote:> And then we should be in business, and all systems will have thread_local .All that being sorted out, we now have libc++ 7.0.0 and libc++abi built and being used with emulated-tls support on darwin < 11 now. Thanks! The last bit of this I plan to sort out would be how to tweak the following patch so that __cxa_thread_atexit would be called based on the -femulated-tls flag rather than based on the MacOSXVersion. That way emulated-tls could be used/tested on any OS version. -- Ken =========================--- a/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp.orig 2018-10-02 18:31:17.000000000 -0700 +++ b/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp 2018-10-02 18:32:35.000000000 -0700 @@ -2255,7 +2255,7 @@ const char *Name = "__cxa_atexit"; if (TLS) { const llvm::Triple &T = CGF.getTarget().getTriple(); - Name = T.isOSDarwin() ? "_tlv_atexit" : "__cxa_thread_atexit"; + Name = (T.isOSDarwin() && !T.isMacOSXVersionLT(10, 7)) ? "_tlv_atexit" : "__cxa_thread_atexit"; }
Jacob Carlborg via llvm-dev
2018-Dec-10 10:43 UTC
[llvm-dev] using emulated-tls on Darwin 8, 9, 10
On 2018-12-10 07:52, Ken Cunningham via llvm-dev wrote:> All that being sorted out, we now have libc++ 7.0.0 and libc++abi built and being used with emulated-tls support on darwin < 11 now. Thanks!Cool. BTW, what about TLS in C, i.e. "__thread"? -- /Jacob Carlborg
Ken Cunningham via llvm-dev
2018-Dec-10 16:29 UTC
[llvm-dev] using emulated-tls on Darwin 8, 9, 10
On 2018-12-10, at 2:43 AM, Jacob Carlborg via llvm-dev wrote:> On 2018-12-10 07:52, Ken Cunningham via llvm-dev wrote: > >> All that being sorted out, we now have libc++ 7.0.0 and libc++abi built and being used with emulated-tls support on darwin < 11 now. Thanks! > > Cool. BTW, what about TLS in C, i.e. "__thread"? >Yes, the various tests I've tried with this pass. I am a hobbyist, not a professional programmer, so it's possible I'm missing some aspect of the TLS coverage or the implementation. The darwin code in llvm generally assumes tlv_atexit for TLS, and I might be overlooking some detail that I haven't as yet discovered. I wonder if there is any appetite to have darwin support the -femulated-tls flag in general, for testing the subsystems, etc. Right now if you use the flag, you still get tlv_atexit in the end. I should be able to find a way to test if femulated-tls is set while in the scope of CodeGen/ItaniumCXXABI.cpp and branch on the flag to cxa_thread_atexit -- and if I sort that out, a general implementation would appear workable. Ken