www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DLL on LDC

Hi,

I am trying to create a simple DLL and a simple app that loads it 
on Linux with end goal of having it work on MacOS.

Everything seems to work fine with DMD, but when I use LDC2 to 
build the loader, I don't get the `shared static this()` and 
`~this` called when I `dlopen()` and `dlclose()` my DLL. I am 
opening with RDLD_NOW. I am a bit surprised that the issue is in 
the loader, but it appears to be the case. I am building both 
with `dub --compiler=ldc2`, an the DLL has `targetType 
dynamicLibrary` in the dub.sdl, do I need to pass some extra 
flags for dub or LDC2? Is it doable at all?

When I build with DMD I am getting a seg fault during `rt_term()` 
at exit, at `__GI___pthread_mutex_destroy`, which makes it seem 
like it's not really working that well.

As I understood it, LDC2 is the furthest ahead in terms of DLL 
support on MacOS. Is this the case?

Does anyone have some insights or working setup they are willing 
to share? :)

Thanks in advance for any help!
Nov 11 2019