DMD front-end can be used as a library with Dub

Cauterite via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 1 09:16:57 PDT 2016


On Monday, 29 August 2016 at 10:42:23 UTC, Alexander Breckel 
wrote:
>

Because of the poor memory management in the compiler, I included 
a modified GC-stub when I compiled the frontend as a library, so 
that it can be used in long-running processes:

https://gist.github.com/Cauterite/4eb74347aea040f5d371fb49054e1819

You can call gc_annihilate(true) to delete the entire heap.

Obviously you need to keep the library in a separate DLL with its 
own runtime, and carefully avoid holding references to GC memory 
across annihilations.

This technique is working pretty smoothly for me so far.

Also to compile it as a DLL you either have to remove main() from 
mars.d or play games with the C runtime: 
https://gist.github.com/Cauterite/b190e62891c773703d0de3a1d99df362


More information about the Digitalmars-d mailing list