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
|
2020-04-24 23:36:52 +00:00
|
|
|
, opencl-clang
|
2021-04-05 15:23:46 +00:00
|
|
|
, python3
|
2022-05-18 14:49:53 +00:00
|
|
|
, spirv-tools
|
|
|
|
, spirv-headers
|
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";
|
2023-03-08 16:32:21 +00:00
|
|
|
rev = "v0.11.0";
|
|
|
|
sha256 = "sha256-74JBW7qU8huSqwqgxNbvbGj1DlJJThgGhb3owBYmhvI=";
|
2021-12-06 16:07:01 +00:00
|
|
|
};
|
2022-12-17 10:02:37 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
llvmPkgs = llvmPackages_11 // {
|
2022-12-17 10:02:37 +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;
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "intel-graphics-compiler";
|
2023-03-08 16:32:21 +00:00
|
|
|
version = "1.0.12812.26";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "intel";
|
|
|
|
repo = "intel-graphics-compiler";
|
|
|
|
rev = "igc-${version}";
|
2023-03-08 16:32:21 +00:00
|
|
|
sha256 = "sha256-KpaDaDYVp40H7OscDGUpzEMgIOIk397ANi+8sDk4Wow=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
nativeBuildInputs = [ cmake bison flex python3 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
buildInputs = [ spirv-headers spirv-tools spirv-llvm-translator llvm lld ];
|
2021-04-05 15:23:46 +00:00
|
|
|
|
|
|
|
strictDeps = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
# testing is done via intel-compute-runtime
|
2020-04-24 23:36:52 +00:00
|
|
|
doCheck = false;
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
postPatch = ''
|
2022-12-17 10:02:37 +00:00
|
|
|
substituteInPlace external/SPIRV-Tools/CMakeLists.txt \
|
2022-05-18 14:49:53 +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-17 10:02:37 +00:00
|
|
|
substituteInPlace IGC/AdaptorOCL/igc-opencl.pc.in \
|
2022-05-18 14:49:53 +00:00
|
|
|
--replace '/@CMAKE_INSTALL_INCLUDEDIR@' "/include" \
|
|
|
|
--replace '/@CMAKE_INSTALL_LIBDIR@' "/lib"
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# 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/
|
2022-12-17 10:02:37 +00:00
|
|
|
ln -s clang $out/clang-${lib.versions.major (lib.getVersion clang)}
|
2021-08-08 23:34:03 +00:00
|
|
|
ln -s ${opencl-clang}/lib/* $out/
|
2022-12-17 10:02:37 +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 23:34:03 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
2022-05-18 14:49:53 +00:00
|
|
|
"-Wno-dev"
|
2021-12-06 16:07:01 +00:00
|
|
|
"-DVC_INTRINSICS_SRC=${vc_intrinsics_src}"
|
2022-05-18 14:49:53 +00:00
|
|
|
"-DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DCCLANG_BUILD_PREBUILDS=ON"
|
|
|
|
"-DCCLANG_BUILD_PREBUILDS_DIR=${prebuilds}"
|
2022-12-17 10:02:37 +00:00
|
|
|
"-DIGC_PREFERRED_LLVM_VERSION=${lib.getVersion llvm}"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
# causes redefinition of _FORTIFY_SOURCE
|
|
|
|
hardeningDisable = [ "fortify3" ];
|
|
|
|
|
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;
|
2022-12-17 10:02:37 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = with maintainers; [ SuperSandro2000 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|