Skip to content

infra: Lib_index, deps_of_entries, deps_of_entry_modules, raw ocamldep#14513

Merged
Alizter merged 1 commit into
mainfrom
robinbb-14492-l1-lib-index-infra
May 14, 2026
Merged

infra: Lib_index, deps_of_entries, deps_of_entry_modules, raw ocamldep#14513
Alizter merged 1 commit into
mainfrom
robinbb-14492-l1-lib-index-infra

Conversation

@robinbb
Copy link
Copy Markdown
Collaborator

@robinbb robinbb commented May 13, 2026

Layer 1 of 9 stacked PRs reconstructing #14492 in reviewable layers.

Adds the dataflow infrastructure subsequent layers consume — Lib_file_deps.Lib_index, deps_of_entries, deps_of_entry_modules, Ocamldep.read_immediate_deps_words (top-level cache keyed on (source path, ml_kind)), and Ocamldep.read_immediate_deps_raw_of. No consumer yet.

Stack: this PR → main. Next: #14514.

Part of #14492. Related to #4572.

Comment thread src/dune_rules/ocamldep.ml Outdated
Comment thread src/dune_rules/ocamldep.ml Outdated
Comment thread src/dune_rules/lib_file_deps.mli Outdated
@robinbb robinbb force-pushed the robinbb-14492-l1-lib-index-infra branch 2 times, most recently from a6bf06f to d273159 Compare May 13, 2026 22:42
Comment thread src/dune_rules/ocamldep.ml Outdated
Comment thread src/dune_rules/ocamldep.ml Outdated
@Alizter
Copy link
Copy Markdown
Collaborator

Alizter commented May 13, 2026

@robinbb Should I wait a bit longer before continuing to review if you want to improve it? I'm basically happy with this part, its not too controversial. After L9 we can always rethink anything that's not up to par.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Layer 1 of a 9-PR stack reconstructing #14492. This PR introduces dataflow infrastructure for per-module inter-library dependency filtering (#4572) without yet wiring any consumers: a Lib_file_deps.Lib_index module that classifies entry-module references as tight/non-tight per library, helpers deps_of_entries / deps_of_entry_modules to build glob-based or per-module file deps, and a refactor of Ocamldep.read_immediate_deps_of that factors out a shared read_immediate_deps_words (with a top-level cache keyed on (source path, ml_kind)) and adds a new read_immediate_deps_raw_of returning raw module-name sets without filtering against the stanza's module set.

Changes:

  • Add Lib_index, deps_of_entries, and deps_of_entry_modules to Lib_file_deps for per-module/per-library dep computation.
  • Refactor Ocamldep to share a top-level cache of ocamldep word output and expose read_immediate_deps_raw_of for cross-library use.
  • Extract the ocamldep error helper invalid_ocamldep_output and uncurry parse_deps_exn.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/dune_rules/lib_file_deps.mli Public API for deps_of_entries, deps_of_entry_modules, and Lib_index.
src/dune_rules/lib_file_deps.ml Implements the new helpers and the Lib_index classification logic.
src/dune_rules/ocamldep.mli Adds the new read_immediate_deps_raw_of signature.
src/dune_rules/ocamldep.ml Splits ocamldep parsing/error helpers and introduces a process-global cache shared by read_immediate_deps_of and the new raw API.

Comment thread src/dune_rules/lib_file_deps.ml
Comment thread src/dune_rules/ocamldep.ml
Comment thread src/dune_rules/lib_file_deps.mli Outdated
Comment thread src/dune_rules/ocamldep.ml Outdated
@robinbb robinbb force-pushed the robinbb-14492-l1-lib-index-infra branch 2 times, most recently from 07c064f to a3ab9c8 Compare May 13, 2026 23:21
…mldep

Pure-additive groundwork for #4572's per-module inter-library dependency
filter. No consumer yet; the cross-library walker and per-module filter
land in a follow-up.

[Lib_file_deps]:
- [Lib_index]: a per-cctx index mapping module-name → (lib, Some entry
  Module.t / None) entries plus a [tight_eligible] set of libs whose
  modules can serve specific-file deps and a [no_ocamldep] set of libs
  whose [.d] files don't exist (short-circuited by
  [Dep_rules.skip_ocamldep]). [create] / [filter_libs_with_modules] /
  [lookup_tight_entries] / [is_tight_eligible] / [wrapped_libs_referenced].
- [deps_of_entries ~opaque ~cm_kind libs]: opaque-aware glob deps over the
  given libraries. Mirrors the implicit semantics previously inlined in
  [Compilation_context.Includes.make].
- [deps_of_entry_modules ~opaque ~cm_kind lib modules]: specific-file
  cmi/cmx deps on the given local-lib modules, via [cm_public_file] so
  the produce-public-cmi rule is triggered.

[Ocamldep]:
- Extract [invalid_ocamldep_output] so [parse_deps_exn] can be called
  independently of its [Action_builder.t] caller.
- [read_immediate_deps_words]: top-level cache keyed on (source path,
  ml_kind) holding the [Action_builder.t]. Without it, future per-module
  filter callers each create a distinct [Action_builder.memoize] cell
  (because [pp_flags] closure identity varies), causing ocamldep to run
  multiply per source.
- [read_immediate_deps_of]: refactored to read words through the cache,
  then resolve against the stanza's module set; semantics unchanged.
- [read_immediate_deps_raw_of]: new entry point returning raw
  [Module_name.Set.t] for the cross-library walker.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-14492-l1-lib-index-infra branch from a3ab9c8 to 55c7882 Compare May 13, 2026 23:30
@robinbb
Copy link
Copy Markdown
Collaborator Author

robinbb commented May 13, 2026

@robinbb Should I wait a bit longer before continuing to review if you want to improve it? I'm basically happy with this part, its not too controversial. After L9 we can always rethink anything that's not up to par.

@Alizter Okay, but, if you approve, do you want it to merge, or do you want all 9 PRs to be approved before the first merges? (I'll keep making changes as long as you keep making comments.)

@robinbb robinbb marked this pull request as ready for review May 13, 2026 23:33
@robinbb robinbb requested review from Alizter and Copilot May 13, 2026 23:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@Alizter
Copy link
Copy Markdown
Collaborator

Alizter commented May 14, 2026

@robinbb I was suggesting reviewing and merging as we go along. I don't see any point in keeping the entire series in limbo, that's just more work for everybody.

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.

I don't see anything that's obviously wrong. Bench results also don't change as expected.

@Alizter Alizter merged commit 479c915 into main May 14, 2026
35 checks passed
@Alizter Alizter deleted the robinbb-14492-l1-lib-index-infra branch May 14, 2026 11:16
@robinbb
Copy link
Copy Markdown
Collaborator Author

robinbb commented May 14, 2026

A note for observers, not for @Alizter.

Bench results also don't change as expected.

This is an interesting case where the comma, or lack of comma, changes the meaning 100%.

Here, @Alizter is expressing that the bench results are unchanged, and that the lack of change is what was expected.

He is not expressing: the bench results failed to have an expected change.

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