Thread overview
Article on incremental compilation
Apr 22, 2023
Zachary Yedidia
Apr 23, 2023
Zachary Yedidia
April 22, 2023

Hi everyone,

I've been tinkering with setting up incremental compilation in my D projects by using .di files to ensure that a module is only recompiled if its interface changes (not its implementation). I've written an article about it here: https://zyedidia.github.io/blog/posts/4-incremental-d-knit/. Hopefully you find it interesting! Thanks!

April 23, 2023

On 4/22/23 7:33 PM, Zachary Yedidia wrote:

>

Hi everyone,

I've been tinkering with setting up incremental compilation in my D projects by using .di files to ensure that a module is only recompiled if its interface changes (not its implementation). I've written an article about it here: https://zyedidia.github.io/blog/posts/4-incremental-d-knit/. Hopefully you find it interesting! Thanks!

Nice! Your build system sounds pretty cool.

On your section on "Areas for improvements in D interface files":

The previous section holds the answer -- templates. Templates must be included in full because they are instantiated by the caller. But a template can still use:

  • private variables/functions
  • private types
  • private imports

etc. Basically anything that can be used in the implementation. The only thing that's hidden is non-template function implementations.

In order to avoid copying those things, the compiler would have to prove that no template inside the module can use these things.

One possible mechanism could be if no templates exist, it could exclude them. But to determine whether an existing template might use them, I believe is the halting problem.

So we are stuck with it.

-Steve

April 23, 2023

Ah I see, that makes sense. I'll add an edit about that. Thanks for the explanation!