summary refs log tree commit diff
path: root/pkgs/development/compilers/halide/default.nix
blob: 356ebe23172983f935c42b3a4ae5023fbcb5c56e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{ llvmPackages, lib, fetchFromGitHub, cmake
, libpng, libjpeg, mesa, eigen
, openblas, blas, lapack
}:

assert blas.implementation == "openblas" && lapack.implementation == "openblas";

let
  version = "2019_08_27";

in llvmPackages.stdenv.mkDerivation {

  name = "halide-${builtins.replaceStrings ["_"] ["."] version}";

  src = fetchFromGitHub {
    owner = "halide";
    repo = "Halide";
    rev = "release_${version}";
    sha256 = "09xf8v9zyxx2fn6s1yzjkyzcf9zyzrg3x5vivgd2ljzbfhm8wh7n";
  };

  patches = [ ./nix.patch ];

  # clang fails to compile intermediate code because
  # of unused "--gcc-toolchain" option
  postPatch = ''
    sed -i "s/-Werror//" src/CMakeLists.txt
  '';

  cmakeFlags = [ "-DWARNINGS_AS_ERRORS=OFF" ];

  # To handle the lack of 'local' RPATH; required, as they call one of
  # their built binaries requiring their libs, in the build process.
  preBuild = ''
    export LD_LIBRARY_PATH="$(pwd)/lib''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
  '';

  enableParallelBuilding = true;

  # Note: only openblas and not atlas part of this Nix expression
  # see pkgs/development/libraries/science/math/liblapack/3.5.0.nix
  # to get a hint howto setup atlas instead of openblas
  buildInputs = [ llvmPackages.llvm libpng libjpeg mesa eigen openblas ];

  nativeBuildInputs = [ cmake ];

  # No install target for cmake available.
  # Calling install target in Makefile causes complete rebuild
  # and the library rpath is broken, because libncursesw.so.6 is missing.
  # Another way is using "make halide_archive", but the tarball is not easy
  # to disassemble.
  installPhase = ''
    find
    mkdir -p "$out/lib" "$out/bin"
    cp bin/HalideTrace* "$out/bin"
    cp lib/libHalide.so "$out/lib"
    cp -r include "$out"
  '';

  meta = with lib; {
    description = "C++ based language for image processing and computational photography";
    homepage = "https://halide-lang.org";
    license = licenses.mit;
    platforms = [ "i686-linux" "x86_64-linux" ];
    maintainers = [ maintainers.ck3d ];
  };
}