On Wed, Feb 26, 2014 at 1:20 PM, Adam D. Ruppe <destructionator@gmail.com> wrote:
Try compiling your library with -defaultlib= (leaving it blank after the equal sign). Then it might work by not loading the symbols for phobos etc twice - they will only be linked into the main program.

Thanks, but I don't see how that would help treating the D dll as a standalone library with its own GC/druntime etc. Once again, I'm doing runtime loading (via dlopen+friends) not load-time linking (via -L-lfoo compile flags).

Furthermore, the following:
dmd -oflibfoo.dylib -shared -defaultlib= foo.d 
results in link errors (because of '-defaultlib= ')

and I also tried:
dmd -offoo.o -c foo.d 
gcc foo.o -shared -o libfoo.dylib -Wl,-flat_namespace -Wl,-undefined -Wl,suppress

followed by runtime loading it in a D program (via dlopen) but not surprisingly this crashes.