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.