Skip to content

dep_rules: don't run (transitive) ocamldep on single module buildables - #12555

Merged
anmonteiro merged 2 commits into
ocaml:mainfrom
anmonteiro:anmonteiro/dont-run-ocamldep-transitive-on-single-module-buildables
Oct 13, 2025
Merged

anmonteiro merged 2 commits into
ocaml:mainfrom
anmonteiro:anmonteiro/dont-run-ocamldep-transitive-on-single-module-buildables

Conversation

@anmonteiro

Copy link
Copy Markdown
Collaborator

same as #3847, for .all-deps

@anmonteiro
anmonteiro requested a review from rgrinberg October 12, 2025 07:44
@anmonteiro
anmonteiro marked this pull request as ready for review October 12, 2025 07:44

@rgrinberg rgrinberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A further improvement would be not to generate the rule for such singleton modules

@anmonteiro

Copy link
Copy Markdown
Collaborator Author

I'm not sure it's being generated now?

@anmonteiro
anmonteiro enabled auto-merge (squash) October 13, 2025 03:34
@anmonteiro
anmonteiro merged commit 641e260 into ocaml:main Oct 13, 2025
@anmonteiro
anmonteiro deleted the anmonteiro/dont-run-ocamldep-transitive-on-single-module-buildables branch October 13, 2025 07:31
Sudha247 pushed a commit to Sudha247/dune that referenced this pull request Oct 13, 2025
davesnx added a commit to davesnx/dune that referenced this pull request Oct 14, 2025
* 'main' of github.com:/ocaml/dune: (147 commits)
  cram test: test only parameter flags in merlin generation
  fix(oxcaml): import eta-expansion changes from opam-repo (ocaml#12563)
  address review comments
  Mask the path to the stdlib
  fix(oxcaml): generate merlin config for library parameters
  fix(melange + include_qualified): track correct `.cmj` dependencies in emit (ocaml#12531)
  refactor: remove some unused code in [Path] (ocaml#12558)
  dep_rules: don't run (transitive) `ocamldep` on single module buildables (ocaml#12555)
  fix(pkg): ignore project settings for building packages
  test(pkg): reproduce ocaml#12131
  melange: add a test for module cycle checks (ocaml#12554)
  chore: lint check for new changes entries (ocaml#12553)
  feature(cram): allow for conflict detection (ocaml#12538)
  ci: update for ocaml 5.4 release (ocaml#12552)
  chore(script): generate changelog from structure (ocaml#12516)
  Reuse dependencies between project and tools (ocaml#12526)
  Introduce Io.overwrite_file
  test: fix dune install requiring a mandir
  Enable package management for more tests
  Add a `dune tools env` command to add dev tools to PATH (ocaml#12521)
  ...
MisterDA pushed a commit to MisterDA/dune that referenced this pull request Nov 13, 2025
robinbb added a commit to robinbb/dune that referenced this pull request Apr 22, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 22, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 23, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 24, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 25, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 25, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 25, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 25, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 26, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 27, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 27, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request Apr 29, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request Apr 30, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request Apr 30, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request Apr 30, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request Apr 30, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request May 1, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request May 1, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request May 1, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request May 1, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request May 1, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request May 1, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 2, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 2, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 3, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 3, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 3, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 3, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, since in that case there is no filter
benefit to gain. When `(libraries ...)` is declared, run ocamldep
even for a single-module stanza so the filter has the data it needs.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 4, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 6, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 6, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 6, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 7, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 7, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 7, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 7, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 7, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 8, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 9, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit to robinbb/dune that referenced this pull request May 9, 2026
…4572)

Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to ocaml#3847 / ocaml#12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in ocaml#14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
ocaml#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request May 10, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
robinbb added a commit that referenced this pull request May 10, 2026
Previously, dune short-circuited ocamldep for every single-module
stanza as an optimisation (dating back to #3847 / #12555, when
ocamldep output was used only for intra-stanza dependencies). The
short-circuit silently defeats the per-module inter-library filter
introduced in #14116, because the filter reads ocamldep output to
determine which libraries a module references.

Narrow the short-circuit: apply it only when the stanza has no
library dependencies at all, or when the stanza is built for
Melange. In the no-deps case there is no filter benefit to gain;
in the Melange case [lib_deps_for_module]'s [can_filter] guard
returns [false] for melange [cm_kind]s, so the dep graph is never
read and computing it is wasted work.

Reported by @nojb in
#14116 (comment)

Includes a new test `single-module-unreferenced-lib.t` capturing the
exact reproducer: libA and libB are both single-module, libB depends
on libA but its only module does not reference libA's; modifying
libA's module must not recompile libB's.

Adding `.impl.d` / `.impl.all-deps` rules for these stanzas slightly
changes the build-graph nodes traversed when dune reports error
chains and dependency cycles. Update affected snapshots:

  * `enabled_if/eif-context_name.t`, `enabled_if/eif-ocaml_version.t`,
    `invalid-dune-package.t`, `optional-executable.t`,
    `stanzas/forbidden_libraries.t`, three `virtual-libraries/*` tests:
    a `-> required by _build/default/...dune__exe__*.cmx` chain entry
    is no longer visited before the error is reported, since the
    library-resolution failure is reached through an ocamldep rule
    that precedes the .cmx rule in the build graph.

  * `inline-tests/alias-cycle.t`: the dependency cycle is now walked
    through `.cmx` / `.cmxa` instead of `.cmi` / inline-tests exe
    nodes. Same cycle, different traversal. (A later commit replaces
    this snapshot with a walk-invariant assertion.)

  * `watching/multiple-errors-output.t`: ocamldep now runs on a
    deliberately malformed source (`let f = Bar.x + Baz.y +
    invalid_syntax : ? = !`) and reports a syntax error that
    compilation alone previously missed. The aggregated error count
    grows from 2 to 3.

The Melange branch of the short-circuit means [emit-installed.t] and
[emit-installed-two-modes.t] do not gain an [ocamldep (internal)]
trace line: their [b/dune] stanzas are single-module melange
libraries with library deps, exactly the case the new disjunct
covers.

Signed-off-by: Robin Bate Boerop <[email protected]>
@Alizter Alizter added this to the 3.21.0 milestone Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants