FYI @Janno and I found a pretty bad bug in dune 3.13.0 and above, that leads to all Coq files being compiled as soon as any (even unrelated) dependency changes (see https://github.com/ocaml/dune/issues/10149). We managed to identify the commit introducing the regression, but I'm not familiar enough with how dependencies are collected to quickly fix it. Any help would be appreciated.
Indeed that's a tricky one, the Dune API has changed so much since the first Coq dune code, I'm unsure what the semantics of some parts are.
Moreover I'm suprised you didn't observe this regression already on https://github.com/ocaml/dune/pull/7048 .
I hope we can resolve it soon tho, see my comment on the issue.
Note that also you may want to backport https://github.com/ocaml/dune/pull/10116
Yeah, I hope this can be fixed quickly: we really want the new (dynamic_include ..)
stanza. It'd be a shame to have to roll back to 3.12.2.
Maybe the easiest fix would be to go back to calling coqdep
per file, as I think you suggested? (Or at least to generate independent files.)
(Yeah, we were thinking of backporting those.)
Emilio Jesús Gallego Arias said:
Moreover I'm suprised you didn't observe this regression already on https://github.com/ocaml/dune/pull/7048 .
I don't think the regression was there after this MR, right?
I think for now we want to get some feedback from Andrey and Rudi, a fixup is pretty easy tho if you need something now.
Rodolphe Lepigre said:
Emilio Jesús Gallego Arias said:
Moreover I'm suprised you didn't observe this regression already on https://github.com/ocaml/dune/pull/7048 .
I don't think the regression was there after this MR, right?
Depends on the semantics we assume for Action_builder , indeed it is puzzling the regression happen in that commit bisect, we need more info from the engine folks.
We don't need something right now, but we'll definitely need something in the next couple of days.
It may require more time upstream, so meanwhile you can try this solution:
setup_theory_rules
add a new setup_per_file_rules
.file.v.d
file with the result of Dep_map.find
so this will add N write file overhead to a build where the file listing changes
where N = number of files in the theory
but still on linux, that should be pretty minimal
Let me know if you have any question about the above fix
OK thanks, I'll see if I can give it a go in the next couple of days.
So instead of the two current rules:
{ list of sources } ---[coqdep]---> { .foo.d.v }
{ .foo.d.v } ---[build_map]---> { dep_map } ---[find]---> { dep files } ---[coqc]---> { .vo }
we have 3 rules
so things factor thru the new file rule:
{ .foo.v.d } ---[ build_map } ----> { dep_map } ---[find] ---{ file.v.d }
I've written the code anyways, let me push the branch.
FTR this turned out to be a bug introduced during unrelated refactoring in Action_builder.contents
. This is an internal API that is used to read contents of a file and pipe them along to generate actions. The previous semantics before the refactoring was that files could be read, but there was no dependency on the files itself generated. This allowed for coqdep to output a file and other Coq related actions to be generated without actually depending on the output of coqdep as a file, but rather being contents aware. Same content = same rules. This was broken unintenionally in the refactoring leading to a spurious dependency being declared on files being read. This meant that every time the output of coqdep changed, the entire project got rebuilt.
I submitted a fix here once I noticed the root cause of this issue: https://github.com/ocaml/dune/pull/10446
It is a very subtle bug, in that we might be the only consumer of that API so a sensible looking change didn't have an affect on anything else. Coq is tested in the Dune test suite, but obviously we can't test every possible behaviour so nobody (in Dune) noticed this since 3.13.
I'm going to advocate for this to be backported to all affected Dune versions. These are currently 3.13, 3.14 and 3.15.
Great work, thanks a lot @Ali Caglayan!
Thanks a lot @Ali Caglayan , I'm glad we could look into this; I'm on holidays now and indeed lacking time lately due to some reorganization of my work tasks.
I still wonder tho about the current semantics of contents
, IMHO the current documentation is a bit ambigous, it would be good to note that it doesn't record a dep on file.
But now that I think of it, it is maybe likely obvious?
I guess we can think of cases where people could expect either semantics
We are the only really serious user of contents
so I think adding a comment in the API explicitly stating that this does not record the file as a dependency would be the correct thing to do.
If there is a reason to expect the other semantics, then the correct gadget should be added to action_builder.
I agree. This stuff is very subtle! I get myself confused about the semantics all the time, but indeed, the non-recording semantics are the right ones.
Last updated: Oct 13 2024 at 01:02 UTC