What's the current state of the art for module compilation?

David Given dg at cowlark.com
Tue Nov 17 23:55:16 UTC 2026


The last time I looked at D, its support for doing separate 
module compilation was a bit lacking. Is this still the case?

The summary of my possibly inaccurate understanding of the 
situation is:

- in order to use a module, the compiler needs access to the 
library (the compiled code), plus declarations. The declarations 
can be either .di files or the original .d source code.
- .di files are not to be trusted, as even though the compiler 
will generate them, it will silently break things like templates 
and functions which return auto.
- giving the compiler access to the original .d source code isn't 
ideal as it requires full parsing of the source code (which may 
need pulling in the whole transitive graph of dependencies), and 
which therefore rather defeats one of the main purposes of doing 
separate compilation.

(Also the compiler interface is a bit unfriendly as many of the 
paths for input and output artifacts are determine automatically 
by the compiler, meaning the build system isn't necessarily aware 
of them, but that can be worked around.)

Last time I asked about this, the recommendation was not to do 
separate compilation and just compile the whole program each time 
--- but this isn't a scaleable solution.

Is this still an issue?


More information about the Digitalmars-d mailing list