2021-08-08 23:34:03 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
2021-08-08 23:34:03 +00:00
|
|
|
, runCommandLocal
|
2020-04-24 23:36:52 +00:00
|
|
|
, bison
|
|
|
|
, flex
|
2021-12-06 16:07:01 +00:00
|
|
|
, llvmPackages_11
|
|
|
|
, lld_11
|
2020-04-24 23:36:52 +00:00
|
|
|
, opencl-clang
|
2021-04-05 15:23:46 +00:00
|
|
|
, python3
|
2020-04-24 23:36:52 +00:00
|
|
|
, spirv-llvm-translator
|
|
|
|
|
|
|
|
, buildWithPatches ? true
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-12-06 16:07:01 +00:00
|
|
|
vc_intrinsics_src = fetchFromGitHub {
|
|
|
|
owner = "intel";
|
|
|
|
repo = "vc-intrinsics";
|
|
|
|
rev = "e5ad7e02aa4aa21a3cd7b3e5d1f3ec9b95f58872";
|
|
|
|
sha256 = "Vg1mngwpIQ3Tik0GgRXPG22lE4sLEAEFch492G2aIXs=";
|
|
|
|
};
|
|
|
|
llvmPkgs = llvmPackages_11 // {
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit spirv-llvm-translator;
|
|
|
|
};
|
|
|
|
inherit (llvmPkgs) llvm;
|
2021-05-20 23:08:51 +00:00
|
|
|
inherit (if buildWithPatches then opencl-clang else llvmPkgs) clang libclang spirv-llvm-translator;
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit (lib) getVersion optional optionals versionOlder versions;
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "intel-graphics-compiler";
|
2021-12-06 16:07:01 +00:00
|
|
|
version = "1.0.8744";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "intel";
|
|
|
|
repo = "intel-graphics-compiler";
|
|
|
|
rev = "igc-${version}";
|
2021-12-06 16:07:01 +00:00
|
|
|
sha256 = "G5+dYD8uZDPkRyn1sgXsRngdq4NJndiCJCYTRXyUgTA=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
nativeBuildInputs = [ clang cmake bison flex python3 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
buildInputs = [ clang opencl-clang spirv-llvm-translator llvm lld_11 ];
|
2021-04-05 15:23:46 +00:00
|
|
|
|
|
|
|
strictDeps = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# 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
|
2021-08-08 23:34:03 +00:00
|
|
|
# cmake requires an absolute path
|
|
|
|
prebuilds = runCommandLocal "igc-cclang-prebuilds" { } ''
|
|
|
|
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 ${lib.getLib libclang}/lib/clang/${getVersion clang}/include/opencl-c.h $out/
|
2021-12-06 16:07:01 +00:00
|
|
|
ln -s ${lib.getLib libclang}/lib/clang/${getVersion clang}/include/opencl-c-base.h $out/
|
2021-08-08 23:34:03 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
2021-12-06 16:07:01 +00:00
|
|
|
"-DVC_INTRINSICS_SRC=${vc_intrinsics_src}"
|
|
|
|
"-DINSTALL_SPIRVDLL=0"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DCCLANG_BUILD_PREBUILDS=ON"
|
|
|
|
"-DCCLANG_BUILD_PREBUILDS_DIR=${prebuilds}"
|
|
|
|
"-DIGC_PREFERRED_LLVM_VERSION=${getVersion llvm}"
|
|
|
|
];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2021-08-08 23:34:03 +00:00
|
|
|
homepage = "https://github.com/intel/intel-graphics-compiler";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "LLVM-based compiler for OpenCL targeting Intel Gen graphics hardware";
|
2021-08-08 23:34:03 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.all;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ gloaming ];
|
2022-01-19 23:45:15 +00:00
|
|
|
broken = stdenv.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/trunk/intel-graphics-compiler.x86_64-darwin
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|