Merge pull request #203399 from SuperSandro2000/intel-graphics-compiler

This commit is contained in:
Sandro
2022-12-01 13:26:35 +01:00
committed by GitHub
3 changed files with 41 additions and 53 deletions
@@ -6,7 +6,6 @@
, bison
, flex
, llvmPackages_11
, lld_11
, opencl-clang
, python3
, spirv-tools
@@ -20,38 +19,36 @@ let
vc_intrinsics_src = fetchFromGitHub {
owner = "intel";
repo = "vc-intrinsics";
rev = "v0.3.0";
sha256 = "sha256-1Rm4TCERTOcPGWJF+yNoKeB9x3jfqnh7Vlv+0Xpmjbk=";
rev = "v0.6.0";
sha256 = "sha256-seVqRtdQ4ciWhsXzneS7pG1aaFtw28SPu9XDkBtr5nc=";
};
llvmPkgs = llvmPackages_11 // {
inherit spirv-llvm-translator;
};
inherit (llvmPkgs) llvm;
inherit (if buildWithPatches then opencl-clang else llvmPkgs) clang libclang spirv-llvm-translator;
inherit (lib) getVersion optional optionals versionOlder versions;
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;
in
stdenv.mkDerivation rec {
pname = "intel-graphics-compiler";
version = "1.0.11061";
version = "1.0.12260.1";
src = fetchFromGitHub {
owner = "intel";
repo = "intel-graphics-compiler";
rev = "igc-${version}";
sha256 = "sha256-qS/+GTqHtp3T6ggPKrCDsrTb7XvVOUaNbMzGU51jTu4=";
sha256 = "sha256-fNBgJGIpHC+rnKsV1Kq1ubz/4l0+ltUHaUpaWsYTgmg=";
};
nativeBuildInputs = [ clang cmake bison flex python3 ];
nativeBuildInputs = [ cmake bison flex python3 ];
buildInputs = [ spirv-headers spirv-tools clang opencl-clang spirv-llvm-translator llvm lld_11 ];
buildInputs = [ spirv-headers spirv-tools spirv-llvm-translator llvm lld ];
strictDeps = true;
# checkInputs = [ lit pythonPackages.nose ];
# FIXME: How do we run the test suite?
# https://github.com/intel/intel-graphics-compiler/issues/98
# testing is done via intel-compute-runtime
doCheck = false;
postPatch = ''
@@ -74,10 +71,10 @@ stdenv.mkDerivation rec {
prebuilds = runCommandLocal "igc-cclang-prebuilds" { } ''
mkdir $out
ln -s ${clang}/bin/clang $out/
ln -s clang $out/clang-${versions.major (getVersion clang)}
ln -s clang $out/clang-${lib.versions.major (lib.getVersion clang)}
ln -s ${opencl-clang}/lib/* $out/
ln -s ${lib.getLib libclang}/lib/clang/${getVersion clang}/include/opencl-c.h $out/
ln -s ${lib.getLib libclang}/lib/clang/${getVersion clang}/include/opencl-c-base.h $out/
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/
'';
cmakeFlags = [
@@ -86,15 +83,14 @@ stdenv.mkDerivation rec {
"-DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds"
"-DCCLANG_BUILD_PREBUILDS=ON"
"-DCCLANG_BUILD_PREBUILDS_DIR=${prebuilds}"
"-DIGC_PREFERRED_LLVM_VERSION=${getVersion llvm}"
"-DIGC_PREFERRED_LLVM_VERSION=${lib.getVersion llvm}"
];
meta = with lib; {
homepage = "https://github.com/intel/intel-graphics-compiler";
description = "LLVM-based compiler for OpenCL targeting Intel Gen graphics hardware";
license = licenses.mit;
platforms = platforms.all;
maintainers = with maintainers; [ gloaming ];
broken = stdenv.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/trunk/intel-graphics-compiler.x86_64-darwin
platforms = platforms.linux;
maintainers = with maintainers; [ SuperSandro2000 ];
};
}
@@ -22,11 +22,11 @@ let
hash = "sha256-BhNAApgZ/w/92XjpoDY6ZEIhSTwgJ4D3/EfNvPmNM2o=";
} else if llvmMajor == "11" then {
version = "unstable-2022-05-04";
rev = "99420daab98998a7e36858befac9c5ed109d4920"; # 265 commits ahead of v11.0.0
hash = "sha256-/vUyL6Wh8hykoGz1QmT1F7lfGDEmG4U3iqmqrJxizOg=";
rev = "a31ffaeef77e23d500b3ea3d35e0c42ff5648ad9"; # 266 commits ahead of v11.0.0
hash = "sha256-rkYMFVfS3xG8ozs7zhiSBjIxvxEetetctE+fLS3hXoU=";
} else throw "Incompatible LLVM version.";
in
stdenv.mkDerivation rec {
stdenv.mkDerivation {
pname = "SPIRV-LLVM-Translator";
inherit (branch) version;
@@ -64,7 +64,7 @@ stdenv.mkDerivation rec {
homepage = "https://github.com/KhronosGroup/SPIRV-LLVM-Translator";
description = "A tool and a library for bi-directional translation between SPIR-V and LLVM IR";
license = licenses.ncsa;
platforms = platforms.all;
platforms = platforms.unix;
maintainers = with maintainers; [ gloaming ];
};
}
@@ -4,10 +4,8 @@
, fetchpatch
, cmake
, git
, llvmPackages_11
, spirv-llvm-translator
, buildWithPatches ? true
}:
@@ -16,32 +14,25 @@ let
inherit spirv-llvm-translator;
};
inherit (lib) getVersion;
addPatches = component: pkg:
with builtins; with lib;
let path = "${passthru.patchesOut}/${component}";
in pkg.overrideAttrs (super: {
postPatch = (if super ? postPatch then super.postPatch + "\n" else "") + ''
for p in ${path}/*
do
patch -p1 -i "$p"
done
'';
});
addPatches = component: pkg: pkg.overrideAttrs (oldAttrs: {
postPatch = oldAttrs.postPatch or "" + ''
for p in ${passthru.patchesOut}/${component}/*; do
patch -p1 -i "$p"
done
'';
});
passthru = rec {
spirv-llvm-translator = llvmPkgs.spirv-llvm-translator;
spirv-llvm-translator = llvmPkgs.spirv-llvm-translator.override { llvm = llvmPackages_11.llvm; };
llvm = addPatches "llvm" llvmPkgs.llvm;
libclang = addPatches "clang" llvmPkgs.libclang;
clang-unwrapped = libclang.out;
clang = llvmPkgs.clang.override {
cc = clang-unwrapped;
};
patchesOut = stdenv.mkDerivation rec {
patchesOut = stdenv.mkDerivation {
pname = "opencl-clang-patches";
inherit (library) version src patches;
# Clang patches assume the root is the llvm root dir
@@ -62,14 +53,13 @@ let
};
library = let
inherit (llvmPkgs) llvm;
inherit (llvmPackages_11) llvm;
inherit (if buildWithPatches then passthru else llvmPkgs) libclang spirv-llvm-translator;
in
stdenv.mkDerivation rec {
stdenv.mkDerivation {
pname = "opencl-clang";
version = "unstable-2022-03-16";
inherit passthru;
src = fetchFromGitHub {
owner = "intel";
@@ -79,8 +69,8 @@ let
};
patches = [
# Build script tries to find Clang OpenCL headers under ${llvm}
# Work around it by specifying that directory manually.
# Build script tries to find Clang OpenCL headers under ${llvm}
# Work around it by specifying that directory manually.
./opencl-headers-dir.patch
];
@@ -96,19 +86,21 @@ let
buildInputs = [ libclang llvm spirv-llvm-translator ];
cmakeFlags = [
"-DPREFERRED_LLVM_VERSION=${getVersion llvm}"
"-DOPENCL_HEADERS_DIR=${libclang.lib}/lib/clang/${getVersion libclang}/include/"
"-DPREFERRED_LLVM_VERSION=${lib.getVersion llvm}"
"-DOPENCL_HEADERS_DIR=${libclang.lib}/lib/clang/${lib.getVersion libclang}/include/"
"-DLLVMSPIRV_INCLUDED_IN_LLVM=OFF"
"-DSPIRV_TRANSLATOR_DIR=${spirv-llvm-translator}"
];
inherit passthru;
meta = with lib; {
homepage = "https://github.com/intel/opencl-clang/";
description = "A clang wrapper library with an OpenCL-oriented API and the ability to compile OpenCL C kernels to SPIR-V modules";
license = licenses.ncsa;
platforms = platforms.all;
maintainers = with maintainers; [ gloaming ];
maintainers = with maintainers; [ SuperSandro2000 ];
};
};
in