evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / by-name / in / intel-graphics-compiler / package.nix
blobef3ff5ff4565bccbd8cdf337e656cd485f33a88f
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , bash
5 , cmake
6 , runCommandLocal
7 , bison
8 , flex
9 , intel-compute-runtime
10 , llvmPackages_14
11 , opencl-clang
12 , python3
13 , spirv-tools
14 , spirv-headers
15 , spirv-llvm-translator
17 , buildWithPatches ? true
20 let
21   vc_intrinsics_src = fetchFromGitHub {
22     owner = "intel";
23     repo = "vc-intrinsics";
24     rev = "v0.19.0";
25     hash = "sha256-vOK7xfOR+aDpdGd8oOFLJc1Ct1S5BCJmLN6Ubn5wlkQ=";
26   };
28   inherit (llvmPackages_14) lld llvm;
29   inherit (if buildWithPatches then opencl-clang else llvmPackages_14) clang libclang;
30   spirv-llvm-translator' = spirv-llvm-translator.override { inherit llvm; };
33 stdenv.mkDerivation rec {
34   pname = "intel-graphics-compiler";
35   version = "1.0.17384.11";
37   src = fetchFromGitHub {
38     owner = "intel";
39     repo = "intel-graphics-compiler";
40     rev = "igc-${version}";
41     hash = "sha256-O4uMaPauRv2aMgM2B7XdzCcjI5JghsjX5XbkeloLyck=";
42   };
44   postPatch = ''
45     substituteInPlace IGC/AdaptorOCL/igc-opencl.pc.in \
46       --replace-fail '/@CMAKE_INSTALL_INCLUDEDIR@' "/include" \
47       --replace-fail '/@CMAKE_INSTALL_LIBDIR@' "/lib"
49     chmod +x IGC/Scripts/igc_create_linker_script.sh
50     patchShebangs --build IGC/Scripts/igc_create_linker_script.sh
51   '';
53   nativeBuildInputs = [ bash bison cmake flex (python3.withPackages (ps : with ps; [ mako pyyaml ])) ];
55   buildInputs = [ lld llvm spirv-headers spirv-llvm-translator' spirv-tools ];
57   strictDeps = true;
59   # testing is done via intel-compute-runtime
60   doCheck = false;
62   # Handholding the braindead build script
63   # cmake requires an absolute path
64   prebuilds = runCommandLocal "igc-cclang-prebuilds" { } ''
65     mkdir $out
66     ln -s ${clang}/bin/clang $out/
67     ln -s ${opencl-clang}/lib/* $out/
68     ln -s ${lib.getLib libclang}/lib/clang/${lib.getVersion clang}/include/opencl-c.h $out/
69     ln -s ${lib.getLib libclang}/lib/clang/${lib.getVersion clang}/include/opencl-c-base.h $out/
70   '';
72   cmakeFlags = [
73     "-DVC_INTRINSICS_SRC=${vc_intrinsics_src}"
74     "-DCCLANG_BUILD_PREBUILDS=ON"
75     "-DCCLANG_BUILD_PREBUILDS_DIR=${prebuilds}"
76     "-DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds"
77     "-DIGC_OPTION__VC_INTRINSICS_MODE=Source"
78     "-Wno-dev"
79   ];
81   passthru.tests = {
82     inherit intel-compute-runtime;
83   };
85   meta = with lib; {
86     description = "LLVM-based compiler for OpenCL targeting Intel Gen graphics hardware";
87     homepage = "https://github.com/intel/intel-graphics-compiler";
88     changelog = "https://github.com/intel/intel-graphics-compiler/releases/tag/${src.rev}";
89     license = licenses.mit;
90     platforms = platforms.linux;
91     maintainers = with maintainers; [ SuperSandro2000 ];
92   };