lol

intel-graphics-compiler: move opencl-clang into the package (#440534)

authored by

Emily and committed by
GitHub
d1179922 8d1cf7ae

+70 -195
+69 -47
pkgs/by-name/in/intel-graphics-compiler/package.nix
··· 2 2 lib, 3 3 stdenv, 4 4 fetchFromGitHub, 5 - bash, 6 5 cmake, 7 - runCommandLocal, 6 + ninja, 7 + git, 8 8 bison, 9 9 flex, 10 + zlib, 10 11 intel-compute-runtime, 11 - llvmPackages_15, 12 - opencl-clang, 13 12 python3, 14 13 spirv-tools, 15 14 spirv-headers, 16 - spirv-llvm-translator, 17 - 18 - buildWithPatches ? true, 19 15 }: 20 16 21 - let 22 - vc_intrinsics_src = fetchFromGitHub { 23 - owner = "intel"; 24 - repo = "vc-intrinsics"; 25 - rev = "v0.23.1"; 26 - hash = "sha256-7coQegLcgIKiqnonZmgrKlw6FCB3ltSh6oMMvdopeQc="; 27 - }; 28 - 29 - inherit (llvmPackages_15) lld llvm; 30 - inherit (if buildWithPatches then opencl-clang else llvmPackages_15) clang libclang; 31 - spirv-llvm-translator' = spirv-llvm-translator.override { inherit llvm; }; 32 - 33 - # Handholding the braindead build script 34 - # cmake requires an absolute path 35 - prebuilds = runCommandLocal "igc-cclang-prebuilds" { } '' 36 - mkdir $out 37 - ln -s ${clang}/bin/clang $out/ 38 - ln -s ${opencl-clang}/lib/* $out/ 39 - ln -s ${lib.getLib libclang}/lib/clang/${lib.getVersion clang}/include/opencl-c.h $out/ 40 - ln -s ${lib.getLib libclang}/lib/clang/${lib.getVersion clang}/include/opencl-c-base.h $out/ 41 - ''; 42 - in 43 17 stdenv.mkDerivation rec { 44 18 pname = "intel-graphics-compiler"; 45 19 version = "2.16.0"; 46 20 47 - src = fetchFromGitHub { 48 - owner = "intel"; 49 - repo = "intel-graphics-compiler"; 50 - tag = "v${version}"; 51 - hash = "sha256-vtVktc77OT7OANVXnLvEQx+NEQBPrTE5FFynXhpsK7o="; 52 - }; 21 + # See the repository for expected versions: 22 + # <https://github.com/intel/intel-graphics-compiler/blob/v2.16.0/documentation/build_ubuntu.md#revision-table> 23 + srcs = [ 24 + (fetchFromGitHub { 25 + name = "igc"; 26 + owner = "intel"; 27 + repo = "intel-graphics-compiler"; 28 + tag = "v${version}"; 29 + hash = "sha256-vtVktc77OT7OANVXnLvEQx+NEQBPrTE5FFynXhpsK7o="; 30 + }) 31 + (fetchFromGitHub { 32 + name = "llvm-project"; 33 + owner = "llvm"; 34 + repo = "llvm-project"; 35 + tag = "llvmorg-15.0.7"; 36 + hash = "sha256-wjuZQyXQ/jsmvy6y1aksCcEDXGBjuhpgngF3XQJ/T4s="; 37 + }) 38 + (fetchFromGitHub { 39 + name = "vc-intrinsics"; 40 + owner = "intel"; 41 + repo = "vc-intrinsics"; 42 + tag = "v0.23.1"; 43 + hash = "sha256-7coQegLcgIKiqnonZmgrKlw6FCB3ltSh6oMMvdopeQc="; 44 + }) 45 + (fetchFromGitHub { 46 + name = "opencl-clang"; 47 + owner = "intel"; 48 + repo = "opencl-clang"; 49 + tag = "v15.0.3"; 50 + hash = "sha256-JkYFmnDh7Ot3Br/818aLN33COEG7+xyOf8OhdoJX9Cw=="; 51 + }) 52 + (fetchFromGitHub { 53 + name = "llvm-spirv"; 54 + owner = "KhronosGroup"; 55 + repo = "SPIRV-LLVM-Translator"; 56 + tag = "v15.0.15"; 57 + hash = "sha256-kFVDS+qwoG1AXrZ8LytoiLVbZkTGR9sO+Wrq3VGgWNQ="; 58 + }) 59 + ]; 60 + 61 + sourceRoot = "."; 62 + 63 + cmakeDir = "../igc"; 64 + 65 + postUnpack = '' 66 + chmod -R +w . 67 + mv opencl-clang llvm-spirv llvm-project/llvm/projects/ 68 + ''; 53 69 54 70 postPatch = '' 55 - substituteInPlace IGC/AdaptorOCL/igc-opencl.pc.in \ 71 + substituteInPlace igc/IGC/AdaptorOCL/igc-opencl.pc.in \ 56 72 --replace-fail '/@CMAKE_INSTALL_INCLUDEDIR@' "/include" \ 57 73 --replace-fail '/@CMAKE_INSTALL_LIBDIR@' "/lib" 58 74 59 - chmod +x IGC/Scripts/igc_create_linker_script.sh 60 - patchShebangs --build IGC/Scripts/igc_create_linker_script.sh 75 + chmod +x igc/IGC/Scripts/igc_create_linker_script.sh 76 + patchShebangs --build igc/IGC/Scripts/igc_create_linker_script.sh 77 + 78 + # The build system only applies patches when the sources are in a 79 + # Git repository. 80 + git -C llvm-project init 81 + git -C llvm-project -c user.name=nixbld -c user.email= commit --allow-empty -m stub 82 + substituteInPlace llvm-project/llvm/projects/opencl-clang/cmake/modules/CMakeFunctions.cmake \ 83 + --replace-fail 'COMMAND ''${GIT_EXECUTABLE} am --3way --ignore-whitespace -C0 ' \ 84 + 'COMMAND patch -p1 --ignore-whitespace -i ' 61 85 ''; 62 86 63 87 nativeBuildInputs = [ 64 - bash 65 88 bison 66 89 cmake 67 90 flex 91 + git 92 + ninja 68 93 (python3.withPackages ( 69 94 ps: with ps; [ 70 95 mako 71 96 pyyaml 72 97 ] 73 98 )) 99 + zlib 74 100 ]; 75 101 76 102 buildInputs = [ 77 - lld 78 - llvm 79 103 spirv-headers 80 - spirv-llvm-translator' 81 104 spirv-tools 82 105 ]; 83 106 ··· 87 110 doCheck = false; 88 111 89 112 cmakeFlags = [ 90 - "-DVC_INTRINSICS_SRC=${vc_intrinsics_src}" 91 - "-DCCLANG_BUILD_PREBUILDS=ON" 92 - "-DCCLANG_BUILD_PREBUILDS_DIR=${prebuilds}" 93 113 "-DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds" 94 - "-DIGC_OPTION__VC_INTRINSICS_MODE=Source" 114 + "-DIGC_OPTION__USE_PREINSTALLED_SPIRV_HEADERS=ON" 115 + "-DSPIRV-Headers_INCLUDE_DIR=${spirv-headers}/include" 116 + "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${spirv-headers.src}" 95 117 "-Wno-dev" 96 118 ]; 97 119 ··· 102 124 meta = with lib; { 103 125 description = "LLVM-based compiler for OpenCL targeting Intel Gen graphics hardware"; 104 126 homepage = "https://github.com/intel/intel-graphics-compiler"; 105 - changelog = "https://github.com/intel/intel-graphics-compiler/releases/tag/${src.rev}"; 127 + changelog = "https://github.com/intel/intel-graphics-compiler/releases/tag/${version}"; 106 128 license = licenses.mit; 107 129 platforms = platforms.linux; 108 130 maintainers = with maintainers; [ SuperSandro2000 ];
-25
pkgs/by-name/op/opencl-clang/opencl-headers-dir.patch
··· 1 - diff --git a/cl_headers/CMakeLists.txt b/cl_headers/CMakeLists.txt 2 - index 3dd2ea4..aeae6e9 100644 3 - --- a/cl_headers/CMakeLists.txt 4 - +++ b/cl_headers/CMakeLists.txt 5 - @@ -11,12 +11,14 @@ add_custom_command( 6 - ) 7 - endfunction(copy_file) 8 - 9 - -if(USE_PREBUILT_LLVM) 10 - - set(OPENCL_HEADERS_DIR 11 - - "${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include/") 12 - -else(USE_PREBUILT_LLVM) 13 - - set(OPENCL_HEADERS_DIR "${CLANG_SOURCE_DIR}/lib/Headers") 14 - -endif(USE_PREBUILT_LLVM) 15 - +if(NOT DEFINED OPENCL_HEADERS_DIR) 16 - + if(USE_PREBUILT_LLVM) 17 - + set(OPENCL_HEADERS_DIR 18 - + "${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include/") 19 - + else(USE_PREBUILT_LLVM) 20 - + set(OPENCL_HEADERS_DIR "${CLANG_SOURCE_DIR}/lib/Headers") 21 - + endif(USE_PREBUILT_LLVM) 22 - +endif() 23 - copy_file(${OPENCL_HEADERS_DIR}/opencl-c.h opencl-c.h) 24 - 25 - add_custom_target (
-123
pkgs/by-name/op/opencl-clang/package.nix
··· 1 - { 2 - lib, 3 - stdenv, 4 - applyPatches, 5 - fetchFromGitHub, 6 - cmake, 7 - git, 8 - llvmPackages_15, 9 - spirv-llvm-translator, 10 - buildWithPatches ? true, 11 - }: 12 - 13 - let 14 - addPatches = 15 - component: pkg: 16 - pkg.overrideAttrs (oldAttrs: { 17 - postPatch = oldAttrs.postPatch or "" + '' 18 - for p in ${passthru.patchesOut}/${component}/*; do 19 - patch -p1 -i "$p" 20 - done 21 - ''; 22 - }); 23 - 24 - llvmPkgs = llvmPackages_15; 25 - inherit (llvmPkgs) llvm; 26 - spirv-llvm-translator' = spirv-llvm-translator.override { inherit llvm; }; 27 - libclang = if buildWithPatches then passthru.libclang else llvmPkgs.libclang; 28 - 29 - passthru = rec { 30 - spirv-llvm-translator = spirv-llvm-translator'; 31 - llvm = addPatches "llvm" llvmPkgs.llvm; 32 - libclang = addPatches "clang" llvmPkgs.libclang; 33 - 34 - clang-unwrapped = libclang.out; 35 - clang = llvmPkgs.clang.override { 36 - cc = clang-unwrapped; 37 - }; 38 - 39 - patchesOut = stdenv.mkDerivation { 40 - pname = "opencl-clang-patches"; 41 - inherit version src; 42 - # Clang patches assume the root is the llvm root dir 43 - # but clang root in nixpkgs is the clang sub-directory 44 - postPatch = '' 45 - for filename in patches/clang/*.patch; do 46 - substituteInPlace "$filename" \ 47 - --replace-fail "a/clang/" "a/" \ 48 - --replace-fail "b/clang/" "b/" 49 - done 50 - ''; 51 - 52 - installPhase = '' 53 - [ -d patches ] && cp -r patches/ $out || mkdir $out 54 - mkdir -p $out/clang $out/llvm 55 - ''; 56 - }; 57 - }; 58 - 59 - version = "15.0.3"; 60 - src = applyPatches { 61 - src = fetchFromGitHub { 62 - owner = "intel"; 63 - repo = "opencl-clang"; 64 - tag = "v${version}"; 65 - hash = "sha256-JkYFmnDh7Ot3Br/818aLN33COEG7+xyOf8OhdoJX9Cw="; 66 - }; 67 - 68 - patches = [ 69 - # Build script tries to find Clang OpenCL headers under ${llvm} 70 - # Work around it by specifying that directory manually. 71 - ./opencl-headers-dir.patch 72 - ]; 73 - 74 - postPatch = '' 75 - # fix not be able to find clang from PATH 76 - substituteInPlace cl_headers/CMakeLists.txt \ 77 - --replace-fail " NO_DEFAULT_PATH" "" 78 - '' 79 - + lib.optionalString stdenv.hostPlatform.isDarwin '' 80 - # Uses linker flags that are not supported on Darwin. 81 - sed -i -e '/SET_LINUX_EXPORTS_FILE/d' CMakeLists.txt 82 - substituteInPlace CMakeLists.txt \ 83 - --replace-fail '-Wl,--no-undefined' "" 84 - ''; 85 - }; 86 - in 87 - 88 - stdenv.mkDerivation { 89 - pname = "opencl-clang"; 90 - inherit version src; 91 - 92 - nativeBuildInputs = [ 93 - cmake 94 - git 95 - llvm.dev 96 - ]; 97 - 98 - buildInputs = [ 99 - libclang 100 - llvm 101 - spirv-llvm-translator' 102 - ]; 103 - 104 - cmakeFlags = [ 105 - "-DPREFERRED_LLVM_VERSION=${lib.getVersion llvm}" 106 - "-DOPENCL_HEADERS_DIR=${lib.getLib libclang}/lib/clang/${lib.getVersion libclang}/include/" 107 - 108 - "-DLLVMSPIRV_INCLUDED_IN_LLVM=OFF" 109 - "-DSPIRV_TRANSLATOR_DIR=${spirv-llvm-translator'}" 110 - ]; 111 - 112 - inherit passthru; 113 - 114 - meta = with lib; { 115 - homepage = "https://github.com/intel/opencl-clang/"; 116 - description = "Clang wrapper library with an OpenCL-oriented API and the ability to compile OpenCL C kernels to SPIR-V modules"; 117 - license = licenses.ncsa; 118 - maintainers = [ ]; 119 - platforms = platforms.all; 120 - # error: invalid value 'CL3.0' in '-cl-std=CL3.0' 121 - broken = stdenv.hostPlatform.isDarwin; 122 - }; 123 - }
+1
pkgs/top-level/aliases.nix
··· 1808 1808 opencv2 = throw "opencv2 has been removed as it is obsolete and was not used by any other package; please migrate to OpenCV 4"; # Added 2024-08-20 1809 1809 opencv3 = throw "opencv3 has been removed as it is obsolete and was not used by any other package; please migrate to OpenCV 4"; # Added 2024-08-20 1810 1810 openafs_1_8 = openafs; # Added 2022-08-22 1811 + opencl-clang = throw "opencl-clang has been integrated into intel-graphics-compiler"; # Added 2025-09-10 1811 1812 opencl-info = throw "opencl-info has been removed, as the upstream is unmaintained; consider using 'clinfo' instead"; # Added 2024-06-12 1812 1813 opencomposite-helper = throw "opencomposite-helper has been removed from nixpkgs as it causes issues with some applications. See https://wiki.nixos.org/wiki/VR#OpenComposite for the recommended setup"; # Added 2024-09-07 1813 1814 openconnect_gnutls = openconnect; # Added 2022-03-29