Jacob Carlborg via llvm-dev
2018-Dec-08 19:51 UTC
[llvm-dev] using emulated-tls on Darwin 8, 9, 10
On 2018-12-08 19:10, Ken Cunningham via llvm-dev wrote:> So putting it into libc++abi.dylib might indeed be the only workable method, assuming each executable would get it's own copy in memory and they wouldn't all collide together.Can ibc++abi link with libclang_rt to resolve the symbol? -- /Jacob Carlborg
Ken Cunningham via llvm-dev
2018-Dec-08 22:27 UTC
[llvm-dev] using emulated-tls on Darwin 8, 9, 10
On 2018-12-08, at 11:51 AM, Jacob Carlborg via llvm-dev wrote:> On 2018-12-08 19:10, Ken Cunningham via llvm-dev wrote: > >> So putting it into libc++abi.dylib might indeed be the only workable method, assuming each executable would get it's own copy in memory and they wouldn't all collide together. > > Can ibc++abi link with libclang_rt to resolve the symbol? >Thanks for the clue, and yes that led me to the answer. We are building libc++abi with nodefaultlibs . The emutls.o symbols indeed belong right in libc++abi, and I will either compile them in with emutls.c or link them in manually by adding that library. And then we should be in business, and all systems will have thread_local . Thanks for the hint. Ken
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"; }