depot/third_party/nixpkgs/pkgs/development/compilers/intel-graphics-compiler/default.nix
Default email c7cb07f092 Project import generated by Copybara.
GitOrigin-RevId: 1536926ef5621b09bba54035ae2bb6d806d72ac8
2024-02-29 21:09:43 +01:00

89 lines
2.4 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, cmake
, runCommandLocal
, bison
, flex
, intel-compute-runtime
, llvmPackages_14
, opencl-clang
, python3
, spirv-tools
, spirv-headers
, spirv-llvm-translator
, buildWithPatches ? true
}:
let
vc_intrinsics_src = fetchFromGitHub {
owner = "intel";
repo = "vc-intrinsics";
rev = "v0.16.0";
hash = "sha256-d197m80vSICdv4VKnyqdy3flzbKLKmB8jroY2difA7o=";
};
inherit (llvmPackages_14) lld llvm;
inherit (if buildWithPatches then opencl-clang else llvmPackages_14) clang libclang;
spirv-llvm-translator' = spirv-llvm-translator.override { inherit llvm; };
in
stdenv.mkDerivation rec {
pname = "intel-graphics-compiler";
version = "1.0.15985.7";
src = fetchFromGitHub {
owner = "intel";
repo = "intel-graphics-compiler";
rev = "igc-${version}";
hash = "sha256-NXShD6M5OeKi0+Jszvoos+wjHZ9lWh/LIUFLFq8dzFM=";
};
nativeBuildInputs = [ bison cmake flex (python3.withPackages (ps : with ps; [ mako ])) ];
buildInputs = [ lld llvm spirv-headers spirv-llvm-translator' spirv-tools ];
strictDeps = true;
# testing is done via intel-compute-runtime
doCheck = false;
postPatch = ''
substituteInPlace IGC/AdaptorOCL/igc-opencl.pc.in \
--replace '/@CMAKE_INSTALL_INCLUDEDIR@' "/include" \
--replace '/@CMAKE_INSTALL_LIBDIR@' "/lib"
'';
# Handholding the braindead build script
# cmake requires an absolute path
prebuilds = runCommandLocal "igc-cclang-prebuilds" { } ''
mkdir $out
ln -s ${clang}/bin/clang $out/
ln -s ${opencl-clang}/lib/* $out/
ln -s ${lib.getLib libclang}/lib/clang/${lib.getVersion clang}/include/opencl-c.h $out/
ln -s ${lib.getLib libclang}/lib/clang/${lib.getVersion clang}/include/opencl-c-base.h $out/
'';
cmakeFlags = [
"-DVC_INTRINSICS_SRC=${vc_intrinsics_src}"
"-DCCLANG_BUILD_PREBUILDS=ON"
"-DCCLANG_BUILD_PREBUILDS_DIR=${prebuilds}"
"-DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds"
"-DIGC_OPTION__VC_INTRINSICS_MODE=Source"
"-Wno-dev"
];
passthru.tests = {
inherit intel-compute-runtime;
};
meta = with lib; {
description = "LLVM-based compiler for OpenCL targeting Intel Gen graphics hardware";
homepage = "https://github.com/intel/intel-graphics-compiler";
changelog = "https://github.com/intel/intel-graphics-compiler/releases/tag/${src.rev}";
license = licenses.mit;
platforms = platforms.linux;
maintainers = with maintainers; [ SuperSandro2000 ];
};
}