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

No longer read installed META files for compiler libraries (-> fix "vmthreads only exists in OCaml < 4.09") #4946

Merged
merged 5 commits into from
Sep 28, 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 @@ -195,6 +195,9 @@ Unreleased
- No longer reference deprecated Toploop functions when using dune files in
OCaml syntax. (#4834, fixes #4830, @nojb)

- Dune no longer reads installed META files for libraries distributed with the
compiler, instead using its own internal database. (#4946, @nojb)

2.9.1 (07/09/2021)
------------------

Expand Down
4 changes: 4 additions & 0 deletions doc/advanced-topics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ set of predicates:
it is linked as part of a driver or meant to add a ``-ppx`` argument
to the compiler, choose the former behavior

Note that Dune does not read *installed* ``META`` files for libraries
distributed with the compiler (as these files are not installed by the compiler
itself, but installed by `ocamlfind`, and are not always perfectly
accurate). Instead Dune uses its own internal database for this information.

Dynamic loading of packages with findlib
========================================
Expand Down
13 changes: 6 additions & 7 deletions src/dune_rules/findlib/findlib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -568,12 +568,7 @@ end = struct
| [] -> (
match Package.Name.to_string name with
| "dune" -> Memo.Build.return (Ok builtin_for_dune)
| _ -> (
match Package.Name.Map.find db.builtins name with
| None -> Memo.Build.return (Error Unavailable_reason.Not_found)
| Some meta ->
let+ builtin = load_builtin db meta in
Ok builtin))
| _ -> Memo.Build.return (Error Unavailable_reason.Not_found))
| dir :: dirs -> (
let dir = Path.relative dir (Package.Name.to_string name) in
let* dir_exists = Fs_memo.path_exists dir in
Expand All @@ -599,7 +594,11 @@ end = struct
| None -> loop dirs
| Some p -> Memo.Build.return (Ok p)))
in
loop db.paths
match Package.Name.Map.find db.builtins name with
| None -> loop db.paths
| Some meta ->
let+ builtin = load_builtin db meta in
Ok builtin
end

let memo =
Expand Down
42 changes: 20 additions & 22 deletions src/dune_rules/findlib/meta.ml
Original file line number Diff line number Diff line change
Expand Up @@ -238,27 +238,31 @@ let builtins ~stdlib_dir ~version:ocaml_version =
in
let dynlink = simple "dynlink" [] ~dir:"+" in
let bytes = dummy "bytes" in
let result = dummy "result" in
let uchar = dummy "uchar" in
let seq = dummy "seq" in
let threads =
{ name = Some (Lib_name.of_string "threads")
; entries =
[ version
; main_modules [ "thread" ]
; requires ~preds:[ Pos "mt"; Pos "mt_vm" ] [ "threads.vm" ]
; requires ~preds:[ Pos "mt"; Pos "mt_posix" ] [ "threads.posix" ]
; directory "+"
; rule "type_of_threads" [] Set "posix"
; rule "error" [ Neg "mt" ] Set "Missing -thread or -vmthread switch"
; rule "error"
[ Neg "mt_vm"; Neg "mt_posix" ]
Set "Missing -thread or -vmthread switch"
; Package
(simple "vm" [ "unix" ] ~dir:"+vmthreads" ~archive_name:"threads")
; Package
(simple "posix" [ "unix" ] ~dir:"+threads" ~archive_name:"threads")
]
([ version
; main_modules [ "thread" ]
; requires ~preds:[ Pos "mt"; Pos "mt_vm" ] [ "threads.vm" ]
; requires ~preds:[ Pos "mt"; Pos "mt_posix" ] [ "threads.posix" ]
; directory "+"
; rule "type_of_threads" [] Set "posix"
; rule "error" [ Neg "mt" ] Set "Missing -thread or -vmthread switch"
; rule "error"
[ Neg "mt_vm"; Neg "mt_posix" ]
Set "Missing -thread or -vmthread switch"
; Package
(simple "posix" [ "unix" ] ~dir:"+threads" ~archive_name:"threads")
]
@
if Ocaml_version.has_vmthreads ocaml_version then
[ Package
(simple "vm" [ "unix" ] ~dir:"+vmthreads" ~archive_name:"threads")
]
else
[])
}
in
let num =
Expand Down Expand Up @@ -288,12 +292,6 @@ let builtins ~stdlib_dir ~version:ocaml_version =
; ocamldoc
]
in
let base =
if Ocaml_version.pervasives_includes_result ocaml_version then
result :: base
else
base
in
let base =
if Ocaml_version.stdlib_includes_uchar ocaml_version then
uchar :: base
Expand Down
4 changes: 2 additions & 2 deletions src/dune_rules/ocaml_version.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ let supports_response_file version = version >= (4, 05, 0)

let ocamlmklib_supports_response_file version = version >= (4, 08, 0)

let pervasives_includes_result version = version >= (4, 03, 0)

let stdlib_includes_uchar version = version >= (4, 03, 0)

let stdlib_includes_bigarray version = version >= (4, 07, 0)
Expand Down Expand Up @@ -49,3 +47,5 @@ let custom_or_output_complete_exe version =
let ocamlopt_always_calls_library_linker version = version < (4, 12, 0)

let has_sys_opaque_identity version = version >= (4, 3, 0)

let has_vmthreads version = version < (4, 9, 0)
6 changes: 3 additions & 3 deletions src/dune_rules/ocaml_version.mli
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ val supports_response_file : t -> bool
(** Does ocamlmklib support [-args0]? *)
val ocamlmklib_supports_response_file : t -> bool

(** Whether [Pervasives] includes the [result] type *)
val pervasives_includes_result : t -> bool

(** Whether the standard library includes the [Uchar] module *)
val stdlib_includes_uchar : t -> bool

Expand Down Expand Up @@ -68,3 +65,6 @@ val ocamlopt_always_calls_library_linker : t -> bool

(** Whether [Sys.opaque_identity] is in the standard library *)
val has_sys_opaque_identity : t -> bool

(** Whether [vmthreads] exists *)
val has_vmthreads : t -> bool
6 changes: 0 additions & 6 deletions test/blackbox-tests/test-cases/merlin/merlin-tests.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ CRAM sanitization
X
((STDLIB /OCAMLC_WHERE)
(EXCLUDE_QUERY_DIR)
(B lib/bytes)
(B lib/findlib)
(B /OCAMLC_WHERE)
(B
$TESTCASE_ROOT/_build/default/exe/.x.eobjs/byte)
(B
$TESTCASE_ROOT/_build/default/lib/.foo.objs/public_cmi)
(S lib/bytes)
(S lib/findlib)
(S /OCAMLC_WHERE)
(S
Expand Down Expand Up @@ -65,12 +63,10 @@ CRAM sanitization
Privmod
((STDLIB /OCAMLC_WHERE)
(EXCLUDE_QUERY_DIR)
(B lib/bytes)
(B lib/findlib)
(B /OCAMLC_WHERE)
(B
$TESTCASE_ROOT/_build/default/lib/.foo.objs/byte)
(S lib/bytes)
(S lib/findlib)
(S /OCAMLC_WHERE)
(S
Expand All @@ -87,12 +83,10 @@ CRAM sanitization
Foo
((STDLIB /OCAMLC_WHERE)
(EXCLUDE_QUERY_DIR)
(B lib/bytes)
(B lib/findlib)
(B /OCAMLC_WHERE)
(B
$TESTCASE_ROOT/_build/default/lib/.foo.objs/byte)
(S lib/bytes)
(S lib/findlib)
(S /OCAMLC_WHERE)
(S
Expand Down