Skip to content

Commit

Permalink
fix: plugin loading
Browse files Browse the repository at this point in the history
Loading using the findlib loader was broken in 3.7.0. This PR restores
the functionality

Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
  • Loading branch information
anmonteiro authored and rgrinberg committed Apr 15, 2023
1 parent 4d1dabd commit f9eadb0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Unreleased
----------

- Fix plugin loading with findlib. The functionality was broken in 3.7.0.
(#7556, @anmonteiro)

- Introduce a `public_headers` field on libraries. This field is like
`install_c_headers`, but it allows to choose the extension and choose the
paths for the installed headers. (#7512, @rgrinberg)
Expand Down
23 changes: 15 additions & 8 deletions src/dune_rules/link_time_code_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ type t = Link_time_code_gen_type.t =
; force_linkall : bool
}

let generate_and_compile_module cctx ~precompiled_cmi ~name ~lib ~code ~requires
=
let generate_and_compile_module cctx ~precompiled_cmi ~obj_name ~name ~lib ~code
~requires =
let sctx = Compilation_context.super_context cctx in
let open Memo.O in
let* module_ =
let+ modules = Dir_contents.modules_of_lib sctx lib in
let obj_name =
Option.map modules ~f:(fun modules ->
let mli_only = Modules.find modules name |> Option.value_exn in
Module.obj_name mli_only)
match obj_name with
| Some _ -> obj_name
| None ->
Option.map modules ~f:(fun modules ->
Modules.find modules name |> Option.value_exn |> Module.obj_name)
in
let src_dir =
let obj_dir = Compilation_context.obj_dir cctx in
Expand Down Expand Up @@ -242,6 +244,7 @@ let handle_special_libs cctx =
| Build_info { data_module; api_version } ->
let& module_ =
generate_and_compile_module cctx ~name:data_module ~lib
~obj_name:None
~code:
(Action_builder.of_memo
(build_info_code cctx ~libs:all_libs ~api_version))
Expand All @@ -268,8 +271,11 @@ let handle_special_libs cctx =
[ dynlink; findlib ]
in
let& module_ =
generate_and_compile_module cctx ~lib
~name:(Module_name.of_string "findlib_initl")
let name = Module_name.of_string "findlib_initl" in
let obj_name =
Some (Module_name.Unique.of_name_assuming_needs_no_mangling name)
in
generate_and_compile_module ~obj_name cctx ~lib ~name
~code:
(Action_builder.return
(findlib_init_code
Expand All @@ -291,7 +297,8 @@ let handle_special_libs cctx =
else Action_builder.return (dune_site_code ())
in
let& module_ =
generate_and_compile_module cctx ~name:data_module ~lib ~code
generate_and_compile_module cctx ~obj_name:None ~name:data_module
~lib ~code
~requires:(Resolve.Memo.return [ lib ])
~precompiled_cmi:true
in
Expand Down
23 changes: 15 additions & 8 deletions test/blackbox-tests/test-cases/builtin-support-override.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ Create a library called `findlib.dynload`
> EOF
$ cat > findlib/dune <<EOF
> (library
> (name findlib_dynload)
> (public_name findlib.dynload)
> (wrapped false)
> (special_builtin_support findlib_dynload))
> (name findlib_dynload)
> (public_name findlib.dynload)
> (wrapped false)
> (libraries findlib dynlink)
> (modules fl_dynload)
> (special_builtin_support findlib_dynload))
> (library
> (public_name findlib)
> (modules findlib))
> EOF
$ cat >findlib/findlib.ml <<EOF
> type x = Record_core
> let record_package _ _ = assert false
> let record_package_predicates _ _ = assert false
> EOF
$ touch findlib/fl_dynload.ml

Expand All @@ -34,7 +44,4 @@ Create a library called `findlib.dynload`
> EOF
$ touch exe/the_exe.ml

$ dune build --display short ./exe/the_exe.exe 2>&1 | grep crash
I must not crash. Uncertainty is the mind-killer. Exceptions are the


$ dune build

0 comments on commit f9eadb0

Please sign in to comment.