File tree Expand file tree Collapse file tree 5 files changed +44
-6
lines changed
test/blackbox-tests/test-cases/root-module Expand file tree Collapse file tree 5 files changed +44
-6
lines changed Original file line number Diff line number Diff line change 1+ - Don't run ocamldep to compute false dependencies on the ` root_module `
2+ (#12227 , @rgrinberg )
Original file line number Diff line number Diff line change @@ -137,15 +137,15 @@ let rec deps_of
137137 ~ml_kind
138138 (m : Modules.Sourced_module.t )
139139 =
140- let is_alias =
140+ let is_alias_or_root =
141141 match m with
142142 | Impl_of_virtual_module _ -> false
143143 | Imported_from_vlib m | Normal m ->
144144 (match Module. kind m with
145- | Alias _ -> true
145+ | Root | Alias _ -> true
146146 | _ -> false )
147147 in
148- if is_alias
148+ if is_alias_or_root
149149 then Memo. return (Action_builder. return [] )
150150 else (
151151 let skip_if_source_absent f sourced_module =
@@ -176,7 +176,7 @@ let has_single_file modules = Option.is_some @@ Modules.With_vlib.as_singleton m
176176
177177let immediate_deps_of unit modules ~obj_dir ~ml_kind =
178178 match Module. kind unit with
179- | Alias _ -> Action_builder. return []
179+ | Root | Alias _ -> Action_builder. return []
180180 | Wrapped_compat ->
181181 let interface_module =
182182 match Modules.With_vlib. lib_interface modules with
Original file line number Diff line number Diff line change @@ -618,7 +618,7 @@ module Module = struct
618618 match (dep : Dep.t ) with
619619 | Immediate (m , _ ) | Transitive (m , _ ) ->
620620 (match Module. kind m with
621- | Module.Kind. Alias _ -> None
621+ | Module.Kind. Alias _ | Root -> None
622622 | _ ->
623623 let dir = obj_dir t in
624624 let name = Dep. basename dep in
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ let parse_deps_exn =
109109let transitive_deps =
110110 let transive_dep obj_dir m =
111111 (match Module. kind m with
112- | Alias _ -> None
112+ | Root | Alias _ -> None
113113 | _ -> if Module. has m ~ml_kind: Intf then Some Ml_kind. Intf else Some Impl )
114114 |> Option. map ~f: (fun ml_kind ->
115115 Obj_dir.Module. dep obj_dir (Transitive (m, ml_kind))
Original file line number Diff line number Diff line change 1+ Demonstrate if we're running ocamldep for the root module. There should be no
2+ need to do so since this module cannot depend on any other module in the same
3+ compilation unit.
4+
5+ $ cat > dune-project << EOF
6+ > (lang dune 3.20 )
7+ > EOF
8+
9+ $ mkdir lib /
10+ $ cat > lib / dune << EOF
11+ > (library
12+ > (name bar))
13+ > EOF
14+ $ touch lib / bar. ml
15+
16+ $ cat > dune << EOF
17+ > (library
18+ > (name foo)
19+ > (libraries bar)
20+ > (root_module root))
21+ > EOF
22+
23+ $ dune build foo. cma
24+
25+ $ find _build/ default /. foo. objs | grep -i root | sort -u
26+ _build/ default /. foo. objs/ byte/ foo__Root. cmi
27+ _build/ default /. foo. objs/ byte/ foo__Root. cmo
28+ _build/ default /. foo. objs/ byte/ foo__Root. cmt
29+
30+ Not only is running ocamldep wasteful, but it can also lead to cycles:
31+
32+ $ cat > bar. ml << EOF
33+ > module X = Root. Bar
34+ > EOF
35+
36+ $ dune build foo. cma
You can’t perform that action at this time.
0 commit comments