Skip to content

Commit

Permalink
Fix bigarray config ocaml#5494
Browse files Browse the repository at this point in the history
Implementing "Select" rule and "Re_export" witch is the same as "Direct".

ocaml#5526 (comment)
is a good report for this fix.

Signed-off-by: Alpha DIALLO <[email protected]>
  • Loading branch information
moyodiallo committed Apr 20, 2022
1 parent 6c8d122 commit 4ebafd3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/dune_rules/lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1381,18 +1381,25 @@ end = struct
}

let resolve_complex_deps db deps ~private_deps : resolved_deps Memo.Build.t =
let ocaml_version = db.lib_config.ocaml_version in
let bigarray_in_std_libraries = Ocaml_version.has_bigarray_library ocaml_version in
let is_bigarray lib = String.equal "bigarray" (Lib_name.to_string lib) in
let resolve_select { Lib_dep.Select.result_fn; choices; loc } =
let open Memo.Build.O in
let+ res, src_fn =
let+ select =
Memo.Build.List.find_map choices
~f:(fun { required; forbidden; file } ->
let forbidden = Lib_name.Set.to_list forbidden in
if List.exists ~f:(fun lib -> is_bigarray lib && bigarray_in_std_libraries) forbidden
then Memo.Build.return None
else
let* exists =
Memo.Build.List.exists forbidden ~f:(available_internal db)
in
if exists then Memo.Build.return None
else
let required = Lib_name.Set.filter ~f:(fun lib -> not (is_bigarray lib) || bigarray_in_std_libraries) required in
Resolve.Build.peek
(let deps =
Lib_name.Set.fold required ~init:[] ~f:(fun x acc ->
Expand Down Expand Up @@ -1421,6 +1428,9 @@ end = struct
let open Memo.Build.O in
match (dep : Lib_dep.t) with
| Re_export (loc, name) ->
if is_bigarray name && not bigarray_in_std_libraries
then Memo.Build.return (acc_res, acc_selects, acc_re_exports)
else
let+ lib = resolve_dep db (loc, name) ~private_deps in
let open Resolve.O in
let acc_re_exports =
Expand All @@ -1435,11 +1445,9 @@ end = struct
in
(acc_res, acc_selects, acc_re_exports)
| Direct (loc, name) ->
let ocaml_version = db.lib_config.ocaml_version in
if String.equal "bigarray" (Lib_name.to_string name)
&& not (Ocaml_version.has_bigarray_library ocaml_version)
if is_bigarray name && not bigarray_in_std_libraries
then
Memo.Build.return (acc_res, acc_selects, acc_re_exports)
Memo.Build.return (acc_res, acc_selects, acc_re_exports)
else
let+ lib = resolve_dep db (loc, name) ~private_deps in
let acc_res =
Expand Down

0 comments on commit 4ebafd3

Please sign in to comment.