From 3359f34e2d622f858a783bfe7a133343d0f5866b Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 15 Jan 2020 16:49:17 +0000 Subject: [PATCH] Fix #2974 Signed-off-by: Jeremie Dimino Co-Authored-By: Andrey Mokhov --- CHANGES.md | 6 ++++++ src/dune/lib.ml | 29 +++++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 93e578239d7..ebee643aa35 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +2.1.3 (unreleased) +------------------ + +- Fix building the OCaml compiler with Dune (#3038, fixes #2974, + @diml) + 2.1.2 (08/01/2020) ------------------ diff --git a/src/dune/lib.ml b/src/dune/lib.ml index a1c7b205edc..229c4c1240b 100644 --- a/src/dune/lib.ml +++ b/src/dune/lib.ml @@ -426,17 +426,26 @@ module Link_params = struct | Native -> List.rev_append (Lib_info.native_archives t.info) lib_files in let include_dirs = - let dirs files = - List.sort_uniq ~compare:Path.compare (List.map files ~f:Path.parent_exn) - (* TODO: Remove the above unsafe call to [parent_exn] by separating - files and directories at the type level. Then any file will have a - well-defined parent directory, possibly ".". *) + let files = + match mode with + | Byte -> dll_files + | Byte_with_stubs_statically_linked_in + | Native -> + lib_files in - match mode with - | Byte -> dirs dll_files - | Byte_with_stubs_statically_linked_in - | Native -> - dirs lib_files + let files = + match Lib_info.exit_module t.info with + | None -> files + | Some _ -> + (* The exit module is copied next to the archive, so we add the + archive here so that its directory ends up in [include_dirs]. *) + files @ deps + in + (* TODO: Remove the below unsafe call to [parent_exn] by separating files + and directories at the type level. Then any file will have a + well-defined parent directory, possibly ".". *) + let dirs = List.map files ~f:Path.parent_exn in + List.sort_uniq dirs ~compare:Path.compare in let hidden_deps = match Lib_info.exit_module t.info with