Summary
dune ocaml top-module rebuilds the top-module artefact when any library declared in the parent stanza's (libraries ...) field has its interface modified — even libraries that are referenced ONLY from .mli (and therefore dropped by top_module.ml's Module.set_source ~ml_kind:Intf None).
Reproducer
(Same setup as the baseline test in #14476.)
A library mylib with (libraries dep_for_intf dep_for_impl), where m.ml references only Dep_for_impl.value and m.mli references only Dep_for_intf.t. After dune ocaml top-module mylib/m.ml initial build, editing dep_for_intf's .mli triggers a rebuild of _build/default/.topmod/mylib/m.ml/mylib__M.cmo despite no reference from m.ml to Dep_for_intf.
Severity
Soundness is preserved (over-rebuilds, never under-rebuilds). The cost is incremental-rebuild perf in iterative dune utop / dune ocaml top-module workflows on monorepos with libraries that have many (libraries ...) deps.
Summary
dune ocaml top-modulerebuilds the top-module artefact when any library declared in the parent stanza's(libraries ...)field has its interface modified — even libraries that are referenced ONLY from.mli(and therefore dropped bytop_module.ml'sModule.set_source ~ml_kind:Intf None).Reproducer
(Same setup as the baseline test in #14476.)
A library
mylibwith(libraries dep_for_intf dep_for_impl), wherem.mlreferences onlyDep_for_impl.valueandm.mlireferences onlyDep_for_intf.t. Afterdune ocaml top-module mylib/m.mlinitial build, editingdep_for_intf's.mlitriggers a rebuild of_build/default/.topmod/mylib/m.ml/mylib__M.cmodespite no reference fromm.mltoDep_for_intf.Severity
Soundness is preserved (over-rebuilds, never under-rebuilds). The cost is incremental-rebuild perf in iterative
dune utop/dune ocaml top-moduleworkflows on monorepos with libraries that have many(libraries ...)deps.