Help with legacy-support

Ken Cunningham ken.cunningham.webuse at gmail.com
Sun May 2 05:18:31 UTC 2021


thread_local storage on MacOS is handled by dyld and uses and Apple-specific implementation that came into being in 10.7.

The thread_local infrastructure uses symbols that start with “_tlv_*”.

See here for details:

https://github.com/apple-opensource/dyld/blob/b6b86eb2db14440d373f6f7fd21be4a2bc0da897/src/threadLocalVariables.c <https://github.com/apple-opensource/dyld/blob/b6b86eb2db14440d373f6f7fd21be4a2bc0da897/src/threadLocalVariables.c>


On < 10.6 I have implemented the “emulated_tls” infrastructure that systems without OS implemented TLS use. 

This is what gcc uses on every macOS system from 10.4 to BigSur.

The variables have different names, cxa_thread_*.

They normally live in libc on Linux, but I added them the libcxxabi using their mechanism for doing that on systems other than Apple.

To make that change, I added a small test and switch the implementation here:

https://github.com/macports/macports-ports/blob/19157729c2b2081d3434eca941440846ef8b796d/lang/llvm-9.0/files/9000-patch-clang-7.0-support-emulated-tls.diff#L23 <https://github.com/macports/macports-ports/blob/19157729c2b2081d3434eca941440846ef8b796d/lang/llvm-9.0/files/9000-patch-clang-7.0-support-emulated-tls.diff#L23>


I have pondered making some “work-alike” functions with the Apple names “tlv_init” etc, so the links would work, and then making perhaps the tlv_* functions call the cxa_thread_* functions, but I just never got around to it.

It might be do-able. Or we might do better to figure out how to make rust use the cxa_thread_* functions instead; probably, it already can. rust is backended by llvm, and we’ve already sorted out how to make llvm do this.

Stay in touch!

Ken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-dev/attachments/20210501/9e303d63/attachment-0001.htm>


More information about the macports-dev mailing list