digitalmars.D - shared libraries on OS X
- John Colvin (6/6) Nov 11 2014 what's the status?
- Jacob Carlborg (11/17) Nov 11 2014 The first step would be to implement native TLS, see this issue [1]. The...
- Jacob Carlborg (7/8) Nov 11 2014 BTW, the reason to implement native TLS is because otherwise we need to
- Martin Nowak (3/7) Nov 14 2014 What's the situation of native TLS? Any docs?
- David Nadlinger (4/6) Nov 14 2014 10.7. And IMHO the most useful documentation for actually getting
- Jacob Carlborg (5/7) Nov 15 2014 There's also the source code for the compiler (Clang, LLVM) and the
- Sean Kelly (4/11) Nov 14 2014 We're two releases into having native support for TLS in OSX now,
- Jacob Carlborg (4/6) Nov 15 2014 There have been four releases of OS X which support TLS, 10.7-10.10.
- Martin Nowak (9/12) Nov 14 2014 Yes, you need a constructor and destructor in each shared library that
- Jacob Carlborg (4/7) Nov 15 2014 Right, I keep forgetting that.
what's the status? I tried building druntime with 'make -f posix.mak dll' and got src/rt/sections.d(52): Error: static assert (is(typeof(__error) == void* function())) is false I'd be happy to put in some work to improve the situation, but a brief overview of the status quo would be useful.
Nov 11 2014
On 2014-11-11 11:42, John Colvin wrote:what's the status? I tried building druntime with 'make -f posix.mak dll' and got src/rt/sections.d(52): Error: static assert (is(typeof(__error) == void* function())) is false I'd be happy to put in some work to improve the situation, but a brief overview of the status quo would be useful.The first step would be to implement native TLS, see this issue [1]. The next step that would probably be to look at the changes in druntime made for Linux to add support for shared libraries. I think a major part of that is in rt_sections.d or similar. There were some changes to the compiler as well, adding some hooks when a dynamic library is loaded. But that shouldn't be needed on OS X since the dynamic linker have native support for this. [1] https://issues.dlang.org/show_bug.cgi?id=9476 -- /Jacob Carlborg
Nov 11 2014
On 2014-11-11 15:05, Jacob Carlborg wrote:The first step would be to implement native TLS, see this issue [1].BTW, the reason to implement native TLS is because otherwise we need to implement basically what the dynamic linker is already doing for TLS our self. Since it would be nice to have native TLS support anyway I thought that was a better idea. -- /Jacob Carlborg
Nov 11 2014
On 11/11/2014 06:24 PM, Jacob Carlborg wrote:BTW, the reason to implement native TLS is because otherwise we need to implement basically what the dynamic linker is already doing for TLS our self. Since it would be nice to have native TLS support anyway I thought that was a better idea.What's the situation of native TLS? Any docs? What version of OSX is required?
Nov 14 2014
On Friday, 14 November 2014 at 15:22:45 UTC, Martin Nowak wrote:What's the situation of native TLS? Any docs? What version of OSX is required?10.7. And IMHO the most useful documentation for actually getting stuff done is the ld source code (opensource.apple.com). David
Nov 14 2014
On 2014-11-14 17:18, David Nadlinger wrote:10.7. And IMHO the most useful documentation for actually getting stuff done is the ld source code (opensource.apple.com).There's also the source code for the compiler (Clang, LLVM) and the dynamic linker (dyld). -- /Jacob Carlborg
Nov 15 2014
On Tuesday, 11 November 2014 at 17:24:31 UTC, Jacob Carlborg wrote:On 2014-11-11 15:05, Jacob Carlborg wrote:We're two releases into having native support for TLS in OSX now, so it probably is time to switch over.The first step would be to implement native TLS, see this issue [1].BTW, the reason to implement native TLS is because otherwise we need to implement basically what the dynamic linker is already doing for TLS our self. Since it would be nice to have native TLS support anyway I thought that was a better idea.
Nov 14 2014
On 2014-11-14 17:40, Sean Kelly wrote:We're two releases into having native support for TLS in OSX now, so it probably is time to switch over.There have been four releases of OS X which support TLS, 10.7-10.10. -- /Jacob Carlborg
Nov 15 2014
On 11/11/2014 03:05 PM, Jacob Carlborg wrote:There were some changes to the compiler as well, adding some hooks when a dynamic library is loaded. But that shouldn't be needed on OS X since the dynamic linker have native support for this.Yes, you need a constructor and destructor in each shared library that call into druntime to register all modules, EH handlers and such things. There is some Mach-O support to be notified (via a callback) when a new shared library is loaded. It wasn't possible to unset that callback though, meaning it would segfault when druntime itself is unloaded. So either we get this runtime linker stuff to work or we simply use __attribute__((constructor))/__attribute__((destructor)) functions like on linux.
Nov 14 2014
On 2014-11-14 16:26, Martin Nowak wrote:There is some Mach-O support to be notified (via a callback) when a new shared library is loaded. It wasn't possible to unset that callback though, meaning it would segfault when druntime itself is unloaded.Right, I keep forgetting that. -- /Jacob Carlborg
Nov 15 2014