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
|
|
|
|
, lld_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";
|
2022-05-05 12:44:35 +00:00
|
|
|
rev = "v0.3.0";
|
|
|
|
sha256 = "sha256-1Rm4TCERTOcPGWJF+yNoKeB9x3jfqnh7Vlv+0Xpmjbk=";
|
2021-10-23 20:24:24 +00:00
|
|
|
};
|
|
|
|
llvmPkgs = llvmPackages_11 // {
|
2019-07-27 18:27:00 +00:00
|
|
|
inherit spirv-llvm-translator;
|
|
|
|
};
|
|
|
|
inherit (llvmPkgs) llvm;
|
llvmPackages: Multuple outputs for everythting
Also begin to start work on cross compilation, though that will have to
be finished later.
The patches are based on the first version of
https://reviews.llvm.org/D99484. It's very annoying to do the
back-porting but the review has uncovered nothing super major so I'm
fine sticking with what I've got.
Beyond making the outputs work, I also strove to re-sync the packages,
as they have been drifting pointlessly apart for some time.
----
Other misc notes, highly incomplete
- lvm-config-native and llvm-config are put in `dev` because they are
tools just for build time.
- Clang no longer has an lld dep. That was introduced in
db29857eb391ed002046090851a44c452b80bdbd, but if clang needs help
finding lld when it is used we should just pass it flags / put in the
resource dir. Providing it at build time increases critical path
length for no good reason.
----
A note on `nativeCC`:
`stdenv` takes tools from the previous stage, so:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.stdenv.cc`: `(?0, ?1, x)`
while:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.targetPackages`: `(x, x, ?2)`
3. `pkgsBuildBuild.targetPackages.stdenv.cc`: `(?1, x, x)`
2020-10-15 08:23:57 +00:00
|
|
|
inherit (if buildWithPatches then opencl-clang else llvmPkgs) clang libclang spirv-llvm-translator;
|
2021-01-22 11:25:31 +00:00
|
|
|
inherit (lib) getVersion optional optionals versionOlder versions;
|
2019-07-27 18:27:00 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "intel-graphics-compiler";
|
2022-05-05 12:44:35 +00:00
|
|
|
version = "1.0.11061";
|
2019-07-27 18:27:00 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "intel";
|
|
|
|
repo = "intel-graphics-compiler";
|
|
|
|
rev = "igc-${version}";
|
2022-05-05 12:44:35 +00:00
|
|
|
sha256 = "sha256-qS/+GTqHtp3T6ggPKrCDsrTb7XvVOUaNbMzGU51jTu4=";
|
2019-07-27 18:27:00 +00:00
|
|
|
};
|
|
|
|
|
2021-03-26 09:04:07 +00:00
|
|
|
nativeBuildInputs = [ clang cmake bison flex python3 ];
|
2019-07-27 18:27:00 +00:00
|
|
|
|
2022-05-05 12:44:35 +00:00
|
|
|
buildInputs = [ spirv-headers spirv-tools clang opencl-clang spirv-llvm-translator llvm lld_11 ];
|
2021-03-26 09:04:07 +00:00
|
|
|
|
|
|
|
strictDeps = true;
|
2019-07-27 18:27:00 +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;
|
|
|
|
|
2022-05-05 12:44:35 +00:00
|
|
|
patchPhase = ''
|
|
|
|
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'
|
|
|
|
substituteInPlace ./IGC/AdaptorOCL/igc-opencl.pc.in \
|
|
|
|
--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/
|
|
|
|
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-10-23 20:24:24 +00:00
|
|
|
ln -s ${lib.getLib libclang}/lib/clang/${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}"
|
|
|
|
"-DIGC_PREFERRED_LLVM_VERSION=${getVersion llvm}"
|
|
|
|
];
|
|
|
|
|
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;
|
|
|
|
platforms = platforms.all;
|
2019-07-27 18:27:00 +00:00
|
|
|
maintainers = with maintainers; [ gloaming ];
|
2022-01-17 12:28:37 +00:00
|
|
|
broken = stdenv.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/trunk/intel-graphics-compiler.x86_64-darwin
|
2019-07-27 18:27:00 +00:00
|
|
|
};
|
|
|
|
}
|