shared libraries on OS X

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 14 07:26:05 PST 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.


More information about the Digitalmars-d mailing list