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