nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

opencl-clang: unstable-2022-03-16 -> unstable-2023-06-12

+70 -58
+70 -58
pkgs/development/libraries/opencl-clang/default.nix
··· 1 1 { lib 2 2 , stdenv 3 + , applyPatches 3 4 , fetchFromGitHub 4 5 , fetchpatch 5 6 , cmake 6 7 , git 7 - , llvmPackages_11 8 + , llvmPackages_14 8 9 , spirv-llvm-translator 9 10 , buildWithPatches ? true 10 11 }: 11 12 12 13 let 13 - llvmPkgs = llvmPackages_11 // { 14 - inherit spirv-llvm-translator; 15 - }; 16 - 17 14 addPatches = component: pkg: pkg.overrideAttrs (oldAttrs: { 18 15 postPatch = oldAttrs.postPatch or "" + '' 19 16 for p in ${passthru.patchesOut}/${component}/*; do ··· 19 22 ''; 20 23 }); 21 24 25 + llvmPkgs = llvmPackages_14; 26 + inherit (llvmPkgs) llvm; 27 + spirv-llvm-translator' = spirv-llvm-translator.override { inherit llvm; }; 28 + libclang = if buildWithPatches then passthru.libclang else llvmPkgs.libclang; 29 + 22 30 passthru = rec { 23 - spirv-llvm-translator = llvmPkgs.spirv-llvm-translator.override { llvm = llvmPackages_11.llvm; }; 31 + spirv-llvm-translator = spirv-llvm-translator'; 24 32 llvm = addPatches "llvm" llvmPkgs.llvm; 25 33 libclang = addPatches "clang" llvmPkgs.libclang; 26 34 ··· 36 34 37 35 patchesOut = stdenv.mkDerivation { 38 36 pname = "opencl-clang-patches"; 39 - inherit (library) version src patches; 37 + inherit version src; 40 38 # Clang patches assume the root is the llvm root dir 41 39 # but clang root in nixpkgs is the clang sub-directory 42 40 postPatch = '' ··· 54 52 }; 55 53 }; 56 54 57 - library = let 58 - inherit (llvmPackages_11) llvm; 59 - inherit (if buildWithPatches then passthru else llvmPkgs) libclang spirv-llvm-translator; 60 - in 61 - stdenv.mkDerivation { 62 - pname = "opencl-clang"; 63 - version = "unstable-2022-03-16"; 64 - 65 - 66 - src = fetchFromGitHub { 67 - owner = "intel"; 68 - repo = "opencl-clang"; 69 - rev = "bbdd1587f577397a105c900be114b56755d1f7dc"; 70 - sha256 = "sha256-qEZoQ6h4XAvSnJ7/gLXBb1qrzeYa6Jp6nij9VFo8MwQ="; 71 - }; 72 - 73 - patches = [ 74 - # Build script tries to find Clang OpenCL headers under ${llvm} 75 - # Work around it by specifying that directory manually. 76 - ./opencl-headers-dir.patch 77 - ]; 78 - 79 - # Uses linker flags that are not supported on Darwin. 80 - postPatch = lib.optionalString stdenv.isDarwin '' 81 - sed -i -e '/SET_LINUX_EXPORTS_FILE/d' CMakeLists.txt 82 - substituteInPlace CMakeLists.txt \ 83 - --replace '-Wl,--no-undefined' "" 84 - ''; 85 - 86 - nativeBuildInputs = [ cmake git llvm.dev ]; 87 - 88 - buildInputs = [ libclang llvm spirv-llvm-translator ]; 89 - 90 - cmakeFlags = [ 91 - "-DPREFERRED_LLVM_VERSION=${lib.getVersion llvm}" 92 - "-DOPENCL_HEADERS_DIR=${libclang.lib}/lib/clang/${lib.getVersion libclang}/include/" 93 - 94 - "-DLLVMSPIRV_INCLUDED_IN_LLVM=OFF" 95 - "-DSPIRV_TRANSLATOR_DIR=${spirv-llvm-translator}" 96 - ]; 97 - 98 - inherit passthru; 99 - 100 - meta = with lib; { 101 - homepage = "https://github.com/intel/opencl-clang/"; 102 - description = "A clang wrapper library with an OpenCL-oriented API and the ability to compile OpenCL C kernels to SPIR-V modules"; 103 - license = licenses.ncsa; 104 - platforms = platforms.all; 105 - maintainers = with maintainers; [ ]; 106 - }; 55 + version = "unstable-2023-06-12"; 56 + src = applyPatches { 57 + src = fetchFromGitHub { 58 + owner = "intel"; 59 + repo = "opencl-clang"; 60 + # https://github.com/intel/opencl-clang/compare/ocl-open-140 61 + rev = "cf95b338d14685e4f3402ab1828bef31d48f1fd6"; 62 + hash = "sha256-To1RlQX9IJ+1zAwEXaW7ua3VNfjK9mu7pgsRPsfa8g8="; 107 63 }; 64 + 65 + patches = [ 66 + # Build script tries to find Clang OpenCL headers under ${llvm} 67 + # Work around it by specifying that directory manually. 68 + ./opencl-headers-dir.patch 69 + 70 + # fix CMake throwing errors 71 + (fetchpatch { 72 + url = "https://github.com/intel/opencl-clang/commit/321e3b99c1a8d54c8475f5ae998452069cc5eb71.patch"; 73 + hash = "sha256-cATbH+AMVtcabhl3EkzAH7w3wGreUV53hQYHVUUEP4g="; 74 + }) 75 + ]; 76 + 77 + postPatch = '' 78 + # fix not be able to find clang from PATH 79 + substituteInPlace cl_headers/CMakeLists.txt \ 80 + --replace " NO_DEFAULT_PATH" "" 81 + '' + lib.optionalString stdenv.isDarwin '' 82 + # Uses linker flags that are not supported on Darwin. 83 + sed -i -e '/SET_LINUX_EXPORTS_FILE/d' CMakeLists.txt 84 + substituteInPlace CMakeLists.txt \ 85 + --replace '-Wl,--no-undefined' "" 86 + ''; 87 + }; 108 88 in 109 - library 89 + 90 + stdenv.mkDerivation { 91 + pname = "opencl-clang"; 92 + inherit version src; 93 + 94 + nativeBuildInputs = [ cmake git llvm.dev ]; 95 + 96 + buildInputs = [ libclang llvm spirv-llvm-translator' ]; 97 + 98 + cmakeFlags = [ 99 + "-DPREFERRED_LLVM_VERSION=${lib.getVersion llvm}" 100 + "-DOPENCL_HEADERS_DIR=${libclang.lib}/lib/clang/${lib.getVersion libclang}/include/" 101 + 102 + "-DLLVMSPIRV_INCLUDED_IN_LLVM=OFF" 103 + "-DSPIRV_TRANSLATOR_DIR=${spirv-llvm-translator'}" 104 + ]; 105 + 106 + inherit passthru; 107 + 108 + meta = with lib; { 109 + homepage = "https://github.com/intel/opencl-clang/"; 110 + description = "A clang wrapper library with an OpenCL-oriented API and the ability to compile OpenCL C kernels to SPIR-V modules"; 111 + license = licenses.ncsa; 112 + maintainers = with maintainers; [ ]; 113 + platforms = platforms.all; 114 + # error: invalid value 'CL3.0' in '-cl-std=CL3.0' 115 + broken = stdenv.isDarwin; 116 + }; 117 + }