From 55ac8ffa43fa078929e24b33f4571321829ae9c3 Mon Sep 17 00:00:00 2001 From: Symphorien Gibol Date: Sun, 6 Oct 2019 12:00:00 +0000 Subject: [PATCH] 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. --- pkgs/development/ocaml-modules/llvm/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/development/ocaml-modules/llvm/default.nix b/pkgs/development/ocaml-modules/llvm/default.nix index 3cebefb33edf..fff4cff7802a 100644 --- a/pkgs/development/ocaml-modules/llvm/default.nix +++ b/pkgs/development/ocaml-modules/llvm/default.nix @@ -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 [];