scaffold: thread Lib_index, has_virtual_impl, pps_runtime_libs through cctx#14514
Merged
Alizter merged 3 commits intoMay 22, 2026
Merged
Conversation
This was referenced May 13, 2026
a3ab9c8 to
55c7882
Compare
c804917 to
d37e419
Compare
There was a problem hiding this comment.
Pull request overview
This PR scaffolds dependency-filtering data through Compilation_context.t for later layers of the inter-library per-module dependency work.
Changes:
- Adds
lib_index,has_virtual_impl, andpps_runtime_libsto compilation contexts. - Builds a
Lib_file_deps.Lib_indexfrom direct/hidden library dependencies. - Exposes small helper APIs on
ModulesandDep_graph.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/dune_rules/modules.mli |
Exposes Modules.as_singleton. |
src/dune_rules/modules.ml |
Implements singleton detection for module sets. |
src/dune_rules/lib_rules.ml |
Passes PPX runtime libraries into library compilation contexts. |
src/dune_rules/exe_rules.ml |
Passes PPX runtime libraries into executable compilation contexts. |
src/dune_rules/dep_graph.mli |
Exposes dependency graph directory and membership helpers. |
src/dune_rules/dep_graph.ml |
Implements dependency graph directory and membership helpers. |
src/dune_rules/compilation_context.mli |
Adds accessors for lib index, virtual implementation status, and PPX runtime libraries. |
src/dune_rules/compilation_context.ml |
Stores new context fields and constructs the library dependency index. |
7459ded to
22fcd5f
Compare
Alizter
added a commit
that referenced
this pull request
May 14, 2026
#14513) 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.
0dfddde to
2d4b53c
Compare
686951f to
8a00b1d
Compare
robinbb
added a commit
that referenced
this pull request
May 19, 2026
The optional argument with default [Resolve.Memo.return []] hid the silent-wrongness Alizter flagged on #14514: a new caller that forgets to pass [~pps_runtime_libs] would silently drop ppx runtime libs from the must-glob set under narrowing. Make the parameter required. The five sites without a meaningful pps_runtime_libs to compute (ppx_driver, utop, mdx, inline_tests, melange) now pass [Resolve.Memo.return []] explicitly, documenting the absence at the call site rather than at the API. Melange compile rules bypass narrowing today (`can_filter = false` in module_compilation.ml), so the explicit empty preserves prior behaviour. utop's pps surface (collected from in-scope libraries) could in principle carry runtime libs; treat this as a separate follow-up rather than papering over via API. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
c0de663 to
693843e
Compare
8a00b1d to
ff735b8
Compare
robinbb
added a commit
that referenced
this pull request
May 20, 2026
The optional argument with default [Resolve.Memo.return []] hid the silent-wrongness Alizter flagged on #14514: a new caller that forgets to pass [~pps_runtime_libs] would silently drop ppx runtime libs from the must-glob set under narrowing. Make the parameter required. The five sites without a meaningful pps_runtime_libs to compute (ppx_driver, utop, mdx, inline_tests, melange) now pass [Resolve.Memo.return []] explicitly, documenting the absence at the call site rather than at the API. Melange compile rules bypass narrowing today (`can_filter = false` in module_compilation.ml), so the explicit empty preserves prior behaviour. utop's pps surface (collected from in-scope libraries) could in principle carry runtime libs; treat this as a separate follow-up rather than papering over via API. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
693843e to
87f8132
Compare
robinbb
added a commit
that referenced
this pull request
May 20, 2026
The optional argument with default [Resolve.Memo.return []] hid the silent-wrongness Alizter flagged on #14514: a new caller that forgets to pass [~pps_runtime_libs] would silently drop ppx runtime libs from the must-glob set under narrowing. Make the parameter required. The five sites without a meaningful pps_runtime_libs to compute (ppx_driver, utop, mdx, inline_tests, melange) now pass [Resolve.Memo.return []] explicitly, documenting the absence at the call site rather than at the API. Melange compile rules bypass narrowing today (`can_filter = false` in module_compilation.ml), so the explicit empty preserves prior behaviour. utop's pps surface (collected from in-scope libraries) could in principle carry runtime libs; treat this as a separate follow-up rather than papering over via API. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
robinbb
added a commit
that referenced
this pull request
May 20, 2026
The optional argument with default [Resolve.Memo.return []] hid the silent-wrongness Alizter flagged on #14514: a new caller that forgets to pass [~pps_runtime_libs] would silently drop ppx runtime libs from the must-glob set under narrowing. Make the parameter required. The five sites without a meaningful pps_runtime_libs to compute (ppx_driver, utop, mdx, inline_tests, melange) now pass [Resolve.Memo.return []] explicitly, documenting the absence at the call site rather than at the API. Melange compile rules bypass narrowing today (`can_filter = false` in module_compilation.ml), so the explicit empty preserves prior behaviour. utop's pps surface (collected from in-scope libraries) could in principle carry runtime libs; treat this as a separate follow-up rather than papering over via API. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
ff735b8 to
4ef93a0
Compare
87f8132 to
6863ae5
Compare
robinbb
added a commit
that referenced
this pull request
May 20, 2026
The optional argument with default [Resolve.Memo.return []] hid the silent-wrongness Alizter flagged on #14514: a new caller that forgets to pass [~pps_runtime_libs] would silently drop ppx runtime libs from the must-glob set under narrowing. Make the parameter required. The five sites without a meaningful pps_runtime_libs to compute (ppx_driver, utop, mdx, inline_tests, melange) now pass [Resolve.Memo.return []] explicitly, documenting the absence at the call site rather than at the API. Melange compile rules bypass narrowing today (`can_filter = false` in module_compilation.ml), so the explicit empty preserves prior behaviour. utop's pps surface (collected from in-scope libraries) could in principle carry runtime libs; treat this as a separate follow-up rather than papering over via API. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
4ef93a0 to
d4bfd08
Compare
robinbb
added a commit
that referenced
this pull request
May 21, 2026
The optional argument with default [Resolve.Memo.return []] hid the silent-wrongness Alizter flagged on #14514: a new caller that forgets to pass [~pps_runtime_libs] would silently drop ppx runtime libs from the must-glob set under narrowing. Make the parameter required. The five sites without a meaningful pps_runtime_libs to compute (ppx_driver, utop, mdx, inline_tests, melange) now pass [Resolve.Memo.return []] explicitly, documenting the absence at the call site rather than at the API. Melange compile rules bypass narrowing today (`can_filter = false` in module_compilation.ml), so the explicit empty preserves prior behaviour. utop's pps surface (collected from in-scope libraries) could in principle carry runtime libs; treat this as a separate follow-up rather than papering over via API. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
6863ae5 to
4298335
Compare
robinbb
added a commit
that referenced
this pull request
May 21, 2026
The optional argument with default [Resolve.Memo.return []] hid the silent-wrongness Alizter flagged on #14514: a new caller that forgets to pass [~pps_runtime_libs] would silently drop ppx runtime libs from the must-glob set under narrowing. Make the parameter required. The five sites without a meaningful pps_runtime_libs to compute (ppx_driver, utop, mdx, inline_tests, melange) now pass [Resolve.Memo.return []] explicitly, documenting the absence at the call site rather than at the API. Melange compile rules bypass narrowing today (`can_filter = false` in module_compilation.ml), so the explicit empty preserves prior behaviour. utop's pps surface (collected from in-scope libraries) could in principle carry runtime libs; treat this as a separate follow-up rather than papering over via API. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
d4bfd08 to
cb2c7c2
Compare
robinbb
added a commit
that referenced
this pull request
May 21, 2026
The optional argument with default [Resolve.Memo.return []] hid the silent-wrongness Alizter flagged on #14514: a new caller that forgets to pass [~pps_runtime_libs] would silently drop ppx runtime libs from the must-glob set under narrowing. Make the parameter required. The five sites without a meaningful pps_runtime_libs to compute (ppx_driver, utop, mdx, inline_tests, melange) now pass [Resolve.Memo.return []] explicitly, documenting the absence at the call site rather than at the API. Melange compile rules bypass narrowing today (`can_filter = false` in module_compilation.ml), so the explicit empty preserves prior behaviour. utop's pps surface (collected from in-scope libraries) could in principle carry runtime libs; treat this as a separate follow-up rather than papering over via API. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
4298335 to
59744cf
Compare
…h cctx Pure-additive scaffolding for #4572's per-module inter-library filter. Fields are populated but no consumer reads them yet; the per-module filter (which is the only caller) lands in a follow-up. [Compilation_context]: - [build_lib_index]: builds a [Lib_file_deps.Lib_index.t] from the cctx's direct + hidden libs. Each entry carries [Some Module.t] for unwrapped locals (tight-eligible) and [None] otherwise (wrapped locals / externals). Local libs whose source is preprocessed by a non-staged ppx are indexed on the post-pp module so the cross-lib walker reads ocamldep on the same source the dep lib's compile pipeline produces. - Three new fields on [t]: [lib_index] (Memo.Lazy.t computing the index), [has_virtual_impl] (Memo.Lazy.t flag — true iff any dep lib implements a virtual lib), and [pps_runtime_libs] (closure of ppx_runtime_libraries introduced by [pps] in this stanza, threaded through [create]). - Accessors for each. [for_module_generated_at_link_time] populates [lib_index] with a [Code_error.raise] sentinel — the per-module filter's [can_filter] guard prevents reaching it from synthesised link-time cctxs. [Lib_rules] / [Exe_rules]: compute [pps_runtime_libs] from the stanza's [compile_info] and thread it through [Compilation_context.create]. [Dep_graph]: expose [dir] and [mem]; the cross-lib walker's [can_filter] guard uses these to detect synthesised dummy graphs. [Modules]: add [as_singleton] returning [Some m] iff the module set is a single user-written module. Used by [build_lib_index] to detect the single-module-no-deps short-circuit case. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
The cinaps and toplevel `Compilation_context.create` call sites omit the new `?pps_runtime_libs` field, leaving it at the default `Resolve.Memo.return []`. Under the per-module narrowing introduced later in the stack, this silently drops ppx runtime libs from `must_glob_libs`, producing missing `.cmi` globs in the stanzas' compile rules. Compute and pass it via the same `Lib.Compile.pps` + `Lib.ppx_runtime_deps` pattern used in `exe_rules.ml` and `lib_rules.ml`. Melange bypasses narrowing (`can_filter = false`) so it keeps the optional default and is unaffected today. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
The optional argument with default [Resolve.Memo.return []] hid the silent-wrongness Alizter flagged on #14514: a new caller that forgets to pass [~pps_runtime_libs] would silently drop ppx runtime libs from the must-glob set under narrowing. Make the parameter required. The five sites without a meaningful pps_runtime_libs to compute (ppx_driver, utop, mdx, inline_tests, melange) now pass [Resolve.Memo.return []] explicitly, documenting the absence at the call site rather than at the API. Melange compile rules bypass narrowing today (`can_filter = false` in module_compilation.ml), so the explicit empty preserves prior behaviour. utop's pps surface (collected from in-scope libraries) could in principle carry runtime libs; treat this as a separate follow-up rather than papering over via API. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
cb2c7c2 to
62fb631
Compare
59744cf to
ff3952d
Compare
robinbb
added a commit
that referenced
this pull request
May 22, 2026
The optional argument with default [Resolve.Memo.return []] hid the silent-wrongness Alizter flagged on #14514: a new caller that forgets to pass [~pps_runtime_libs] would silently drop ppx runtime libs from the must-glob set under narrowing. Make the parameter required. The five sites without a meaningful pps_runtime_libs to compute (ppx_driver, utop, mdx, inline_tests, melange) now pass [Resolve.Memo.return []] explicitly, documenting the absence at the call site rather than at the API. Melange compile rules bypass narrowing today (`can_filter = false` in module_compilation.ml), so the explicit empty preserves prior behaviour. utop's pps surface (collected from in-scope libraries) could in principle carry runtime libs; treat this as a separate follow-up rather than papering over via API. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
Alizter
approved these changes
May 22, 2026
Alizter
left a comment
Collaborator
There was a problem hiding this comment.
There is no noticeable change that I've seen from reviewing this. The nature of being an interim PR means I've had to relax scrutiny especially for redundant or copy-pasted code. The implicit assumption is that this can be cleaned up in a future PR once the main features they are leading towards are merged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Layer 2 of 9 of #14492.
Threads
lib_index,has_virtual_impl, andpps_runtime_libsthroughCompilation_context.t. Addsbuild_lib_index(constructs theLib_indexfrom the cctx's libs, indexing on post-pp modules for non-staged-ppx local libs). Wires~pps_runtime_libsat all nineCompilation_context.createcall sites: computed fromLib.Compile.pps + Lib.ppx_runtime_depsatLib_rules,Exe_rules,Cinaps, andToplevel;Resolve.Memo.return []atPpx_driver,Utop,Mdx,Inline_tests, andMelange_rules. ExposesDep_graph.dir/memfor layer 4'scan_filterguard. AddsModules.as_singleton.pps_runtime_libsis a required parameter ofCompilation_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.