[D-runtime] DLL initialization in Druntime

Sean Kelly sean at invisibleduck.org
Tue Jan 18 11:51:04 PST 2011

On Jan 18, 2011, at 11:37 AM, Rainer Schuetze wrote:

> Sean Kelly wrote:
>> The unfortunate part is that this isn't necessary when using Runtime.loadLibrary(), since that will do the right thing.  It would only be necessary for a non-D hosting app.  I guess if it has an "already ran" flag in it then the library writer could have his init_my_lib() routine call it instead.  *sigh*  No automatic alternatives, huh?
> What about creating a DLL that just contains the GC and exports the proxy pointer? Any DLL/EXE that wants to use the shared GC links against the import library of this DLL and sets its proxy pointer before any other initialisation.
> In case of multi threading, a bit more needs to done to forward TLS ranges to the proxy. But this will probably not work anyway, because the threads also need to be shared.
> So, better create a druntime.dll/phobos.dll to share everything...

A druntime/phobos DLL would be a clean way to handle this, though shared libraries complicate distribution of user code.  Although, didn't Visual Studio eliminate the option of statically linking its runtime library?  We'd still need a reasonable short-term solution though.  I don't even know what would be required to ship druntime/phobos in a DLL, but I'm guessing it's more than a few simple changes.  We'd probably need export labels all over the place, etc, right?

More information about the D-runtime mailing list