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

Walter Bright newshound2 at digitalmars.com
Thu Nov 19 02:17:43 UTC 2026


On 11/17/2026 3:55 PM, David Given wrote:
> - 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.

Of course. How else could it work?

> - .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.

Is there an issue filed for that?

> - 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.

That's the point of .di files. Regarding auto functions, there's no way the 
compiler can deduce what auto means without the source code for the auto function.

> (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.)

Can you be more specific?

> 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.

Once a program gets large enough, .di files are needed (analogously to the need 
for .h files in C).

dmd is compiled with one command.



More information about the Digitalmars-d mailing list