diff --git a/pkgs/by-name/in/intel-graphics-compiler/package.nix b/pkgs/by-name/in/intel-graphics-compiler/package.nix index 00ff791d94ec..60ce83a6aefd 100644 --- a/pkgs/by-name/in/intel-graphics-compiler/package.nix +++ b/pkgs/by-name/in/intel-graphics-compiler/package.nix @@ -2,82 +2,105 @@ lib, stdenv, fetchFromGitHub, - bash, cmake, - runCommandLocal, + ninja, + git, bison, flex, + zlib, intel-compute-runtime, - llvmPackages_15, - opencl-clang, python3, spirv-tools, spirv-headers, - spirv-llvm-translator, - - buildWithPatches ? true, }: -let - vc_intrinsics_src = fetchFromGitHub { - owner = "intel"; - repo = "vc-intrinsics"; - rev = "v0.23.1"; - hash = "sha256-7coQegLcgIKiqnonZmgrKlw6FCB3ltSh6oMMvdopeQc="; - }; - - inherit (llvmPackages_15) lld llvm; - inherit (if buildWithPatches then opencl-clang else llvmPackages_15) clang libclang; - spirv-llvm-translator' = spirv-llvm-translator.override { inherit llvm; }; - - # Handholding the braindead build script - # cmake requires an absolute path - prebuilds = runCommandLocal "igc-cclang-prebuilds" { } '' - mkdir $out - ln -s ${clang}/bin/clang $out/ - ln -s ${opencl-clang}/lib/* $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/ - ''; -in stdenv.mkDerivation rec { pname = "intel-graphics-compiler"; version = "2.16.0"; - src = fetchFromGitHub { - owner = "intel"; - repo = "intel-graphics-compiler"; - tag = "v${version}"; - hash = "sha256-vtVktc77OT7OANVXnLvEQx+NEQBPrTE5FFynXhpsK7o="; - }; + # See the repository for expected versions: + # + srcs = [ + (fetchFromGitHub { + name = "igc"; + owner = "intel"; + repo = "intel-graphics-compiler"; + tag = "v${version}"; + hash = "sha256-vtVktc77OT7OANVXnLvEQx+NEQBPrTE5FFynXhpsK7o="; + }) + (fetchFromGitHub { + name = "llvm-project"; + owner = "llvm"; + repo = "llvm-project"; + tag = "llvmorg-15.0.7"; + hash = "sha256-wjuZQyXQ/jsmvy6y1aksCcEDXGBjuhpgngF3XQJ/T4s="; + }) + (fetchFromGitHub { + name = "vc-intrinsics"; + owner = "intel"; + repo = "vc-intrinsics"; + tag = "v0.23.1"; + hash = "sha256-7coQegLcgIKiqnonZmgrKlw6FCB3ltSh6oMMvdopeQc="; + }) + (fetchFromGitHub { + name = "opencl-clang"; + owner = "intel"; + repo = "opencl-clang"; + tag = "v15.0.3"; + hash = "sha256-JkYFmnDh7Ot3Br/818aLN33COEG7+xyOf8OhdoJX9Cw=="; + }) + (fetchFromGitHub { + name = "llvm-spirv"; + owner = "KhronosGroup"; + repo = "SPIRV-LLVM-Translator"; + tag = "v15.0.15"; + hash = "sha256-kFVDS+qwoG1AXrZ8LytoiLVbZkTGR9sO+Wrq3VGgWNQ="; + }) + ]; + + sourceRoot = "."; + + cmakeDir = "../igc"; + + postUnpack = '' + chmod -R +w . + mv opencl-clang llvm-spirv llvm-project/llvm/projects/ + ''; postPatch = '' - substituteInPlace IGC/AdaptorOCL/igc-opencl.pc.in \ + substituteInPlace igc/IGC/AdaptorOCL/igc-opencl.pc.in \ --replace-fail '/@CMAKE_INSTALL_INCLUDEDIR@' "/include" \ --replace-fail '/@CMAKE_INSTALL_LIBDIR@' "/lib" - chmod +x IGC/Scripts/igc_create_linker_script.sh - patchShebangs --build IGC/Scripts/igc_create_linker_script.sh + chmod +x igc/IGC/Scripts/igc_create_linker_script.sh + patchShebangs --build igc/IGC/Scripts/igc_create_linker_script.sh + + # The build system only applies patches when the sources are in a + # Git repository. + git -C llvm-project init + git -C llvm-project -c user.name=nixbld -c user.email= commit --allow-empty -m stub + substituteInPlace llvm-project/llvm/projects/opencl-clang/cmake/modules/CMakeFunctions.cmake \ + --replace-fail 'COMMAND ''${GIT_EXECUTABLE} am --3way --ignore-whitespace -C0 ' \ + 'COMMAND patch -p1 --ignore-whitespace -i ' ''; nativeBuildInputs = [ - bash bison cmake flex + git + ninja (python3.withPackages ( ps: with ps; [ mako pyyaml ] )) + zlib ]; buildInputs = [ - lld - llvm spirv-headers - spirv-llvm-translator' spirv-tools ]; @@ -87,11 +110,10 @@ stdenv.mkDerivation rec { doCheck = false; cmakeFlags = [ - "-DVC_INTRINSICS_SRC=${vc_intrinsics_src}" - "-DCCLANG_BUILD_PREBUILDS=ON" - "-DCCLANG_BUILD_PREBUILDS_DIR=${prebuilds}" "-DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds" - "-DIGC_OPTION__VC_INTRINSICS_MODE=Source" + "-DIGC_OPTION__USE_PREINSTALLED_SPIRV_HEADERS=ON" + "-DSPIRV-Headers_INCLUDE_DIR=${spirv-headers}/include" + "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${spirv-headers.src}" "-Wno-dev" ]; @@ -102,7 +124,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "LLVM-based compiler for OpenCL targeting Intel Gen graphics hardware"; homepage = "https://github.com/intel/intel-graphics-compiler"; - changelog = "https://github.com/intel/intel-graphics-compiler/releases/tag/${src.rev}"; + changelog = "https://github.com/intel/intel-graphics-compiler/releases/tag/${version}"; license = licenses.mit; platforms = platforms.linux; maintainers = with maintainers; [ SuperSandro2000 ]; diff --git a/pkgs/by-name/op/opencl-clang/opencl-headers-dir.patch b/pkgs/by-name/op/opencl-clang/opencl-headers-dir.patch deleted file mode 100644 index 70343b8ee197..000000000000 --- a/pkgs/by-name/op/opencl-clang/opencl-headers-dir.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff --git a/cl_headers/CMakeLists.txt b/cl_headers/CMakeLists.txt -index 3dd2ea4..aeae6e9 100644 ---- a/cl_headers/CMakeLists.txt -+++ b/cl_headers/CMakeLists.txt -@@ -11,12 +11,14 @@ add_custom_command( - ) - endfunction(copy_file) - --if(USE_PREBUILT_LLVM) -- set(OPENCL_HEADERS_DIR -- "${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include/") --else(USE_PREBUILT_LLVM) -- set(OPENCL_HEADERS_DIR "${CLANG_SOURCE_DIR}/lib/Headers") --endif(USE_PREBUILT_LLVM) -+if(NOT DEFINED OPENCL_HEADERS_DIR) -+ if(USE_PREBUILT_LLVM) -+ set(OPENCL_HEADERS_DIR -+ "${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}/include/") -+ else(USE_PREBUILT_LLVM) -+ set(OPENCL_HEADERS_DIR "${CLANG_SOURCE_DIR}/lib/Headers") -+ endif(USE_PREBUILT_LLVM) -+endif() - copy_file(${OPENCL_HEADERS_DIR}/opencl-c.h opencl-c.h) - - add_custom_target ( diff --git a/pkgs/by-name/op/opencl-clang/package.nix b/pkgs/by-name/op/opencl-clang/package.nix deleted file mode 100644 index 3b9157221eca..000000000000 --- a/pkgs/by-name/op/opencl-clang/package.nix +++ /dev/null @@ -1,123 +0,0 @@ -{ - lib, - stdenv, - applyPatches, - fetchFromGitHub, - cmake, - git, - llvmPackages_15, - spirv-llvm-translator, - buildWithPatches ? true, -}: - -let - addPatches = - component: pkg: - pkg.overrideAttrs (oldAttrs: { - postPatch = oldAttrs.postPatch or "" + '' - for p in ${passthru.patchesOut}/${component}/*; do - patch -p1 -i "$p" - done - ''; - }); - - llvmPkgs = llvmPackages_15; - inherit (llvmPkgs) llvm; - spirv-llvm-translator' = spirv-llvm-translator.override { inherit llvm; }; - libclang = if buildWithPatches then passthru.libclang else llvmPkgs.libclang; - - passthru = rec { - spirv-llvm-translator = spirv-llvm-translator'; - llvm = addPatches "llvm" llvmPkgs.llvm; - libclang = addPatches "clang" llvmPkgs.libclang; - - clang-unwrapped = libclang.out; - clang = llvmPkgs.clang.override { - cc = clang-unwrapped; - }; - - patchesOut = stdenv.mkDerivation { - pname = "opencl-clang-patches"; - inherit version src; - # Clang patches assume the root is the llvm root dir - # but clang root in nixpkgs is the clang sub-directory - postPatch = '' - for filename in patches/clang/*.patch; do - substituteInPlace "$filename" \ - --replace-fail "a/clang/" "a/" \ - --replace-fail "b/clang/" "b/" - done - ''; - - installPhase = '' - [ -d patches ] && cp -r patches/ $out || mkdir $out - mkdir -p $out/clang $out/llvm - ''; - }; - }; - - version = "15.0.3"; - src = applyPatches { - src = fetchFromGitHub { - owner = "intel"; - repo = "opencl-clang"; - tag = "v${version}"; - hash = "sha256-JkYFmnDh7Ot3Br/818aLN33COEG7+xyOf8OhdoJX9Cw="; - }; - - patches = [ - # Build script tries to find Clang OpenCL headers under ${llvm} - # Work around it by specifying that directory manually. - ./opencl-headers-dir.patch - ]; - - postPatch = '' - # fix not be able to find clang from PATH - substituteInPlace cl_headers/CMakeLists.txt \ - --replace-fail " NO_DEFAULT_PATH" "" - '' - + lib.optionalString stdenv.hostPlatform.isDarwin '' - # Uses linker flags that are not supported on Darwin. - sed -i -e '/SET_LINUX_EXPORTS_FILE/d' CMakeLists.txt - substituteInPlace CMakeLists.txt \ - --replace-fail '-Wl,--no-undefined' "" - ''; - }; -in - -stdenv.mkDerivation { - pname = "opencl-clang"; - inherit version src; - - nativeBuildInputs = [ - cmake - git - llvm.dev - ]; - - buildInputs = [ - libclang - llvm - spirv-llvm-translator' - ]; - - cmakeFlags = [ - "-DPREFERRED_LLVM_VERSION=${lib.getVersion llvm}" - "-DOPENCL_HEADERS_DIR=${lib.getLib libclang}/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 = "Clang wrapper library with an OpenCL-oriented API and the ability to compile OpenCL C kernels to SPIR-V modules"; - license = licenses.ncsa; - maintainers = [ ]; - platforms = platforms.all; - # error: invalid value 'CL3.0' in '-cl-std=CL3.0' - broken = stdenv.hostPlatform.isDarwin; - }; -} diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index d18eb30642c7..646055501465 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -1808,6 +1808,7 @@ mapAliases { 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 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 openafs_1_8 = openafs; # Added 2022-08-22 + opencl-clang = throw "opencl-clang has been integrated into intel-graphics-compiler"; # Added 2025-09-10 opencl-info = throw "opencl-info has been removed, as the upstream is unmaintained; consider using 'clinfo' instead"; # Added 2024-06-12 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 openconnect_gnutls = openconnect; # Added 2022-03-29