Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a reproduction case for issue #4684 #4685

Merged
merged 2 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------

Expand Down
7 changes: 6 additions & 1 deletion src/dune_rules/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm okay with the change and the todo. Unrelated to the current problem, I was just wondering why we are not testing if the alias file is hidden by a user given interface for a wrapped library. But it is perhaps not installed at all, always public?

Copy link
Member

Choose a reason for hiding this comment

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

The alias file is never hidden, and is always public - even in the presence of a user given interface file. We experimented with making it private before but it never worked.

~private_lib (snd t.name)

let main_module_name t : Lib_info.Main_module_name.t =
Expand Down
15 changes: 15 additions & 0 deletions test/blackbox-tests/test-cases/github4684.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Combining `(root_module ...)` with a public library results in an unexpected
build failure:

$ echo "module X = Root.Unix" > main.ml
$ touch main.opam
$ cat >dune <<EOF
> (library
> (name main)
> (public_name main)
> (root_module root)
> (libraries unix))
> EOF

$ dune build