Internal error: link_many: unable to find module
Expected Behavior
Dune should not crash.
Actual Behavior
Dune crashes with the following message:
Internal error, please report upstream including the contents of _build/log.
Description:
("link_many: unable to find module",
{ main_module_name = "Libzstd__type_gen"
; modules =
Singleton
{ source =
{ path = [ "Zstd_stubs" ]
; files =
{ impl =
Some
{ path = In_build_dir "default/src/zstd_stubs.ml"
; dialect = "ocaml"
}
; intf = None
}
}
; obj_name = "zstd_stubs"
; pp = None
; visibility = "public"
; kind = Impl
; install_as = None
}
})
Raised at Stdune__Code_error.raise in file
"otherlibs/stdune/src/code_error.ml", line 10, characters 30-62
Called from Dune_rules__Exe.link_many.(fun) in file "src/dune_rules/exe.ml",
line 284, characters 12-215
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
line 76, characters 8-11
-> required by ("<unnamed>", ())
-> required by ("load-dir", In_build_dir "default/src")
-> required by ("<unnamed>", ())
-> required by
("build-alias", { dir = In_build_dir "default"; name = "default" })
-> required by ("toplevel", ())
I must not crash. Uncertainty is the mind-killer. Exceptions are the
little-death that brings total obliteration. I will fully express my cases.
Execution will pass over me and through me. And when it has gone past, I
will unwind the stack along its path. Where the cases are handled there will
be nothing. Only I will remain.
Reproduction
- Download and unpack ocaml-zstd.zip.
- Run
opam switch create .. - Run
dune build.
Specifications
-
Version of
dune(output ofdune --version): 3.14.2 -
Version of
ocaml(output ofocamlc --version): 5.1.1 -
Operating system (distribution and version): Arch Linux
-
Link to gist with verbose output (run
dunewith the--verboseflag): https://pastebin.com/raw/ZTxqy70Y
Hi!
I confirmed the problem; also this is not a regression (happens in 3.7.0 too).
From a quick glance, this might be related to using (modules). Normally you don't need to manually split your library in 2 when using (ctypes), you just add it and dune will take care of the rest.
For example the whole dune file might just be:
(library
(public_name zstd)
(wrapped false)
(ctypes
(external_library_name libzstd)
(headers (include "zstd.h"))
(type_description
(instance Types)
(functor Type_description))
(function_description
(concurrency unlocked)
(instance Functions)
(functor Function_description))
(generated_types Types_generated)
(generated_entry_point C)))
But that being said, this error message needs to be fixed.