diff --git a/CHANGES.md b/CHANGES.md index 0c48a637851..800eafd6adf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -151,6 +151,9 @@ Unreleased `INSIDE_EMACS` in order to improve reproducibility (#4680, @jeremiedimino) +- Fix `root_module` when used in public libraries (#4685, fixes #4684, + @rgrinberg, @CraigFe) + 2.9.0 (unreleased) ------------------ diff --git a/src/dune_rules/dune_file.ml b/src/dune_rules/dune_file.ml index 1ecfc84d6d4..85a9af05c8b 100644 --- a/src/dune_rules/dune_file.ml +++ b/src/dune_rules/dune_file.ml @@ -789,7 +789,12 @@ module Library = struct false in Obj_dir.make_lib ~dir - ~has_private_modules:(t.private_modules <> None) + ~has_private_modules: + ((* TODO instead of this fragile approximation, we should be looking at + [Modules.t] and deciding. Unfortunately, [Obj_dir.t] is currently + used in some places where [Modules.t] is not yet constructed. *) + t.private_modules <> None + || t.buildable.root_module <> None) ~private_lib (snd t.name) let main_module_name t : Lib_info.Main_module_name.t = diff --git a/test/blackbox-tests/test-cases/github4684.t b/test/blackbox-tests/test-cases/github4684.t index 4cf54ec6633..99935e1df9f 100644 --- a/test/blackbox-tests/test-cases/github4684.t +++ b/test/blackbox-tests/test-cases/github4684.t @@ -12,80 +12,4 @@ build failure: > EOF $ dune build - Internal error, please report upstream including the contents of _build/log. - Description: - ("External.cm_dir", - { t = - { public_dir = In_build_dir "default" - ; private_dir = None - ; public_cmi_dir = None - } - }) - Raised at file "otherlibs/stdune-unstable/code_error.ml", line 11, characters - 30-62 - Called from file "src/dune_rules/install_rules.ml", line 148, characters - 19-69 - Called from file "src/dune_rules/install_rules.ml" (inlined), line 165, - characters 23-31 - Called from file "src/dune_rules/install_rules.ml", line 180, characters - 49-63 - Called from file "list.ml", line 103, characters 22-25 - Called from file "otherlibs/stdune-unstable/list.ml", line 5, characters - 19-33 - Called from file "list.ml", line 103, characters 22-25 - Called from file "otherlibs/stdune-unstable/list.ml" (inlined), line 5, - characters 19-33 - Called from file "otherlibs/stdune-unstable/list.ml", line 40, characters - 29-39 - Called from file "src/dune_rules/install_rules.ml", line 155, characters - 6-1023 - Called from file "src/fiber/fiber.ml", line 182, characters 9-14 - Re-raised at file "otherlibs/stdune-unstable/exn.ml", line 36, characters - 27-56 - Called from file "src/fiber/fiber.ml", line 204, characters 8-13 - Re-raised at file "otherlibs/stdune-unstable/exn.ml", line 36, characters - 27-56 - Called from file "src/fiber/fiber.ml", line 204, characters 8-13 - Re-raised at file "otherlibs/stdune-unstable/exn.ml", line 36, characters - 27-56 - Called from file "src/fiber/fiber.ml", line 204, characters 8-13 - Re-raised at file "otherlibs/stdune-unstable/exn.ml", line 36, characters - 27-56 - Called from file "src/fiber/fiber.ml", line 204, characters 8-13 - Re-raised at file "otherlibs/stdune-unstable/exn.ml", line 36, characters - 27-56 - Called from file "src/fiber/fiber.ml", line 204, characters 8-13 - Re-raised at file "otherlibs/stdune-unstable/exn.ml", line 36, characters - 27-56 - Called from file "src/fiber/fiber.ml", line 204, characters 8-13 - Re-raised at file "otherlibs/stdune-unstable/exn.ml", line 36, characters - 27-56 - Called from file "src/fiber/fiber.ml", line 204, characters 8-13 - Re-raised at file "otherlibs/stdune-unstable/exn.ml", line 36, characters - 27-56 - Called from file "src/fiber/fiber.ml", line 204, characters 8-13 - Re-raised at file "otherlibs/stdune-unstable/exn.ml", line 36, characters - 27-56 - Called from file "src/fiber/fiber.ml", line 472, characters 10-22 - Called from file "src/fiber/fiber.ml", line 127, characters 10-17 - Re-raised at file "otherlibs/stdune-unstable/exn.ml", line 36, characters - 27-56 - Called from file "src/fiber/fiber.ml", line 204, characters 8-13 - Re-raised at file "otherlibs/stdune-unstable/exn.ml", line 36, characters - 27-56 - Called from file "src/fiber/fiber.ml", line 204, characters 8-13 - -> required by ("stanzas-to-entries", "default") - -> required by ("", ()) - -> required by ("", ()) - -> required by ("", ()) - -> required by ("", ()) - -> required by ("load-dir", In_build_dir "default") - -> required by ("build-alias", { dir = "default"; name = "default" }) - - I must not crash. Uncertainty is the mind-killer. Exceptions are the - little-death that brings total obliteration. I will fully express my cases. - Execution will pass over me and through me. And when it has gone past, I - will unwind the stack along its path. Where the cases are handled there will - be nothing. Only I will remain. - [1]