From 97cc5d8b200df4b1f9c75ac1c45db21be09bf7b8 Mon Sep 17 00:00:00 2001 From: Stephen Sherratt Date: Thu, 12 Sep 2024 09:31:55 +1000 Subject: [PATCH] toolchain: Remove locations from pkg before hashing (#10902) When computing the hash of a toolchain package, first remove all locations. Without doing this, identical compiler packages inside different lockdirs will have different hashes and require unnecessarily recompiling the compiler package. Signed-off-by: Stephen Sherratt --- src/dune_pkg/lock_dir.mli | 1 + src/dune_rules/pkg_toolchain.ml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dune_pkg/lock_dir.mli b/src/dune_pkg/lock_dir.mli index 2042c74f59c..75a80d7f24e 100644 --- a/src/dune_pkg/lock_dir.mli +++ b/src/dune_pkg/lock_dir.mli @@ -30,6 +30,7 @@ module Pkg : sig ; exported_env : String_with_vars.t Action.Env_update.t list } + val remove_locs : t -> t val equal : t -> t -> bool val decode : (lock_dir:Path.Source.t -> Package_name.t -> t) Decoder.t val files_dir : Package_name.t -> lock_dir:Path.Source.t -> Path.Source.t diff --git a/src/dune_rules/pkg_toolchain.ml b/src/dune_rules/pkg_toolchain.ml index 0cf11243dda..da4e06bcd16 100644 --- a/src/dune_rules/pkg_toolchain.ml +++ b/src/dune_rules/pkg_toolchain.ml @@ -27,7 +27,7 @@ let pkg_dir (pkg : Dune_pkg.Lock_dir.Pkg.t) = way). *) let dir_name = (* TODO should include resolved deps *) - let pkg_hash = Digest.generic pkg in + let pkg_hash = Digest.generic (Lock_dir.Pkg.remove_locs pkg) in (* A hash of the fields of a package that affect its installed artifacts *) sprintf "%s.%s-%s"