shared libs for OSX

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Mon May 25 23:28:14 PDT 2015


On 2015-05-25 22:58, Martin Nowak wrote:
> On Monday, 25 May 2015 at 19:40:52 UTC, bitwise wrote:
>> 1) _dyld_register_func_for_add_image should be taken care of with the
>> above two fixes
>
> You still cannot unregister the callback, so it can't be used for
> dynamically loading druntime. Last time we talked about this problem, we
> found some undocumented function that could be deregistered.
>
>> 2) __attribute__((constructor/destructor)) can be added to druntime
>> when building for osx like in the file dylib_fixes.c [1]
>
> For linux we let the compiler emit comdat constructors into every D
> object, so you'll end up with exactly a single function for any binary
> containing D code.
> I don't think you need ctors/dtors on OSX if you already have the dylib
> callback.

I'm not sure if there is any other solution. There is one private 
function, "dyld_register_image_state_change_handler", that should work. 
I think it works because the image is never unloaded. I have not seen 
any function for deregistering a callback, private or public.

Isn't it better to avoid private undocumented functions?

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list