2021-08-08 23:18:59 +02:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2019-07-27 20:27:00 +02:00
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
2021-08-08 23:18:59 +02:00
|
|
|
, runCommandLocal
|
2019-07-27 20:27:00 +02:00
|
|
|
, bison
|
|
|
|
, flex
|
|
|
|
, llvmPackages_8
|
|
|
|
, opencl-clang
|
2021-03-26 10:04:07 +01:00
|
|
|
, python3
|
2019-07-27 20:27:00 +02:00
|
|
|
, spirv-llvm-translator
|
|
|
|
|
|
|
|
, buildWithPatches ? true
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
llvmPkgs = llvmPackages_8 // {
|
|
|
|
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 10:23:57 +02:00
|
|
|
inherit (if buildWithPatches then opencl-clang else llvmPkgs) clang libclang spirv-llvm-translator;
|
2021-01-22 12:25:31 +01:00
|
|
|
inherit (lib) getVersion optional optionals versionOlder versions;
|
2019-07-27 20:27:00 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "intel-graphics-compiler";
|
2020-07-03 20:56:15 +02:00
|
|
|
version = "1.0.4241";
|
2019-07-27 20:27:00 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "intel";
|
|
|
|
repo = "intel-graphics-compiler";
|
|
|
|
rev = "igc-${version}";
|
2020-07-03 20:56:15 +02:00
|
|
|
sha256 = "1jp3c67ppl1x4pazr5nzy52615cpx0kyckaridhc0fsmrkgilyxq";
|
2019-07-27 20:27:00 +02:00
|
|
|
};
|
|
|
|
|
2021-03-26 10:04:07 +01:00
|
|
|
nativeBuildInputs = [ clang cmake bison flex python3 ];
|
2019-07-27 20:27:00 +02:00
|
|
|
|
2021-03-26 10:04:07 +01:00
|
|
|
buildInputs = [ clang opencl-clang spirv-llvm-translator llvm ];
|
|
|
|
|
|
|
|
strictDeps = true;
|
2019-07-27 20:27:00 +02: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:18:59 +02: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/
|
|
|
|
'';
|
2019-07-27 20:27:00 +02:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DCCLANG_BUILD_PREBUILDS=ON"
|
|
|
|
"-DCCLANG_BUILD_PREBUILDS_DIR=${prebuilds}"
|
|
|
|
"-DIGC_PREFERRED_LLVM_VERSION=${getVersion llvm}"
|
|
|
|
];
|
|
|
|
|
2021-01-22 12:25:31 +01:00
|
|
|
meta = with lib; {
|
2021-08-08 23:18:59 +02:00
|
|
|
homepage = "https://github.com/intel/intel-graphics-compiler";
|
2019-07-27 20:27:00 +02:00
|
|
|
description = "LLVM-based compiler for OpenCL targeting Intel Gen graphics hardware";
|
2021-08-08 23:18:59 +02:00
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.all;
|
2019-07-27 20:27:00 +02:00
|
|
|
maintainers = with maintainers; [ gloaming ];
|
|
|
|
};
|
|
|
|
}
|