-
Notifications
You must be signed in to change notification settings - Fork 470
[RFC] Order-only dependencies #5514
Description
It is sometimes useful to specify dependencies of a build action in two steps:
-
Before executing the action, specify the set of its possible dependencies P. The set P is used only for scheduling, i.e., everything in P must be built before running the action. Such dependencies are often called order-only dependencies.
-
After executing the action, specify the set of its actual dependencies A, where A must be a subset of P. These dependencies are used to determine when the action will need to be rebuilt.
Here are a couple of use-cases:
-
It is common to depend on all C headers in a project (i.e.
headers/*.h), to make sure they are up-to-date, and then compile C sources usinggccwith the flags-MMD -MFto obtain the set of actual headers that were needed for compilation. -
A recently discussed use-case in OCaml is to improve build incrementality with respect to library dependencies. For example, if a library B depends on a library A, we can use order-only dependencies to ensure that all modules of A have been built before compiling modules of B, and then use
ocamldepto find actual dependencies of each module of B, to avoid recompiling all B's modules whenever any module of A changes.
Order-only dependencies are not new, for example, the Shake build system provides orderOnly and needed primitives to specify order-only and actual dependencies, respectively. See Section 3.5 of this paper for more details.
For now, this RFC only describes the idea but I'll update it with more details after we figure out how to add this feature to Dune.