# What triggers damlc rebuilds?

**URL:** <https://forum.canton.network/t/what-triggers-damlc-rebuilds/1013>\
**Category:** App Development\
**Tags:** damlc\
**Created:** [August 11, 2020, 6:53am UTC](https://forum.canton.network/t/what-triggers-damlc-rebuilds/1013 "2020-08-11T06:53:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luciano](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/luciano/32/319_2.png) [@Luciano](https://forum.canton.network/u/Luciano)\
**Post date:** [August 11, 2020, 6:53am UTC](https://forum.canton.network/t/what-triggers-damlc-rebuilds/1013/1 "2020-08-11T06:53:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [August 11, 2020, 7:21am UTC](https://forum.canton.network/t/what-triggers-damlc-rebuilds/1013/2 "2020-08-11T07:21:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Luciano](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/luciano/32/319_2.png) [@Luciano](https://forum.canton.network/u/Luciano)\
**Post date:** [August 11, 2020, 7:59am UTC](https://forum.canton.network/t/what-triggers-damlc-rebuilds/1013/3 "2020-08-11T07:59:41Z")

</div>

> [@cocreature](#):
>
> How do you check that it rebuilds?

I see `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.

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [August 11, 2020, 8:03am UTC](https://forum.canton.network/t/what-triggers-damlc-rebuilds/1013/4 "2020-08-11T08:03:44Z")

</div>

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