about summary refs log tree commit diff
path: root/pkgs/development/compilers/intel-graphics-compiler/default.nix
blob: e3dfa8ea324c029efc067ecdeb8e52b015425f28 (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
68
69
70
71
72
73
{ stdenv
, fetchFromGitHub
, cmake
, pkgconfig

, bison
, flex
, llvmPackages_8
, opencl-clang
, python
, spirv-llvm-translator

, buildWithPatches ? true
}:

let
  llvmPkgs = llvmPackages_8 // {
    inherit spirv-llvm-translator;
  };
  inherit (llvmPkgs) llvm;
  inherit (if buildWithPatches then opencl-clang else llvmPkgs) clang clang-unwrapped spirv-llvm-translator;
  inherit (stdenv.lib) getVersion optional optionals versionOlder versions;
in

stdenv.mkDerivation rec {
  pname = "intel-graphics-compiler";
  version = "1.0.3627";

  src = fetchFromGitHub {
    owner = "intel";
    repo = "intel-graphics-compiler";
    rev = "igc-${version}";
    sha256 = "1x9fjvf7rbhil09am2v9j2jhwysdvwgshf9zidbirjgfrqn573h8";
  };

  nativeBuildInputs = [ clang cmake bison flex llvm python ];

  buildInputs = [ clang opencl-clang spirv-llvm-translator ];

  # checkInputs = [ lit pythonPackages.nose ];

  # FIXME: How do we run the test suite?
  # https://github.com/intel/intel-graphics-compiler/issues/98
  doCheck = false;

  # Handholding the braindead build script
  # We put this in a derivation because the cmake requires an absolute path
  prebuilds = stdenv.mkDerivation {
    name = "igc-cclang-prebuilds";
    phases = [ "installPhase" ];
    installPhase = ''
      mkdir $out
      ln -s ${clang}/bin/clang $out/
      ln -s clang $out/clang-${versions.major (getVersion clang)}
      ln -s ${opencl-clang}/lib/* $out/
      ln -s ${clang-unwrapped}/lib/clang/${getVersion clang}/include/opencl-c.h $out/
    '';
  };

  cmakeFlags = [
    "-DCCLANG_BUILD_PREBUILDS=ON"
    "-DCCLANG_BUILD_PREBUILDS_DIR=${prebuilds}"
    "-DIGC_PREFERRED_LLVM_VERSION=${getVersion llvm}"
  ];

  meta = with stdenv.lib; {
    homepage    = "https://github.com/intel/intel-graphics-compiler";
    description = "LLVM-based compiler for OpenCL targeting Intel Gen graphics hardware";
    license     = licenses.mit;
    platforms   = platforms.all;
    maintainers = with maintainers; [ gloaming ];
  };
}