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

stdlib: include dependencies for stdlib alias, decode correctly #7154

Merged
merged 1 commit into from
Feb 22, 2023
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 @@ -21,6 +21,9 @@ Unreleased
be used as dependencies of libraries in the workspace (eg when compiling to
bytecode and/or Javascript). This is now fixed. (#7151, @nojb)

- Allow the main module of a library with `(stdlib ...)` to depend on other
libraries (#7154, @anmonteiro).

3.7.0 (2023-02-17)
------------------

Expand Down
8 changes: 4 additions & 4 deletions src/dune_rules/compilation_context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -224,21 +224,21 @@ let for_alias_module t alias_module =
Sandbox_config.needs_sandboxing
else Sandbox_config.no_special_requirements
in
let modules : modules =
let (modules, includes) : modules * Includes.t =
match Modules.is_stdlib_alias t.modules.modules alias_module with
| false -> singleton_modules alias_module
| false -> (singleton_modules alias_module, Includes.empty)
| true ->
(* The stdlib alias module is different from the alias modules usually
produced by Dune: it contains code and depends on a few other
[CamlinnternalXXX] modules from the stdlib, so we need the full set of
modules to compile it. *)
t.modules
(t.modules, t.includes)
in
{ t with
flags =
Ocaml_flags.append_common flags
[ "-w"; "-49"; "-nopervasives"; "-nostdlib" ]
; includes = Includes.empty
; includes
; stdlib = None
; sandbox
; modules
Expand Down
2 changes: 1 addition & 1 deletion src/dune_rules/modules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module Stdlib = struct
and+ modules = modules ~src_dir ()
and+ exit_module = field_o "exit_module" Module_name.decode
and+ unwrapped =
field ~default:[] "unwrapped" (repeat (enter Module_name.decode))
field ~default:[] "unwrapped" (repeat Module_name.decode)
rgrinberg marked this conversation as resolved.
Show resolved Hide resolved
in
let unwrapped = Module_name.Set.of_list unwrapped in
{ modules; main_module_name; exit_module; unwrapped })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,10 @@ Test dependency on installed package
ocamlc .b.objs/byte/b.{cmi,cmo,cmt}
ocamldep .b.objs/b__Bar.impl.d
ocamlopt .b.objs/native/b.{cmx,o}
File "$TESTCASE_ROOT/prefix/lib/a/dune-package", line 40, characters 14-38:
40 | (unwrapped CamlinternalFormatBasics))))
^^^^^^^^^^^^^^^^^^^^^^^^
Error: List expected
-> required by library "b" in _build/default
-> required by _build/default/META.b
-> required by _build/install/default/lib/b/META
-> required by _build/default/b.install
-> required by alias install
ocamlc .b.objs/byte/b__Bar.{cmi,cmo,cmt}
ocamlopt .b.objs/native/b__Bar.{cmx,o}
ocamlc b.cma
ocamlopt b.{a,cmxa}
ocamlopt b.cmxs
Leaving directory 'b'
[1]