Skip to content

refactor: route lib file deps through [lib_deps_for_module]#14515

Merged
robinbb merged 1 commit into
robinbb-14492-test-stack-integrationfrom
robinbb-14492-l3-includes-refactor
May 23, 2026
Merged

refactor: route lib file deps through [lib_deps_for_module]#14515
robinbb merged 1 commit into
robinbb-14492-test-stack-integrationfrom
robinbb-14492-l3-includes-refactor

Conversation

@robinbb
Copy link
Copy Markdown
Collaborator

@robinbb robinbb commented May 13, 2026

Layer 3 of 9 of #14492. Behaviour-equivalent refactor.

Compilation_context.Includes.make drops ~opaque and stops emitting Hidden_deps; Includes.t carries only -I/-H flags. Module_compilation.lib_deps_for_module (scaffold form: always-glob) and lib_cm_deps wire the dep set back in via deps_of_entries. build_cm and ocamlc_i are switched to consume lib_cm_deps; Alias / Wrapped_compat short-circuit to the cctx's now-flag-only Includes. Lib_file_deps.deps_with_exts removed — only used by the old Cmx arm of Includes.make.

Combined effect: same -I / -H, same lib file deps.

Stack: rebases on #14514. Next: #14516.

Part of #14492. Related to #4572.

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

Refactors how module compilation rules obtain library include flags and library file dependencies by routing lib-file deps through Module_compilation.lib_deps_for_module/lib_cm_deps, while simplifying Compilation_context.Includes to carry only -I/-H flags (dropping Hidden_deps emission). This is part of the staged work toward per-module library dependency filtering (#14492 / #4572) and is intended to be behavior-equivalent.

Changes:

  • Added Module_compilation.lib_deps_for_module (scaffold “always-glob” form) plus lib_cm_deps, and switched build_cm/ocamlc_i to consume dynamic lib deps via Command.Args.Dyn.
  • Simplified Compilation_context.Includes.make to no longer thread ~opaque or emit Hidden_deps; it now produces only include flags.
  • Removed the unused Lib_file_deps.deps_with_exts helper (previously only used by the old Cmx branch in Includes.make).

Reviewed changes

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

File Description
src/dune_rules/module_compilation.ml Introduces per-module lib deps plumbing (lib_deps_for_module/lib_cm_deps) and updates compilation actions to use them.
src/dune_rules/compilation_context.ml Refactors Includes.make to produce only -I/-H flags (no Hidden_deps, no ~opaque).
src/dune_rules/lib_file_deps.mli Removes the deps_with_exts declaration.
src/dune_rules/lib_file_deps.ml Removes the deps_with_exts implementation.

Comment thread src/dune_rules/module_compilation.ml
Comment thread src/dune_rules/module_compilation.ml Outdated
@robinbb robinbb force-pushed the robinbb-14492-l2-cctx-fields branch 3 times, most recently from 7459ded to 22fcd5f Compare May 14, 2026 00:28
@robinbb robinbb force-pushed the robinbb-14492-l3-includes-refactor branch 2 times, most recently from d3418da to 246a914 Compare May 14, 2026 00:35
@robinbb robinbb requested a review from Copilot May 14, 2026 00:36
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.

@robinbb robinbb requested a review from Alizter May 14, 2026 00:51
@robinbb robinbb marked this pull request as ready for review May 14, 2026 00:52
@robinbb robinbb force-pushed the robinbb-14492-l2-cctx-fields branch 3 times, most recently from 2d4b53c to 87a2380 Compare May 14, 2026 19:07
@robinbb robinbb force-pushed the robinbb-14492-l3-includes-refactor branch from 246a914 to d88da28 Compare May 14, 2026 19:07
@robinbb robinbb requested a review from Copilot May 14, 2026 19:08
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.

@robinbb robinbb marked this pull request as draft May 18, 2026 17:14
@robinbb robinbb force-pushed the robinbb-14492-l2-cctx-fields branch 2 times, most recently from 82bc32c to 7f288f7 Compare May 18, 2026 18:03
@robinbb robinbb force-pushed the robinbb-14492-l2-cctx-fields branch 5 times, most recently from b5c7e42 to c0de663 Compare May 19, 2026 20:08
@robinbb robinbb force-pushed the robinbb-14492-l3-includes-refactor branch from d88da28 to 8dcb05b Compare May 19, 2026 20:12
@robinbb robinbb force-pushed the robinbb-14492-l2-cctx-fields branch 2 times, most recently from 693843e to 87f8132 Compare May 20, 2026 00:38
@robinbb robinbb force-pushed the robinbb-14492-l3-includes-refactor branch from 8dcb05b to 60b92c8 Compare May 20, 2026 01:01
@robinbb robinbb requested a review from Copilot May 20, 2026 02:12
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.

@robinbb robinbb force-pushed the robinbb-14492-l2-cctx-fields branch from 87f8132 to 6863ae5 Compare May 20, 2026 20:09
@robinbb robinbb force-pushed the robinbb-14492-l3-includes-refactor branch from 60b92c8 to dde100d Compare May 20, 2026 20:13
@robinbb robinbb marked this pull request as ready for review May 20, 2026 20:41
@robinbb robinbb force-pushed the robinbb-14492-l2-cctx-fields branch from 6863ae5 to 4298335 Compare May 21, 2026 01:20
@robinbb robinbb force-pushed the robinbb-14492-l3-includes-refactor branch from dde100d to 63c3651 Compare May 21, 2026 01:34
@robinbb robinbb force-pushed the robinbb-14492-l2-cctx-fields branch 2 times, most recently from 59744cf to ff3952d Compare May 21, 2026 20:39
@robinbb robinbb force-pushed the robinbb-14492-l3-includes-refactor branch from 63c3651 to 416e701 Compare May 21, 2026 20:46
Alizter added a commit that referenced this pull request May 22, 2026
…h cctx (#14514)

Layer 2 of 9 of #14492.

Threads `lib_index`, `has_virtual_impl`, and `pps_runtime_libs` through
`Compilation_context.t`. Adds `build_lib_index` (constructs the
`Lib_index` from the cctx's libs, indexing on post-pp modules for
non-staged-ppx local libs). Wires `~pps_runtime_libs` at all nine
`Compilation_context.create` call sites: computed from `Lib.Compile.pps
+ Lib.ppx_runtime_deps` at `Lib_rules`, `Exe_rules`, `Cinaps`, and
`Toplevel`; `Resolve.Memo.return []` at `Ppx_driver`, `Utop`, `Mdx`,
`Inline_tests`, and `Melange_rules`. Exposes `Dep_graph.dir` / `mem` for
layer 4's `can_filter` guard. Adds `Modules.as_singleton`.

`pps_runtime_libs` is a required parameter of
`Compilation_context.create` — no implicit default — so a new caller
cannot silently drop ppx runtime libs from the dep set under narrowing
(per @Alizter's review feedback). Fields are populated but never
consumed by L2's own logic; consumers arrive in layer 4.

Stack: rebases on `main` (L1 merged in #14513). Next: #14515.

Part of #14492. Related to #4572.
Base automatically changed from robinbb-14492-l2-cctx-fields to robinbb-14492-test-stack-integration May 22, 2026 19:17
Behavior-equivalent restructuring that opens the lib-deps computation to
per-module filtering in a follow-up. No test promotions.

[Compilation_context.Includes.make] previously emitted both [-I]/[-H]
include flags AND [Hidden_deps] for the cctx's libs in a single
[Command.Args.t]. The opaque-aware [Cmx] case duplicated the deps logic
that already exists in [Lib_file_deps.deps_of_entries]. Simplified:
[Includes.t] now carries only the include flags; the [~opaque] parameter
(and the [for_module_generated_at_link_time] call site) drops out.

[Module_compilation]:
- [lib_deps_for_module]: scaffold form, returns
  [(cctx_includes, deps_of_entries libs)] where [libs = requires_compile
  @ requires_hidden]. The per-module tight filter activates in a
  follow-up; arguments [obj_dir], [for_], [dep_graph], [ml_kind], [mode]
  are threaded but ignored here.
- [lib_cm_deps]: wraps [lib_deps_for_module] with
  [Action_builder.dyn_deps], yielding the include args and registering
  the lib file deps.
- [build_cm]: gated route — [Alias _] (non-stdlib) and [Wrapped_compat]
  modules short-circuit to the cctx's now-flag-only [Includes] (no lib
  deps, matching prior behavior since [Includes.empty] was used for
  these); all other module kinds call [lib_cm_deps]. Replace the
  in-line [Includes] lookup at the [Command.run] site with
  [Command.Args.Dyn lib_cm_deps].
- [ocamlc_i]: same swap.

Combined: every consumer that previously read [-I]/[-H] + [Hidden_deps]
from [Includes] now reads [-I]/[-H] from [Includes] and the deps from
[deps_of_entries] (via [lib_cm_deps]). Same flags, same deps. The
[Alias]/[Wrapped_compat] short-circuit preserves the prior
"no-lib-deps" behavior for those module kinds.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-14492-test-stack-integration branch from 580fc34 to e0f2a6d Compare May 22, 2026 21:16
@robinbb robinbb force-pushed the robinbb-14492-l3-includes-refactor branch from 416e701 to 1c1953d Compare May 22, 2026 21:16
@robinbb robinbb merged commit c8ab405 into robinbb-14492-test-stack-integration May 23, 2026
31 checks passed
@robinbb robinbb deleted the robinbb-14492-l3-includes-refactor branch May 23, 2026 04:51
robinbb added a commit that referenced this pull request May 23, 2026
Layer 3 of 9 of #14492. Behaviour-equivalent refactor.

`Compilation_context.Includes.make` drops `~opaque` and stops emitting
`Hidden_deps`; `Includes.t` carries only `-I`/`-H` flags.
`Module_compilation.lib_deps_for_module` (scaffold form: always-glob)
and `lib_cm_deps` wire the dep set back in via `deps_of_entries`.
`build_cm` and `ocamlc_i` are switched to consume `lib_cm_deps`; `Alias`
/ `Wrapped_compat` short-circuit to the cctx's now-flag-only `Includes`.
`Lib_file_deps.deps_with_exts` removed — only used by the old `Cmx` arm
of `Includes.make`.

Combined effect: same `-I` / `-H`, same lib file deps.

Stack: rebases on #14514. Next: #14516.

Part of #14492. Related to #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.

3 participants