Skip to content

test: document inter-library recompilation behavior (#4572) - #14017

Merged
shonfeder merged 1 commit into
ocaml:mainfrom
robinbb:robinbb-issue-4572-baseline-tests
Apr 7, 2026
Merged

shonfeder merged 1 commit into
ocaml:mainfrom
robinbb:robinbb-issue-4572-baseline-tests

Conversation

@robinbb

@robinbb robinbb commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add baseline tests documenting Dune's current inter-library recompilation
behavior, in preparation for eventually addressing #4572 (finer dependency
analysis between libraries).

Currently, Dune overapproximates by assuming that every module in a consuming
stanza depends on every module in its library dependencies. These tests
document that behavior across 9 scenarios:

  • basic-wrapped: all modules recompile when a wrapped library changes
  • transitive: all modules recompile when a transitive dependency changes
  • virtual-library: all modules recompile when a virtual library changes
  • multiple-libraries: changing one library recompiles users of all libraries
  • unwrapped: all modules recompile when any module in an unwrapped library changes
  • lib-to-lib-wrapped: library-to-library deps (wrapped), all inner modules recompile
  • lib-to-lib-unwrapped: library-to-library deps (unwrapped), all inner modules recompile
  • wrapped-compat: (wrapped (transition ...)) library, all inner modules recompile
  • opaque: interaction with opaque mode — release profile shows coarse recompilation; dev profile correctly avoids recompilation on implementation-only changes

No source code changes. Tests only.

Test plan

  • dune runtest test/blackbox-tests/test-cases/per-module-lib-deps/ passes
  • Related test suites unaffected (ocamldep, virtual-libraries, wrapped-transition, external-lib-deps)

Ref: #4572

@robinbb
robinbb force-pushed the robinbb-issue-4572-baseline-tests branch from b8ef260 to fc8f499 Compare April 2, 2026 23:23
@robinbb
robinbb marked this pull request as draft April 2, 2026 23:27

@Leonidas-from-XIV Leonidas-from-XIV left a comment

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.

I am concerned about dumping the list of calls into the tests as that list might change as Dune evolves. Instead I would suggest using sideeffects to show that a module was rebuilt and then check for that sideeffect.

This way if dune builds less or more the tests don't need to be changed in the future due to unrelated changes.

@robinbb
robinbb force-pushed the robinbb-issue-4572-baseline-tests branch 3 times, most recently from ca96e99 to 43bdd12 Compare April 3, 2026 21:53
@robinbb
robinbb marked this pull request as ready for review April 3, 2026 21:53
@robinbb

robinbb commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator Author

@Leonidas-from-XIV @rgrinberg I think I have made the PR according to your suggestions, now. So, after a rebase against 'main', I removed the 'draft' status, and would appreciate a passing review (if merited). If you see a passing CI and a passing review, feel free to merge it, too, please.

@robinbb
robinbb force-pushed the robinbb-issue-4572-baseline-tests branch 4 times, most recently from 99b35ea to 3f0a685 Compare April 6, 2026 15:41
@Alizter
Alizter requested review from Alizter and rgrinberg April 6, 2026 16:27
@robinbb
robinbb force-pushed the robinbb-issue-4572-baseline-tests branch 2 times, most recently from b7793c6 to fd06025 Compare April 6, 2026 17:06
…ml#4572)

Document the current behavior where all modules in a stanza are
recompiled when a library dependency's interface changes, even if
a module doesn't use that library. Five scenarios are tested:

1. Basic: wrapped library, module that doesn't reference it
2. Transitive: library A depends on B, module doesn't reference A
3. Virtual: virtual library, module that doesn't reference it
4. Multiple libraries: two libraries, modules using only one
5. Unwrapped: individual modules within an unwrapped library,
   with symmetric tests for changing each module independently

Each scenario shows the current stanza-level recompilation behavior
and annotates the expected improvement with TODO comments.

See: ocaml#4572
Signed-off-by: Robin Bate Boerop <[email protected]>
@robinbb
robinbb force-pushed the robinbb-issue-4572-baseline-tests branch from fd06025 to e35a3d1 Compare April 7, 2026 01:42

@Leonidas-from-XIV Leonidas-from-XIV left a comment

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.

LGTM

@shonfeder
shonfeder merged commit 0f2c483 into ocaml:main Apr 7, 2026
28 checks passed
@Alizter

Alizter commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

@shonfeder What is the rush? I self-requested a review and was still in the middle of one.

@robinbb
robinbb deleted the robinbb-issue-4572-baseline-tests branch April 7, 2026 17:44
@shonfeder

shonfeder commented Apr 7, 2026 •

Copy link
Copy Markdown
Member

No rush. I didn't see that you had re-requested review (too much noise in the history to track that imo). But it had been reviewed by you and changes addressed. You didn't mark it as "request changes", to signal you had a blocking concern. It was approved in a review, and passing CI, and it can't possible do any harm to merge. So it looked ready.

Feel free to add follow-ups if needed, or even revert if you think it's necessary for some reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants