ocamlPackages.llvm: propagate needed libs, fix missing build parameter

The opam patch makes ocaml link dependent executables with
-L${LLVM_OCAML_EXTERNAL_LLVM_LIBDIR}. This variable was previously
undefined and as a result the linker would previously be called with
just -L which makes it ignore the next argument. This would lead strange
linking errors, like missing caml_apply2.

Despite defining this variable correctly, propagating llvm is still
necessary for linking to complete. In case ocaml-llvm is a transitive
dependency only, propagatedBuildInputs is not enough. To avoid having to
guess which version of llvm was used, we provide the right one in
passthrough.
This commit is contained in:
Symphorien Gibol 2019-10-06 12:00:00 +00:00 committed by Vincent Laporte
parent 0277cc1f1c
commit 55ac8ffa43

View File

@ -8,7 +8,8 @@ stdenv.mkDerivation {
inherit (llvm) src;
buildInputs = [ python cmake llvm ocaml findlib ctypes ];
buildInputs = [ python cmake ocaml findlib ctypes ];
propagatedBuildInputs = [ llvm ];
patches = [ (fetchpatch {
url = https://raw.githubusercontent.com/ocaml/opam-repository/2bdc193f5a9305ea93bf0f0dfc1fbc327c8b9306/packages/llvm/llvm.7.0.0/files/fix-shared.patch;
@ -18,6 +19,7 @@ stdenv.mkDerivation {
cmakeFlags = [
"-DLLVM_OCAML_OUT_OF_TREE=TRUE"
"-DLLVM_OCAML_INSTALL_PATH=${placeholder "out"}/ocaml"
"-DLLVM_OCAML_EXTERNAL_LLVM_LIBDIR=${stdenv.lib.getLib llvm}/lib"
];
buildFlags = "ocaml_all";
@ -30,6 +32,10 @@ stdenv.mkDerivation {
mv $OCAMLFIND_DESTDIR/llvm/META{.llvm,}
'';
passthru = {
inherit llvm;
};
meta = {
inherit (llvm.meta) license homepage;
platforms = ocaml.meta.platforms or [];