2021-08-08 21:18:59 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2019-07-27 18:27:00 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
2021-08-08 21:18:59 +00:00
|
|
|
, runCommandLocal
|
2019-07-27 18:27:00 +00:00
|
|
|
, bison
|
|
|
|
, flex
|
2021-10-23 20:24:24 +00:00
|
|
|
, llvmPackages_11
|
2019-07-27 18:27:00 +00:00
|
|
|
, opencl-clang
|
2021-03-26 09:04:07 +00:00
|
|
|
, python3
|
2022-05-05 12:44:35 +00:00
|
|
|
, spirv-tools
|
|
|
|
, spirv-headers
|
2019-07-27 18:27:00 +00:00
|
|
|
, spirv-llvm-translator
|
|
|
|
|
|
|
|
, buildWithPatches ? true
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-10-23 20:24:24 +00:00
|
|
|
vc_intrinsics_src = fetchFromGitHub {
|
|
|
|
owner = "intel";
|
|
|
|
repo = "vc-intrinsics";
|
2023-02-28 16:44:18 +00:00
|
|
|
rev = "v0.11.0";
|
|
|
|
sha256 = "sha256-74JBW7qU8huSqwqgxNbvbGj1DlJJThgGhb3owBYmhvI=";
|
2021-10-23 20:24:24 +00:00
|
|
|
};
|
2022-11-28 02:32:49 +00:00
|
|
|
|
2021-10-23 20:24:24 +00:00
|
|
|
llvmPkgs = llvmPackages_11 // {
|
2022-11-28 02:32:49 +00:00
|
|
|
spirv-llvm-translator = spirv-llvm-translator.override { llvm = llvm; };
|
|
|
|
} // lib.optionalAttrs buildWithPatches opencl-clang;
|
|
|
|
|
|
|
|
inherit (llvmPackages_11) lld llvm;
|
|
|
|
inherit (llvmPkgs) clang libclang spirv-llvm-translator;
|
2019-07-27 18:27:00 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "intel-graphics-compiler";
|
2023-02-28 16:44:18 +00:00
|
|
|
version = "1.0.12812.26";
|
2019-07-27 18:27:00 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "intel";
|
|
|
|
repo = "intel-graphics-compiler";
|
|
|
|
rev = "igc-${version}";
|
2023-02-28 16:44:18 +00:00
|
|
|
sha256 = "sha256-KpaDaDYVp40H7OscDGUpzEMgIOIk397ANi+8sDk4Wow=";
|
2019-07-27 18:27:00 +00:00
|
|
|
};
|
|
|
|
|
2022-11-28 02:32:49 +00:00
|
|
|
nativeBuildInputs = [ cmake bison flex python3 ];
|
2019-07-27 18:27:00 +00:00
|
|
|
|
2022-11-28 02:32:49 +00:00
|
|
|
buildInputs = [ spirv-headers spirv-tools spirv-llvm-translator llvm lld ];
|
2021-03-26 09:04:07 +00:00
|
|
|
|
|
|
|
strictDeps = true;
|
2019-07-27 18:27:00 +00:00
|
|
|
|
2022-11-28 02:32:49 +00:00
|
|
|
# testing is done via intel-compute-runtime
|
2019-07-27 18:27:00 +00:00
|
|
|
doCheck = false;
|
|
|
|
|
2022-05-05 22:27:48 +00:00
|
|
|
postPatch = ''
|
2022-12-05 22:08:23 +00:00
|
|
|
substituteInPlace external/SPIRV-Tools/CMakeLists.txt \
|
2022-05-05 22:24:09 +00:00
|
|
|
--replace '$'''{SPIRV-Tools_DIR}../../..' \
|
|
|
|
'${spirv-tools}' \
|
|
|
|
--replace 'SPIRV-Headers_INCLUDE_DIR "/usr/include"' \
|
|
|
|
'SPIRV-Headers_INCLUDE_DIR "${spirv-headers}/include"' \
|
|
|
|
--replace 'set_target_properties(SPIRV-Tools' \
|
|
|
|
'set_target_properties(SPIRV-Tools-shared' \
|
|
|
|
--replace 'IGC_BUILD__PROJ__SPIRV-Tools SPIRV-Tools' \
|
|
|
|
'IGC_BUILD__PROJ__SPIRV-Tools SPIRV-Tools-shared'
|
2022-12-05 22:08:23 +00:00
|
|
|
substituteInPlace IGC/AdaptorOCL/igc-opencl.pc.in \
|
2022-05-05 22:24:09 +00:00
|
|
|
--replace '/@CMAKE_INSTALL_INCLUDEDIR@' "/include" \
|
|
|
|
--replace '/@CMAKE_INSTALL_LIBDIR@' "/lib"
|
2022-05-05 12:44:35 +00:00
|
|
|
'';
|
|
|
|
|
2019-07-27 18:27:00 +00:00
|
|
|
# Handholding the braindead build script
|
2021-08-08 21:18:59 +00:00
|
|
|
# cmake requires an absolute path
|
|
|
|
prebuilds = runCommandLocal "igc-cclang-prebuilds" { } ''
|
|
|
|
mkdir $out
|
|
|
|
ln -s ${clang}/bin/clang $out/
|
2022-11-28 02:32:49 +00:00
|
|
|
ln -s clang $out/clang-${lib.versions.major (lib.getVersion clang)}
|
2021-08-08 21:18:59 +00:00
|
|
|
ln -s ${opencl-clang}/lib/* $out/
|
2022-11-28 02:32:49 +00:00
|
|
|
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/
|
2021-08-08 21:18:59 +00:00
|
|
|
'';
|
2019-07-27 18:27:00 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
2022-05-05 12:44:35 +00:00
|
|
|
"-Wno-dev"
|
2021-10-23 20:24:24 +00:00
|
|
|
"-DVC_INTRINSICS_SRC=${vc_intrinsics_src}"
|
2022-05-05 12:44:35 +00:00
|
|
|
"-DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds"
|
2019-07-27 18:27:00 +00:00
|
|
|
"-DCCLANG_BUILD_PREBUILDS=ON"
|
|
|
|
"-DCCLANG_BUILD_PREBUILDS_DIR=${prebuilds}"
|
2022-11-28 02:32:49 +00:00
|
|
|
"-DIGC_PREFERRED_LLVM_VERSION=${lib.getVersion llvm}"
|
2019-07-27 18:27:00 +00:00
|
|
|
];
|
|
|
|
|
2021-01-22 11:25:31 +00:00
|
|
|
meta = with lib; {
|
2021-08-08 21:18:59 +00:00
|
|
|
homepage = "https://github.com/intel/intel-graphics-compiler";
|
2019-07-27 18:27:00 +00:00
|
|
|
description = "LLVM-based compiler for OpenCL targeting Intel Gen graphics hardware";
|
2021-08-08 21:18:59 +00:00
|
|
|
license = licenses.mit;
|
2022-11-28 02:32:49 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = with maintainers; [ SuperSandro2000 ];
|
2019-07-27 18:27:00 +00:00
|
|
|
};
|
|
|
|
}
|