From e258ed14e2d8bb9fc6bc60b727c57ded5364853c Mon Sep 17 00:00:00 2001 From: Marek Kubica Date: Tue, 23 Apr 2024 11:10:01 +0200 Subject: [PATCH] [3.15] Backport #10446 (#10450) * Add reproduction test case for #10149. Signed-off-by: Rodolphe Lepigre Signed-off-by: Ali Caglayan * 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 --------- Signed-off-by: Rodolphe Lepigre Signed-off-by: Ali Caglayan Co-authored-by: Rodolphe Lepigre Co-authored-by: Ali Caglayan --- doc/changes/10446.md | 2 ++ src/dune_rules/action_builder.ml | 7 +------ .../test-cases/coq/no-rebuild-on-dep-change.t | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 doc/changes/10446.md create mode 100644 test/blackbox-tests/test-cases/coq/no-rebuild-on-dep-change.t diff --git a/doc/changes/10446.md b/doc/changes/10446.md new file mode 100644 index 00000000000..c38b382f368 --- /dev/null +++ b/doc/changes/10446.md @@ -0,0 +1,2 @@ +- Fix a bug where Coq projects were being rebuilt from scratch each time the + dependency graph changed. (#10446, fixes #10149, @alizter) diff --git a/src/dune_rules/action_builder.ml b/src/dune_rules/action_builder.ml index 5192e2ec9a1..870987b0d79 100644 --- a/src/dune_rules/action_builder.ml +++ b/src/dune_rules/action_builder.ml @@ -37,12 +37,7 @@ let paths ps = deps (Dep.Set.of_files ps) let path_set ps = deps (Dep.Set.of_files_set ps) let dyn_paths paths = dyn_deps (paths >>| fun (x, paths) -> x, Dep.Set.of_files paths) let dyn_paths_unit paths = dyn_deps (paths >>| fun paths -> (), Dep.Set.of_files paths) - -let contents p = - let* () = Dep.file p |> Dep.Set.singleton |> Build_system.record_deps in - of_memo (Build_system.read_file p) -;; - +let contents p = of_memo (Build_system.read_file p) let lines_of p = contents p >>| String.split_lines let read_sexp p = diff --git a/test/blackbox-tests/test-cases/coq/no-rebuild-on-dep-change.t b/test/blackbox-tests/test-cases/coq/no-rebuild-on-dep-change.t new file mode 100644 index 00000000000..9df18a23153 --- /dev/null +++ b/test/blackbox-tests/test-cases/coq/no-rebuild-on-dep-change.t @@ -0,0 +1,17 @@ + $ echo "(coq.theory (name bug) (mode vo))" > dune + $ echo "(lang dune 3.12)" > dune-project + $ echo "(using coq 0.8)" >> dune-project + $ touch root.v leaf.v + $ dune build + $ find _build -name "*.vo" | sort + _build/default/leaf.vo + _build/default/root.vo + $ echo "Require Import bug.root." >> leaf.v + +This test makes sure that a full rebuild is not triggered when the output of +coqdep is changed. + +This is as expected: + $ dune build --display=short + coqdep .bug.theory.d + coqc leaf.{glob,vo}