mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 07:31:20 +00:00
55ac8ffa43
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.
47 lines
1.2 KiB
Nix
47 lines
1.2 KiB
Nix
{ stdenv, fetchpatch, python, cmake, llvm, ocaml, findlib, ctypes }:
|
|
|
|
let version = stdenv.lib.getVersion llvm; in
|
|
|
|
stdenv.mkDerivation {
|
|
pname = "ocaml-llvm";
|
|
inherit version;
|
|
|
|
inherit (llvm) src;
|
|
|
|
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;
|
|
sha256 = "1p98j3b1vrryfn1xa7i50m6mmm4dyw5ldafq6kyh9sfmdihz4zsx";
|
|
})];
|
|
|
|
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";
|
|
|
|
installFlags = "-C bindings/ocaml";
|
|
|
|
postInstall = ''
|
|
mkdir -p $OCAMLFIND_DESTDIR/
|
|
mv $out/ocaml $OCAMLFIND_DESTDIR/llvm
|
|
mv $OCAMLFIND_DESTDIR/llvm/META{.llvm,}
|
|
'';
|
|
|
|
passthru = {
|
|
inherit llvm;
|
|
};
|
|
|
|
meta = {
|
|
inherit (llvm.meta) license homepage;
|
|
platforms = ocaml.meta.platforms or [];
|
|
description = "OCaml bindings distributed with LLVM";
|
|
maintainers = with stdenv.lib.maintainers; [ vbgl ];
|
|
};
|
|
|
|
}
|