Skip to content

fix: deduplicate entry modules in root_module stanza#14135

Open
robinbb wants to merge 2 commits intoocaml:mainfrom
robinbb:fix/root-module-duplicate-6148
Open

fix: deduplicate entry modules in root_module stanza#14135
robinbb wants to merge 2 commits intoocaml:mainfrom
robinbb:fix/root-module-duplicate-6148

Conversation

@robinbb
Copy link
Copy Markdown
Contributor

@robinbb robinbb commented Apr 11, 2026

Summary

Fixes #6148.

When findlib sub-packages share a directory with their parent package (e.g., logs.lwt installed alongside logs), dune guesses entry modules by scanning the directory. Both packages report the same modules, causing duplicate module X = X lines in root.ml-gen and a compilation error:

File "root.ml-gen", line 3, characters 0-18:
3 | module Logs = Logs
    ^^^^^^^^^^^^^^^^^^
Error: Multiple definition of the module name Logs.

The fix deduplicates module names via Module_name.Set in Root_module.entries before they are written to root.ml-gen.

  • src/dune_rules/root_module.ml — deduplicate the concatenated entry module list
  • test/blackbox-tests/test-cases/root-module/root-module-duplicate.t — update test to expect success
  • boot/libs.ml — re-sorted entries from bootstrap picking up the new Set-based ordering

Test plan

  • root-module-duplicate.t now passes (was documenting the bug)
  • All other root-module/*.t tests still pass
  • dune build @check passes

When findlib sub-packages share a directory with their parent package
(e.g., logs.lwt installed alongside logs), dune guesses entry modules
by scanning the directory. Both packages report the same modules,
causing duplicate `module X = X` lines in root.ml-gen and a
compilation error.

Fix by deduplicating module names via Module_name.Set before generating
the root module source.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the fix/root-module-duplicate-6148 branch from 70706ff to 2c55423 Compare April 11, 2026 01:58
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.

root_module generates duplicate module definition when logs.lwt is a dependency.

1 participant