Skip to content

refactor: ocamldep without named targets#14385

Merged
rgrinberg merged 1 commit into
ocaml:mainfrom
rgrinberg:push-oowzpwrzwmyr
May 1, 2026
Merged

refactor: ocamldep without named targets#14385
rgrinberg merged 1 commit into
ocaml:mainfrom
rgrinberg:push-oowzpwrzwmyr

Conversation

@rgrinberg
Copy link
Copy Markdown
Member

These targets are useless to end users, so let's hide them. This will allow to improve our handling of these even further later.

Copy link
Copy Markdown
Collaborator

@Alizter Alizter left a comment

Choose a reason for hiding this comment

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

Happy to see more anonymous actions

@rgrinberg rgrinberg force-pushed the push-oowzpwrzwmyr branch 4 times, most recently from e07248e to db4e1b1 Compare April 30, 2026 22:25
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
@rgrinberg rgrinberg force-pushed the push-oowzpwrzwmyr branch from db4e1b1 to 2ddd326 Compare May 1, 2026 20:01
@rgrinberg rgrinberg merged commit 0b37c37 into ocaml:main May 1, 2026
31 checks passed
robinbb pushed a commit to robinbb/dune that referenced this pull request May 2, 2026
Collapse multi-line keyword-argument calls and let-bindings introduced
during conflict resolution while rebasing onto post-ocaml#14385 main, per
ocamlformat.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 2, 2026
Collapse multi-line keyword-argument calls and let-bindings introduced
during conflict resolution while rebasing onto post-ocaml#14385 main, per
ocamlformat.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 2, 2026
Collapse multi-line keyword-argument calls and let-bindings introduced
during conflict resolution while rebasing onto post-ocaml#14385 main, per
ocamlformat.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 3, 2026
Collapse multi-line keyword-argument calls and let-bindings introduced
during conflict resolution while rebasing onto post-ocaml#14385 main, per
ocamlformat.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 3, 2026
Collapse multi-line keyword-argument calls and let-bindings introduced
during conflict resolution while rebasing onto post-ocaml#14385 main, per
ocamlformat.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 3, 2026
Collapse multi-line keyword-argument calls and let-bindings introduced
during conflict resolution while rebasing onto post-ocaml#14385 main, per
ocamlformat.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 3, 2026
Collapse multi-line keyword-argument calls and let-bindings introduced
during conflict resolution while rebasing onto post-ocaml#14385 main, per
ocamlformat.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 4, 2026
…caml#4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR ocaml#14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (ocaml#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 6, 2026
…caml#4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR ocaml#14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (ocaml#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 6, 2026
…caml#4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR ocaml#14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (ocaml#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 6, 2026
…caml#4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR ocaml#14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (ocaml#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 7, 2026
…caml#4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR ocaml#14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (ocaml#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 7, 2026
…caml#4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR ocaml#14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (ocaml#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 7, 2026
…caml#4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR ocaml#14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (ocaml#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 7, 2026
…caml#4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR ocaml#14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (ocaml#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 8, 2026
…caml#4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR ocaml#14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (ocaml#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 9, 2026
…caml#4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR ocaml#14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (ocaml#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit to robinbb/dune that referenced this pull request May 9, 2026
…caml#4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR ocaml#14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (ocaml#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit that referenced this pull request May 10, 2026
…4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR #14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added a commit that referenced this pull request May 10, 2026
…4572)

Use the already-computed ocamldep output to filter inter-library
dependencies on a per-module basis. Each module now only depends on
.cmi/.cmx files from libraries it actually imports, rather than glob
deps on all files from all dependent libraries. This eliminates
unnecessary recompilation when a module in a dependency changes but the
current module doesn't reference that library.

The implementation:

- Add read_immediate_deps_raw_of to ocamldep, returning raw module names
  without filtering against the stanza's module set
- Move Hidden_deps from Includes (library-wide) to per-module in build_cm
- Add Lib_index mapping module names to libraries, computed from
  requires_compile and requires_hidden
- In build_cm, use ocamldep output + Lib_index to determine which
  libraries each module actually needs; fall back to all-library glob
  deps when filtering is not possible (Melange, virtual library
  implementations, singleton stanzas, alias/root modules)
- For local unwrapped libraries, use per-file deps on specific .cmi/.cmx
  files rather than directory-wide globs

Promotes [sibling-unreferenced-lib.t] to assert the desired post-fix
shape: with a sibling consumer module that references nothing from
the declared dep lib, the per-module filter drops the lib entirely
from that module's compile-rule deps, so editing the dep lib's
interface no longer fires any [spurious_rebuild]-named rule. Test
flips from main's one-rule observational baseline to [[]].

Re-promotes [emit-private.t] to drop the [ocamldep (internal)] line
from its trace assertion. The per-module filter reshapes ocamldep
into a memoised action that no longer surfaces in [--display=short]
traces for the melange single-module emit stanza this test exercises;
the line was added on main by PR #14385 and the work it documented
is no longer visible after this change.

chore: add changelog entry for per-module dependency filtering (#4572)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
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.

2 participants