Status D dynamic libs?

Tom S h3r3tic at remove.mat.uni.torun.pl
Sat Apr 19 18:03:50 PDT 2008


The problem with windows DLLs is that they don't support partial linking 
( or how it was called ). That is, you can't have undefined symbols in a 
DLL. What does it mean for an average D program? Each DLL will have to 
contain all symbols that it imports (uses). So multiple std-libs, 
multiple ClassInfos for the same classes, multiple globals. Unless these 
are somehow magically matched at runtime, you'll be in serious trouble. 
E.g. casting an object returned from a DLL to Object will return null. 
The ClassInfo in DLL and the host will be different objects, thus 
failing at the cast. This may be worked around (to some extent), e.g. by 
walking the rtti manually and comparing class names, doing casting thru 
void* pointers...

Still, exceptions bork for the same reason. Whatever is being thrown, 
it's converted to the type being caught, thus exception handling will 
fail really badly across binary boundaries. And IIRC, really badly == 
instant crash at an exception being thrown inside a DLL.

More info on DLLs and D: http://dsource.org/forums/viewtopic.php?t=677 
it's quite old but describes the problems and highlights why DDL was 
conceived.

DDL on the other hand, provides pretty much the functionality that .SO 
on Unix do (plus introspection of the loaded modules), thus allowing 
partial linking. Everything 'just works' since the undefined symbols 
will be taken from the host application, thus globals, typeinfo and 
whatnot will be shared between the host and the plugins.

DDL is not being actively maintained because Eric is currently busy with 
other stuff, mainly due to rand() real life events.
Last time I checked, DDL compiled with Tango and the basic examples worked.

DDL only works with DMD-win though. As for GDC on MSYS, someone might 
try binding EDLL: http://edll.sourceforge.net/, porting it to work with 
DDL's interface or helping Gregor's WinELF: 
http://svn.berlios.de/svnroot/repos/crosslibc/other/winelf/

Hope this info is useful :) Cheers!


-- 
Tomasz Stachowiak
http://h3.team0xf.com/
h3/h3r3tic on #D freenode



More information about the Digitalmars-d mailing list