We have a makefile with targets that execute the daml compiler in incremental mode.
I’ve noticed that sometimes, without having changed anything, a recompile is triggered. Other times it’s not.
I’m curious to know what triggers this. I’m assuming it’s not the make rules (I’ll double check this though).
I suspect it may be
.swp files created by my text editor or something similar. How does damlc decide when something has ‘changed’ and a modules needs to be recompiled?
How do you check that it rebuilds? I suspect that it is probably your makefile here since damlc always rebuilds some parts even in incremental build so if you observed no rebuilds, it was probably your makefile that didn’t invoke damlc.
Let me give a summary of how incremental builds work in damlc at the moment:
Typechecking and generating DAML-LF are two of the more expensive parts of compilation. Therefore, we persist the result of those two steps to disk. When you build again, we check for each file if either file itself changed or the ABI of any of its dependencies changed (if the type stays the same but the implementation has changed, the ABI is still the same since we do not do cross-module optimizations in incremental mode).
If there was no change we reuse the artifacts persisted to disk, if there was a change we typecheck again and generate new DAML-LF.
At the end, the DAML-LF for the individual modules is assembled into a new DAR and we write that to disk. This happens even if no modules changed so the DAR will always be written out again. It would be possible to optimize this case and not do anything but we didn’t optimize for that case so far (it is fairly easy to just not call
daml build if you didn’t change anything).
Compiling xxx to a DAR., and there is a noticeable pause when I run our test framework. But what you’ve explained above sounds reasonable. Then it’s probably just
make checking for changes, as you’ve said.
You will always see
Compiling xxx to a DAR if you invoke
daml build so if you didn’t see it, make didn’t invoke