Skip to content

Commit

Permalink
fix(rules): stdlib module layout
Browse files Browse the repository at this point in the history
include dependencies for stdlib alias, decode correctly

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
  • Loading branch information
anmonteiro authored and rgrinberg committed Feb 22, 2023
1 parent d9936f1 commit 3f19244
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
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)
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]

0 comments on commit 3f19244

Please sign in to comment.