Skip to content

test: document single-module library recompilation behavior (#4572)#14103

Open
robinbb wants to merge 1 commit intoocaml:mainfrom
robinbb:robinbb-issue-4572-singleton
Open

test: document single-module library recompilation behavior (#4572)#14103
robinbb wants to merge 1 commit intoocaml:mainfrom
robinbb:robinbb-issue-4572-singleton

Conversation

@robinbb
Copy link
Copy Markdown
Contributor

@robinbb robinbb commented Apr 9, 2026

Summary

Add baseline test documenting that single-module library consumers are
unnecessarily recompiled when an unused dependency module changes. This
happens because dune skips ocamldep for singleton stanzas, so per-module
filtering cannot determine which libraries the module actually references.

The code change to remove the singleton skip is deferred to the per-module
filtering PR (#14021) where it is actually needed and can be tested
end-to-end.

Ref: #4572

Test plan

  • dune runtest test/blackbox-tests/test-cases/per-module-lib-deps/single-module-lib.t passes

Add baseline test showing that single-module library consumers are
recompiled when an unused module in a dependency changes. This happens
because dune skips ocamldep for singleton stanzas, preventing future
per-module filtering from determining which libraries the module
actually references.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-issue-4572-singleton branch from 6d8e65b to 76ace5e Compare April 9, 2026 14:00
@robinbb robinbb changed the title fix: run ocamldep for single-module stanzas (#4572) refactor: remove singleton ocamldep skip from internal dep_rules functions (#4572) Apr 9, 2026
@robinbb robinbb force-pushed the robinbb-issue-4572-singleton branch from 76ace5e to c66f5d2 Compare April 9, 2026 14:11
@robinbb robinbb changed the title refactor: remove singleton ocamldep skip from internal dep_rules functions (#4572) test: document single-module library recompilation behavior (#4572) Apr 9, 2026
@robinbb
Copy link
Copy Markdown
Contributor Author

robinbb commented Apr 9, 2026

@rgrinberg Thanks for your comments on #14079. In the end, I think that only this test can merge in isolation, so I closed that PR and made this one.

> EOF

uses_alpha is recompiled even though it only references Alpha, not Unused.
This is because dune skips ocamldep for single-module stanzas:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This explanation is not clear and possibly incomplete. The executable would still need to be rebuilt regardless of what modules are referenced by main.ml. This is because you still need to relink to produce the final executable and thus maintain all transitive cmx dependencies up to date.

The only thing you can save here perhaps not recompiling dune__exe__Main.cmx.

More details should be produced in the trace events to demonstrate which events you expect to see and which events will be dropped.

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