Skip to content

[RFC] Order-only dependencies #5514

@snowleopard

Description

@snowleopard

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 using gcc with the flags -MMD -MF to 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 ocamldep to 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.

Metadata

Metadata

Assignees

Labels

proposalRFC's that are awaiting discussion to be accepted or rejected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions