Skip to content

refactor: move library file deps from Includes to per-module in build_cm (#4572)#14030

Draft
robinbb wants to merge 7 commits intoocaml:mainfrom
robinbb:robinbb-issue-4572-refactor
Draft

refactor: move library file deps from Includes to per-module in build_cm (#4572)#14030
robinbb wants to merge 7 commits intoocaml:mainfrom
robinbb:robinbb-issue-4572-refactor

Conversation

@robinbb
Copy link
Copy Markdown
Contributor

@robinbb robinbb commented Apr 3, 2026

Pure refactor: moves Hidden_deps (library file dependencies) out of
Includes.make and into per-module computation in build_cm. No behavioral
change — all modules still depend on all libraries in their stanza's requires.

This separation is prerequisite work for #4572 (finer dependency analysis
between libraries). Includes carries -I flags which must be shared across
all modules in a stanza. Hidden_deps can vary per-module — once separated,
a future change can use ocamldep output to declare only the library deps
each module actually needs.

Changes:

  • Includes.make no longer takes ~opaque or bundles Hidden_deps
  • New deps_of_entries in lib_file_deps.ml replaces the old inline opaque
    logic; deps_with_exts removed (sole caller was the old opaque branch)
  • build_cm adds a lib_cm_deps block that declares library file deps
    per-module; alias and wrapped-compat modules skip library deps (matching
    their existing Includes.empty behavior)

Depends on #14017 (merged), #14031 (merged), #14100, and #14101.
Ref: #4572

@robinbb robinbb force-pushed the robinbb-issue-4572-refactor branch from fc3f91e to bd43f2d Compare April 3, 2026 22:31
@robinbb robinbb force-pushed the robinbb-issue-4572-refactor branch from bd43f2d to c38cdca Compare April 3, 2026 22:47
@robinbb robinbb marked this pull request as ready for review April 3, 2026 23:10
@robinbb
Copy link
Copy Markdown
Contributor Author

robinbb commented Apr 3, 2026

@rgrinberg Here is the refactor that I think you were suggesting in PR #14021. It will be easier to read after #14017 is merged. Subsequently, #14021 will be easier to review, once rebased.

@robinbb robinbb force-pushed the robinbb-issue-4572-refactor branch 4 times, most recently from 142f3f8 to a79bb9d Compare April 6, 2026 15:41
@robinbb robinbb marked this pull request as draft April 6, 2026 16:20
@robinbb robinbb force-pushed the robinbb-issue-4572-refactor branch 3 times, most recently from 5b3066a to 21284b3 Compare April 7, 2026 01:42
@Alizter Alizter marked this pull request as ready for review April 7, 2026 06:17
@robinbb robinbb force-pushed the robinbb-issue-4572-refactor branch 4 times, most recently from 4b6e10e to 817fe3f Compare April 8, 2026 00:42
@robinbb
Copy link
Copy Markdown
Contributor Author

robinbb commented Apr 8, 2026

CI is red, but the errors are on the "install deps" phase, and I did not change the deps in this PR. I'm not sure what I can do to make it go green.

The problem WAS due to THIS Dune, which is used in the "install deps" phases of some CI runs. So, I must fix the problem. Meanwhile, this PR must convert to draft mode.

@robinbb robinbb force-pushed the robinbb-issue-4572-refactor branch 2 times, most recently from ee0e316 to 676d5aa Compare April 8, 2026 05:35
@robinbb robinbb marked this pull request as draft April 8, 2026 05:47
@robinbb robinbb force-pushed the robinbb-issue-4572-refactor branch 3 times, most recently from 05de02d to 34c14f5 Compare April 8, 2026 06:33
When an internal module name shadows an unwrapped library's module name,
the internal module takes precedence and the library's module is
inaccessible. This means ocamldep will report the internal module, not
the library's, so dependency filtering that treats stanza-internal names
as non-library references is correct.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
…lds (ocaml#4572)

Add baseline tests documenting existing behavior:

- lib-deps-preserved: every non-alias module declares glob deps on its
  library dependencies' .cmi files
- sandbox-lib-deps: sandboxed package builds have dependency libraries'
  .cmi files available when a library depends on another library

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb added 4 commits April 9, 2026 00:03
Add baseline test verifying that incremental builds succeed when a module
re-exports a library via a transparent alias (module M = Mylib) and the
library's interface changes. Regression reported by @Alizter.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
Move Hidden_deps (library file dependencies) out of Includes.make and
into per-module computation in build_cm. This is a pure refactor with no
behavioral change — all modules still depend on all libraries in the
stanza's requires.

This separation is necessary for issue ocaml#4572: Includes carries -I flags
(which must be shared across all modules) while Hidden_deps can vary
per-module. With this refactor, a future change can use ocamldep output
to filter Hidden_deps per-module without affecting -I flags.

- Includes.make no longer takes ~opaque or bundles Hidden_deps
- New deps_of_entries in lib_file_deps.ml handles opaque logic
- Alias and Wrapped_compat modules skip library deps (matching their
  existing Includes.empty behavior)
- deps_with_exts removed (sole caller was the old opaque branch)

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-issue-4572-refactor branch from 0ad4949 to 8c3d290 Compare April 9, 2026 04:03
…issue ocaml#4572)

Add a new function `read_immediate_deps_raw_of` to the ocamldep module that
returns raw module names (as Module_name.Set.t) from ocamldep output, without
resolving them to Module.t values.

This function will be used to determine which external library modules a
module actually references, enabling finer-grained dependency tracking where
modules are only recompiled when libraries they actually use change.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-issue-4572-refactor branch from 8c3d290 to 82bf016 Compare April 9, 2026 04:37
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.

1 participant