Dynlinking plugin which references LLVM stubs

I’m following dune’s manual about creating dynamically loadable plugins How to Load Additional Files at Runtime — Dune documentation

When my plugin depends on Unix library it loads fine. But when I reference Llvm instead of Unix, it can’t load a plugin, saying.

Fatal error: exception Dynlink.Error
(Dynlink.Cannot_open_dll “Dynlink.Error (Dynlink.Cannot_open_dll "Failure(\"/home/kakadu/asp/dune-sites-demo/_build/install/default/lib/plugin1/plugin1_impl/plugin1_impl.cmxs: undefined symbol: llvm_build_add\")")”)

The demo is here. Any ideas?

P.S. I want to mention @alan who’s working on new Llvm release.

I wrote the same with ocamlfind+dynlink and it works even with LLVM.
It looks like dune uses other kind of machinery, where linking with LLVM doesn’t works as is. Any help?

I don’t know what is going on and have never mucked deep into plugins, but I do know that Dune is missing a bunch of features that may impede interaction with findlib-based libraries. For example, the versions of LLVM on opam make use of a “predicate” to enable static linking to LLVM. OCamlbuild permits users to access this option, but Dune does not. This is a concern that @kit-ty-kate has mentioned while she has been trying to make the LLVM bindings build with Dune.

However, you don’t seem to need the llvm.static predicate (you would probably not want this flag), so I’m not sure what the issue is for your case specifically.