-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dune always rebuilds all coq files as soon as any dependency changes #10149
Comments
Signed-off-by: Rodolphe Lepigre <rodolphe@bedrocksystems.com>
Thanks for the detailed bug report @Janno , I can reproduce in master. |
Did some tracing in the coq side of rules, everything seems fine on this side:
and after the edit, it becomes:
|
Yeah, we did check the output of |
Indeed, the API has been changing a lot and is not very documented, so I'm indeed unsure we can really do what we want in Coq easily (and I wonder why it worked before). The code looks too coupled in fact. Let me summarize what we are doing:
First, we add a rule to generate { listing of all source files } --[coqdep]--> { coq/.bug.theory.d } Then, we add the coqc rule, and indeed this could be problematic in the way we do it, the code looks like let get_dep_map dir wrapper_name : Path.t list Dep_map.t Action_builder.t =
let file = "$dir/.$wrapper_name.theory.d" in
let* lines = Action_builder.lines_of file in
build_map lines
let get_dep_map : (Dir.t * Coq_lib_name.t, Path.t list Dep_map.t) Action_builder.memo = ....
let deps_of file dir wrapper_name : unit Action_builder.t =
let* dep_map = Action_builder.exec_memo get_dep_map (dir, wrapper_name) in
let deps = Dep_map.find file in
Action_builder.paths deps So, indeed, this is an action that will be re-run when the coqdep file has a different hash, and the calculation of the map is now memoized (see recent bug that for sure impacted your zero-builds big time). But indeed I'm guessing that already the above code is adding the coqdep file as a hard dep to the full coqc action, as we do in the coqc rule: let deps_of = deps_of file ... in
Action_builder.with_no_targets deps_of >>> Command.run coqc args So indeed, this code admits the semantics we observe in this bug, where the coqc rule is triggered due to the dependency on the theory.d file. I am thinking how to workaround this, an obvious way, but still not satisfactory, is to produce a .v.d file for each file, from the map. This way, your coqdep update will rebuild all the I guess in order to implement the true incremental I'll let experts (cc @rgrinberg @snowleopard ) comment tho. |
I guess adding an extra memo node per file to keep the deps is fine. @rlepigre , in a sense what we need here is something like https://ocaml.org/p/incr_map/latest , but using [I didn't have time to look at |
Tried to implement the workaround of having one dep file per .v file, however I got a bit stuck on types: https://github.com/ejgallego/dune/tree/gen_dep_per_file Basically I forgot how to chain an I guess I'm too tired today to look into this more, feel free to take over. |
Indeed, I was a bit tired and didn't distinguish The branch is now functional, just needs a cleanup to be submitted as a PR; please test and report back. |
Signed-off-by: Rodolphe Lepigre <rodolphe@bedrocksystems.com>
I'm still quite puzzled about the commit you bisected tho. The change in semantics seems quite big if that's the case, tho I'd say that PR is more of bugfix then, for the semantics I have in mind. |
Thanks a lot @ejgallego, I'll have a look when I have a minute. |
Signed-off-by: Rodolphe Lepigre <rodolphe@bedrocksystems.com>
@ejgallego sorry for the lag, but your patch does fix the regression, so thanks again. How do we get that fixed properly though? Do you want to make an MR with this proposal? |
I'd suggest you folks use this patch for now, it should be pretty safe. I'd like to think about this and likely discuss with Dune devs as to be sure the new semantics are the intended one. I was fully booked these two weeks, but next week looks more promising. |
This has unfortunately made Did anybody manage to bisect where this was introduced? |
Yes, we bisected it, and it is in the issue description. 😄 @ejgallego also has a fix that works for us at BedRock Systems (we're currently using a patched version of dune). |
@Alizter indeed it seems that the way actions are run changed. This is waiting on me being able to attend a Dune dev meeting as to discuss what is going on, but I think indeed we were relying on a Dune engine bug. |
Feel free to take over my branch and submit the fix tho, I'm sorry I couldn't be more responsive on this. |
The culprit is this line: dune/src/dune_rules/action_builder.ml Lines 44 to 47 in 60b2a3c
Removing the recording of deps here fixes the issue. |
Signed-off-by: Rodolphe Lepigre <rodolphe@bedrocksystems.com> Signed-off-by: Ali Caglayan <alizter@gmail.com>
PR ocaml#9552 changed the semantics of Action_builder.contents so that it records a dependency. The Coq rules were relying on the previous behaviour of not recording a dependency in order to generate a build plan. This caused issue ocaml#10149 to appear. This PR fixes ocaml#10149 by removing the dependency being recorded in Action_builder.contents matching the previous semantics. Signed-off-by: Ali Caglayan <alizter@gmail.com>
Here is a fix: |
PR ocaml#9552 changed the semantics of Action_builder.contents so that it records a dependency. The Coq rules were relying on the previous behaviour of not recording a dependency in order to generate a build plan. This caused issue ocaml#10149 to appear. This PR fixes ocaml#10149 by removing the dependency being recorded in Action_builder.contents matching the previous semantics. Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Rodolphe Lepigre <rodolphe@bedrocksystems.com> Signed-off-by: Ali Caglayan <alizter@gmail.com>
PR ocaml#9552 changed the semantics of Action_builder.contents so that it records a dependency. The Coq rules were relying on the previous behaviour of not recording a dependency in order to generate a build plan. This caused issue ocaml#10149 to appear. This PR fixes ocaml#10149 by removing the dependency being recorded in Action_builder.contents matching the previous semantics. Signed-off-by: Ali Caglayan <alizter@gmail.com>
PR ocaml#9552 changed the semantics of Action_builder.contents so that it records a dependency. The Coq rules were relying on the previous behaviour of not recording a dependency in order to generate a build plan. This caused issue ocaml#10149 to appear. This PR fixes ocaml#10149 by removing the dependency being recorded in Action_builder.contents matching the previous semantics. Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Rodolphe Lepigre <rodolphe@bedrocksystems.com> Signed-off-by: Ali Caglayan <alizter@gmail.com>
PR ocaml#9552 changed the semantics of Action_builder.contents so that it records a dependency. The Coq rules were relying on the previous behaviour of not recording a dependency in order to generate a build plan. This caused issue ocaml#10149 to appear. This PR fixes ocaml#10149 by removing the dependency being recorded in Action_builder.contents matching the previous semantics. Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Rodolphe Lepigre <rodolphe@bedrocksystems.com> Signed-off-by: Ali Caglayan <alizter@gmail.com>
PR ocaml#9552 changed the semantics of Action_builder.contents so that it records a dependency. The Coq rules were relying on the previous behaviour of not recording a dependency in order to generate a build plan. This caused issue ocaml#10149 to appear. This PR fixes ocaml#10149 by removing the dependency being recorded in Action_builder.contents matching the previous semantics. Signed-off-by: Ali Caglayan <alizter@gmail.com>
* Add reproduction test case for #10149. Signed-off-by: Rodolphe Lepigre <rodolphe@bedrocksystems.com> Signed-off-by: Ali Caglayan <alizter@gmail.com> * stop recording deps in Action_builder.contents PR #9552 changed the semantics of Action_builder.contents so that it records a dependency. The Coq rules were relying on the previous behaviour of not recording a dependency in order to generate a build plan. This caused issue #10149 to appear. This PR fixes #10149 by removing the dependency being recorded in Action_builder.contents matching the previous semantics. Signed-off-by: Ali Caglayan <alizter@gmail.com> --------- Signed-off-by: Rodolphe Lepigre <rodolphe@bedrocksystems.com> Signed-off-by: Ali Caglayan <alizter@gmail.com> Co-authored-by: Rodolphe Lepigre <rodolphe@bedrocksystems.com> Co-authored-by: Ali Caglayan <alizter@gmail.com>
CHANGES: ### Fixed - If no directory targets are defined, then do not evaluate `enabled_if` (ocaml/dune#10442, @rgrinberg) - Fix a bug where Coq projects were being rebuilt from scratch each time the dependency graph changed. (ocaml/dune#10446, fixes ocaml/dune#10149, @Alizter)
Expected Behavior
Only
leaf.vo
gets rebuild.Actual Behavior
All files get rebuilt, including
other_root.vo
(the added dependency) as well asroot.v
(the existing dependency).Reproduction
Add reproduction test case for #10149. #10150
The steps below can be used to reproduce exactly the behavior described above but the reproducing PR has a smaller test case that is better suited to debugging this.
cd bug
dune build coq
echo "Require Import bug.other_root." >> coq/leaf.v
dune build coq
Specifications
dune
(output ofdune --version
): 3.13.0, masterocaml
(output ofocamlc --version
): 4.14.1Additional information
git bisect
points to:The corresponding PR is #9552
CC @rlepigre
The text was updated successfully, but these errors were encountered: