1 |
commit: 38ab28e27cd7da59f4a241b09d3ac734c4f8b575 |
2 |
Author: Yiyang Wu <xgreenlandforwyy <AT> gmail <DOT> com> |
3 |
AuthorDate: Wed Jan 25 03:14:27 2023 +0000 |
4 |
Commit: Benda XU <heroxbd <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jan 31 13:31:07 2023 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=38ab28e2 |
7 |
|
8 |
dev-util/hip: Backport fixes for clang directories search |
9 |
|
10 |
Closes: https://bugs.gentoo.org/891013 |
11 |
Signed-off-by: Yiyang Wu <xgreenlandforwyy <AT> gmail.com> |
12 |
Signed-off-by: Benda Xu <heroxbd <AT> gentoo.org> |
13 |
|
14 |
...0-hipcc-fails-to-parse-version-of-clang-i.patch | 70 +++++++++ |
15 |
...8-LLVM-pkg-search-directly-using-find_dep.patch | 163 +++++++++++++++++++ |
16 |
...DEV-355608-Remove-clang-include-path-2996.patch | 51 ++++++ |
17 |
...8-Removed-relative-path-based-CLANG-inclu.patch | 173 +++++++++++++++++++++ |
18 |
dev-util/hip/files/hipvars-5.3.3.pm | 20 +++ |
19 |
dev-util/hip/hip-5.3.3-r2.ebuild | 17 +- |
20 |
6 files changed, 483 insertions(+), 11 deletions(-) |
21 |
|
22 |
diff --git a/dev-util/hip/files/0001-SWDEV-344620-hipcc-fails-to-parse-version-of-clang-i.patch b/dev-util/hip/files/0001-SWDEV-344620-hipcc-fails-to-parse-version-of-clang-i.patch |
23 |
new file mode 100644 |
24 |
index 000000000000..b9a1329e5931 |
25 |
--- /dev/null |
26 |
+++ b/dev-util/hip/files/0001-SWDEV-344620-hipcc-fails-to-parse-version-of-clang-i.patch |
27 |
@@ -0,0 +1,70 @@ |
28 |
+From 73430b62a5437d1ba6c36a1d812a1434d1ad9df7 Mon Sep 17 00:00:00 2001 |
29 |
+From: ROCm CI Service Account <66695075+rocm-ci@××××××××××××××××××××.com> |
30 |
+Date: Tue, 20 Dec 2022 06:51:12 +0530 |
31 |
+Subject: [PATCH 1/3] SWDEV-344620 - hipcc fails to parse version of clang in |
32 |
+ some cases (#3119) |
33 |
+ |
34 |
+Change-Id: I46f716c82a7500b9a2bcaf5f9ff4ad8a8f982770 |
35 |
+Signed-off-by: Yiyang Wu <xgreenlandforwyy@×××××.com> |
36 |
+--- |
37 |
+ bin/hipcc.pl | 22 +++++++--------------- |
38 |
+ 1 file changed, 7 insertions(+), 15 deletions(-) |
39 |
+ |
40 |
+diff --git a/bin/hipcc.pl b/bin/hipcc.pl |
41 |
+index 645ae62d..2a01dcc3 100755 |
42 |
+--- a/bin/hipcc.pl |
43 |
++++ b/bin/hipcc.pl |
44 |
+@@ -144,7 +144,7 @@ if ($HIP_PLATFORM eq "amd") { |
45 |
+ $execExtension = ""; |
46 |
+ if($isWindows) { |
47 |
+ $execExtension = ".exe"; |
48 |
+- } |
49 |
++ } |
50 |
+ $HIPCC="$HIP_CLANG_PATH/clang++" . $execExtension; |
51 |
+ |
52 |
+ # If $HIPCC clang++ is not compiled, use clang instead |
53 |
+@@ -157,13 +157,10 @@ if ($HIP_PLATFORM eq "amd") { |
54 |
+ $HIPLDFLAGS .= " -fuse-ld=lld"; |
55 |
+ $HIPLDFLAGS .= " --ld-path=$HIP_CLANG_PATH/lld-link.exe"; |
56 |
+ } |
57 |
+- $HIP_CLANG_VERSION = `$HIPCC --version`; |
58 |
+- $HIP_CLANG_VERSION=~/.*clang version (\S+).*/; |
59 |
+- $HIP_CLANG_VERSION=$1; |
60 |
+ |
61 |
+- # Figure out the target with which llvm is configured |
62 |
+- $HIP_CLANG_TARGET = `$HIPCC -print-target-triple`; |
63 |
+- $HIP_CLANG_TARGET = chomp($HIP_CLANG_TARGET); |
64 |
++ # get Clang RT Builtin path |
65 |
++ $HIP_CLANG_RT_LIB = `$HIPCC --print-runtime-dir`; |
66 |
++ chomp($HIP_CLANG_RT_LIB); |
67 |
+ |
68 |
+ if (! defined $HIP_CLANG_INCLUDE_PATH) { |
69 |
+ $HIP_CLANG_INCLUDE_PATH = abs_path("$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/include"); |
70 |
+@@ -184,7 +181,7 @@ if ($HIP_PLATFORM eq "amd") { |
71 |
+ print ("HIP_INCLUDE_PATH=$HIP_INCLUDE_PATH\n"); |
72 |
+ print ("HIP_LIB_PATH=$HIP_LIB_PATH\n"); |
73 |
+ print ("DEVICE_LIB_PATH=$DEVICE_LIB_PATH\n"); |
74 |
+- print ("HIP_CLANG_TARGET=$HIP_CLANG_TARGET\n"); |
75 |
++ print ("HIP_CLANG_RT_LIB=$HIP_CLANG_RT_LIB\n"); |
76 |
+ } |
77 |
+ |
78 |
+ if ($isWindows) { |
79 |
+@@ -715,13 +712,8 @@ if ($HIP_PLATFORM eq "amd") { |
80 |
+ } else { |
81 |
+ $toolArgs = ${toolArgs} . " -Wl,--enable-new-dtags -Wl,-rpath=$HIP_LIB_PATH:$ROCM_PATH/lib -lamdhip64 "; |
82 |
+ } |
83 |
+- # To support __fp16 and _Float16, explicitly link with compiler-rt |
84 |
+- $HIP_CLANG_BUILTIN_LIB="$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/$HIP_CLANG_TARGET/libclang_rt.builtins.a"; |
85 |
+- if (-e $HIP_CLANG_BUILTIN_LIB) { |
86 |
+- $toolArgs .= " -L$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/$HIP_CLANG_TARGET -lclang_rt.builtins " |
87 |
+- } else { |
88 |
+- $toolArgs .= " -L$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/linux -lclang_rt.builtins-x86_64 " |
89 |
+- } |
90 |
++ |
91 |
++ $toolArgs .= " -L$HIP_CLANG_RT_LIB -lclang_rt.builtins-x86_64 " |
92 |
+ } |
93 |
+ } |
94 |
+ |
95 |
+-- |
96 |
+2.38.1 |
97 |
+ |
98 |
|
99 |
diff --git a/dev-util/hip/files/0001-SWDEV-352878-LLVM-pkg-search-directly-using-find_dep.patch b/dev-util/hip/files/0001-SWDEV-352878-LLVM-pkg-search-directly-using-find_dep.patch |
100 |
new file mode 100644 |
101 |
index 000000000000..9dbfe8a55395 |
102 |
--- /dev/null |
103 |
+++ b/dev-util/hip/files/0001-SWDEV-352878-LLVM-pkg-search-directly-using-find_dep.patch |
104 |
@@ -0,0 +1,163 @@ |
105 |
+From 6c12b045bc3c434dd13e74bf124ed54afec668c6 Mon Sep 17 00:00:00 2001 |
106 |
+From: AravindanC <aravindan.cheruvally@×××.com> |
107 |
+Date: Fri, 26 Aug 2022 15:02:09 -0700 |
108 |
+Subject: [PATCH] SWDEV-352878 - LLVM pkg search directly using find_dep() for |
109 |
+ CLANG Include path |
110 |
+ |
111 |
+Change-Id: I355e39890757be07de8b9332deca159f35039dfd |
112 |
+Signed-off-by: Yiyang Wu <xgreenlandforwyy@×××××.com> |
113 |
+--- |
114 |
+ hip-config.cmake.in | 108 ++++++++++++++++++++++++++------------------ |
115 |
+ 1 file changed, 64 insertions(+), 44 deletions(-) |
116 |
+ |
117 |
+diff --git a/hip-config.cmake.in b/hip-config.cmake.in |
118 |
+index 89d1224e..67d898d8 100755 |
119 |
+--- a/hip-config.cmake.in |
120 |
++++ b/hip-config.cmake.in |
121 |
+@@ -147,41 +147,62 @@ if(HIP_COMPILER STREQUAL "clang") |
122 |
+ if(NOT HIP_CXX_COMPILER) |
123 |
+ set(HIP_CXX_COMPILER ${CMAKE_CXX_COMPILER}) |
124 |
+ endif() |
125 |
+- if(HIP_CXX_COMPILER MATCHES ".*hipcc" OR HIP_CXX_COMPILER MATCHES ".*clang\\+\\+") |
126 |
+- execute_process(COMMAND ${HIP_CXX_COMPILER} --version |
127 |
++ |
128 |
++ # Use HIP_CXX_COMPILER option -print-resource-dir |
129 |
++ # To fetch the clang include path |
130 |
++ execute_process( |
131 |
++ COMMAND ${HIP_CXX_COMPILER} -print-resource-dir |
132 |
++ OUTPUT_VARIABLE HIP_CLANG_INCLUDE_PATH |
133 |
++ OUTPUT_STRIP_TRAILING_WHITESPACE |
134 |
++ RESULT_VARIABLE CLANG_INCLUDE_PATH_FETCH_EXIT_CODE) |
135 |
++ |
136 |
++ if( NOT "${CLANG_INCLUDE_PATH_FETCH_EXIT_CODE}" STREQUAL "0" ) |
137 |
++ if(HIP_CXX_COMPILER MATCHES ".*hipcc" OR HIP_CXX_COMPILER MATCHES ".*clang\\+\\+") |
138 |
++ # IF not successful in fetching HIP_CLANG_INCLUDE_PATH using |
139 |
++ # HIP_CXX_COMPILER binary command options -print-resource-dir |
140 |
++ # fallback to old method of getting include by finding HIP_CLANG_ROOT |
141 |
++ # and from predefined relative path of HIP_CLANG_ROOT |
142 |
++ execute_process(COMMAND ${HIP_CXX_COMPILER} --version |
143 |
+ OUTPUT_STRIP_TRAILING_WHITESPACE |
144 |
+ OUTPUT_VARIABLE HIP_CXX_COMPILER_VERSION_OUTPUT) |
145 |
+- # Capture the repo, branch and patch level details of the HIP CXX Compiler. |
146 |
+- # Ex. clang version 13.0.0 (https://github.com/ROCm-Developer-Tools/HIP main 12345 COMMIT_HASH) |
147 |
+- # HIP_CLANG_REPO: https://github.com/ROCm-Developer-Tools/HIP |
148 |
+- # HIP_CLANG_BRANCH: main |
149 |
+- # HIP_CLANG_PATCH_LEVEL: 12345 |
150 |
+- if(${HIP_CXX_COMPILER_VERSION_OUTPUT} MATCHES "clang version [0-9]+\\.[0-9]+\\.[0-9]+ \\(([^ \n]*) ([^ \n]*) ([^ \n]*)") |
151 |
+- set(HIP_CLANG_REPO ${CMAKE_MATCH_1}) |
152 |
+- set(HIP_CLANG_BRANCH ${CMAKE_MATCH_2}) |
153 |
+- set(HIP_CLANG_PATCH_LEVEL ${CMAKE_MATCH_3}) |
154 |
+- endif() |
155 |
+- endif() |
156 |
+- if(HIP_CXX_COMPILER MATCHES ".*hipcc") |
157 |
+- if(HIP_CXX_COMPILER_VERSION_OUTPUT MATCHES "InstalledDir:[ \t]*([^\n]*)") |
158 |
+- get_filename_component(HIP_CLANG_ROOT "${CMAKE_MATCH_1}" DIRECTORY) |
159 |
+- endif() |
160 |
+- elseif (HIP_CXX_COMPILER MATCHES ".*clang\\+\\+") |
161 |
+- get_filename_component(_HIP_CLANG_REAL_PATH "${HIP_CXX_COMPILER}" REALPATH) |
162 |
+- get_filename_component(_HIP_CLANG_BIN_PATH "${_HIP_CLANG_REAL_PATH}" DIRECTORY) |
163 |
+- get_filename_component(HIP_CLANG_ROOT "${_HIP_CLANG_BIN_PATH}" DIRECTORY) |
164 |
+- endif() |
165 |
+- file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS ${HIP_CLANG_ROOT}/lib/clang/*/include) |
166 |
+- find_path(HIP_CLANG_INCLUDE_PATH stddef.h |
167 |
+- HINTS |
168 |
++ # Capture the repo, branch and patch level details of the HIP CXX Compiler. |
169 |
++ # Ex. clang version 13.0.0 (https://github.com/ROCm-Developer-Tools/HIP main 12345 COMMIT_HASH) |
170 |
++ # HIP_CLANG_REPO: https://github.com/ROCm-Developer-Tools/HIP |
171 |
++ # HIP_CLANG_BRANCH: main |
172 |
++ # HIP_CLANG_PATCH_LEVEL: 12345 |
173 |
++ if(${HIP_CXX_COMPILER_VERSION_OUTPUT} MATCHES "clang version [0-9]+\\.[0-9]+\\.[0-9]+ \\(([^ \n]*) ([^ \n]*) ([^ \n]*)") |
174 |
++ set(HIP_CLANG_REPO ${CMAKE_MATCH_1}) |
175 |
++ set(HIP_CLANG_BRANCH ${CMAKE_MATCH_2}) |
176 |
++ set(HIP_CLANG_PATCH_LEVEL ${CMAKE_MATCH_3}) |
177 |
++ endif() |
178 |
++ if(HIP_CXX_COMPILER MATCHES ".*hipcc") |
179 |
++ if(HIP_CXX_COMPILER_VERSION_OUTPUT MATCHES "InstalledDir:[ \t]*([^\n]*)") |
180 |
++ get_filename_component(HIP_CLANG_ROOT "${CMAKE_MATCH_1}" DIRECTORY) |
181 |
++ endif() |
182 |
++ elseif (HIP_CXX_COMPILER MATCHES ".*clang\\+\\+") |
183 |
++ get_filename_component(_HIP_CLANG_REAL_PATH "${HIP_CXX_COMPILER}" REALPATH) |
184 |
++ get_filename_component(_HIP_CLANG_BIN_PATH "${_HIP_CLANG_REAL_PATH}" DIRECTORY) |
185 |
++ get_filename_component(HIP_CLANG_ROOT "${_HIP_CLANG_BIN_PATH}" DIRECTORY) |
186 |
++ endif() |
187 |
++ |
188 |
++ |
189 |
++ file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS ${HIP_CLANG_ROOT}/lib/clang/*/include) |
190 |
++ find_path(HIP_CLANG_INCLUDE_PATH stddef.h |
191 |
++ HINTS |
192 |
+ ${HIP_CLANG_INCLUDE_SEARCH_PATHS} |
193 |
+- NO_DEFAULT_PATH) |
194 |
++ NO_DEFAULT_PATH) |
195 |
++ # Since INTERFACE_INCLUDE_DIRECTORIES need to set the parent directory |
196 |
++ # of HIP_CLANG_INCLUDE_PATH incase using find_path() of stddefs.h |
197 |
++ set(HIP_CLANG_INCLUDE_PATH "${HIP_CLANG_INCLUDE_PATH}/..") |
198 |
++ endif() # HIP_CXX_COMPILER Check |
199 |
++ endif() # CLANG_INCLUDE_PATH_FETCH_EXIT_CODE Check |
200 |
++ |
201 |
+ if(NOT WIN32) |
202 |
+ find_dependency(AMDDeviceLibs) |
203 |
+ endif() |
204 |
+ set(AMDGPU_TARGETS "gfx900;gfx906;gfx908;gfx90a;gfx1030" CACHE STRING "AMD GPU targets to compile for") |
205 |
+ set(GPU_TARGETS "${AMDGPU_TARGETS}" CACHE STRING "GPU targets to compile for") |
206 |
+-endif() |
207 |
++endif() # HIP_COMPILER check |
208 |
+ |
209 |
+ if(NOT WIN32) |
210 |
+ find_dependency(amd_comgr) |
211 |
+@@ -263,11 +284,11 @@ if(HIP_COMPILER STREQUAL "clang") |
212 |
+ hip_add_interface_link_flags(hip::device --hip-link) |
213 |
+ |
214 |
+ set_property(TARGET hip::device APPEND PROPERTY |
215 |
+- INTERFACE_INCLUDE_DIRECTORIES "${HIP_CLANG_INCLUDE_PATH}/.." |
216 |
++ INTERFACE_INCLUDE_DIRECTORIES "${HIP_CLANG_INCLUDE_PATH}" |
217 |
+ ) |
218 |
+ |
219 |
+ set_property(TARGET hip::device APPEND PROPERTY |
220 |
+- INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${HIP_CLANG_INCLUDE_PATH}/.." |
221 |
++ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${HIP_CLANG_INCLUDE_PATH}" |
222 |
+ ) |
223 |
+ |
224 |
+ foreach(GPU_TARGET ${GPU_TARGETS}) |
225 |
+@@ -291,25 +312,24 @@ if(HIP_COMPILER STREQUAL "clang") |
226 |
+ endif() |
227 |
+ endif() |
228 |
+ |
229 |
+- file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "${HIP_CLANG_ROOT}/lib/clang/*/lib/*") |
230 |
+- find_library(CLANGRT_BUILTINS |
231 |
+- NAMES |
232 |
+- clang_rt.builtins |
233 |
+- clang_rt.builtins-x86_64 |
234 |
+- PATHS |
235 |
+- ${HIP_CLANGRT_LIB_SEARCH_PATHS} |
236 |
+- ${HIP_CLANG_INCLUDE_PATH}/../lib/linux |
237 |
+- ${HIP_CLANG_INCLUDE_PATH}/../lib/windows |
238 |
+- NO_DEFAULT_PATH) |
239 |
++ |
240 |
++ # Use HIP_CXX option -print-libgcc-file-name --rtlib=compiler-rt |
241 |
++ # To fetch the compiler rt library file name. |
242 |
++ execute_process( |
243 |
++ COMMAND ${HIP_CXX_COMPILER} -print-libgcc-file-name --rtlib=compiler-rt |
244 |
++ OUTPUT_VARIABLE CLANGRT_BUILTINS |
245 |
++ OUTPUT_STRIP_TRAILING_WHITESPACE |
246 |
++ RESULT_VARIABLE CLANGRT_BUILTINS_FETCH_EXIT_CODE) |
247 |
+ |
248 |
+ # Add support for __fp16 and _Float16, explicitly link with compiler-rt |
249 |
+- if(NOT CLANGRT_BUILTINS) |
250 |
+- message(FATAL_ERROR "clangrt builtins lib not found") |
251 |
+- else() |
252 |
++ if( "${CLANGRT_BUILTINS_FETCH_EXIT_CODE}" STREQUAL "0" ) |
253 |
++ # CLANG_RT Builtins found Successfully Set interface link libraries property |
254 |
+ set_property(TARGET hip::host APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${CLANGRT_BUILTINS}") |
255 |
+ set_property(TARGET hip::device APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${CLANGRT_BUILTINS}") |
256 |
+- endif() |
257 |
+-endif() |
258 |
++ else() |
259 |
++ message(STATUS "clangrt builtins lib not found: ${CLANGRT_BUILTINS_FETCH_EXIT_CODE}") |
260 |
++ endif() # CLANGRT_BUILTINS_FETCH_EXIT_CODE Check |
261 |
++endif() # HIP_COMPILER Check |
262 |
+ |
263 |
+ set( hip_LIBRARIES hip::host hip::device) |
264 |
+ set( hip_LIBRARY ${hip_LIBRARIES}) |
265 |
+-- |
266 |
+2.38.1 |
267 |
+ |
268 |
|
269 |
diff --git a/dev-util/hip/files/0002-SWDEV-355608-Remove-clang-include-path-2996.patch b/dev-util/hip/files/0002-SWDEV-355608-Remove-clang-include-path-2996.patch |
270 |
new file mode 100644 |
271 |
index 000000000000..6d64ad8c9fd8 |
272 |
--- /dev/null |
273 |
+++ b/dev-util/hip/files/0002-SWDEV-355608-Remove-clang-include-path-2996.patch |
274 |
@@ -0,0 +1,51 @@ |
275 |
+From 7613e00fe0299d6584d3ee67e5d4010e7fc0866a Mon Sep 17 00:00:00 2001 |
276 |
+From: ROCm CI Service Account <66695075+rocm-ci@××××××××××××××××××××.com> |
277 |
+Date: Fri, 14 Oct 2022 16:02:40 +0530 |
278 |
+Subject: [PATCH 2/3] SWDEV-355608 - Remove clang include path (#2996) |
279 |
+ |
280 |
+Clang doesn't need to be told where to find the clang headers |
281 |
+ |
282 |
+Change-Id: I175781731c43647676d91eedc8a915124f2479ab |
283 |
+Signed-off-by: Yiyang Wu <xgreenlandforwyy@×××××.com> |
284 |
+--- |
285 |
+ bin/hipcc.pl | 11 ----------- |
286 |
+ 1 file changed, 11 deletions(-) |
287 |
+ |
288 |
+diff --git a/bin/hipcc.pl b/bin/hipcc.pl |
289 |
+index 2a01dcc3..7e82cad8 100755 |
290 |
+--- a/bin/hipcc.pl |
291 |
++++ b/bin/hipcc.pl |
292 |
+@@ -162,9 +162,6 @@ if ($HIP_PLATFORM eq "amd") { |
293 |
+ $HIP_CLANG_RT_LIB = `$HIPCC --print-runtime-dir`; |
294 |
+ chomp($HIP_CLANG_RT_LIB); |
295 |
+ |
296 |
+- if (! defined $HIP_CLANG_INCLUDE_PATH) { |
297 |
+- $HIP_CLANG_INCLUDE_PATH = abs_path("$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/include"); |
298 |
+- } |
299 |
+ if (! defined $HIP_INCLUDE_PATH) { |
300 |
+ $HIP_INCLUDE_PATH = "$HIP_PATH/include"; |
301 |
+ } |
302 |
+@@ -177,20 +174,12 @@ if ($HIP_PLATFORM eq "amd") { |
303 |
+ print ("HIP_ROCCLR_HOME=$HIP_ROCCLR_HOME\n"); |
304 |
+ } |
305 |
+ print ("HIP_CLANG_PATH=$HIP_CLANG_PATH\n"); |
306 |
+- print ("HIP_CLANG_INCLUDE_PATH=$HIP_CLANG_INCLUDE_PATH\n"); |
307 |
+ print ("HIP_INCLUDE_PATH=$HIP_INCLUDE_PATH\n"); |
308 |
+ print ("HIP_LIB_PATH=$HIP_LIB_PATH\n"); |
309 |
+ print ("DEVICE_LIB_PATH=$DEVICE_LIB_PATH\n"); |
310 |
+ print ("HIP_CLANG_RT_LIB=$HIP_CLANG_RT_LIB\n"); |
311 |
+ } |
312 |
+ |
313 |
+- if ($isWindows) { |
314 |
+- $HIPCXXFLAGS .= " -std=c++14 -fms-extensions -fms-compatibility"; |
315 |
+- } else { |
316 |
+- $HIPCXXFLAGS .= " -std=c++11"; |
317 |
+- } |
318 |
+- $HIPCXXFLAGS .= " -isystem \"$HIP_CLANG_INCLUDE_PATH/..\""; |
319 |
+- $HIPCFLAGS .= " -isystem \"$HIP_CLANG_INCLUDE_PATH/..\""; |
320 |
+ $HIPLDFLAGS .= " -L\"$HIP_LIB_PATH\""; |
321 |
+ if ($isWindows) { |
322 |
+ $HIPLDFLAGS .= " -lamdhip64"; |
323 |
+-- |
324 |
+2.38.1 |
325 |
+ |
326 |
|
327 |
diff --git a/dev-util/hip/files/0003-SWDEV-352878-Removed-relative-path-based-CLANG-inclu.patch b/dev-util/hip/files/0003-SWDEV-352878-Removed-relative-path-based-CLANG-inclu.patch |
328 |
new file mode 100644 |
329 |
index 000000000000..f92cce4cf8d8 |
330 |
--- /dev/null |
331 |
+++ b/dev-util/hip/files/0003-SWDEV-352878-Removed-relative-path-based-CLANG-inclu.patch |
332 |
@@ -0,0 +1,173 @@ |
333 |
+From fddbcef9a5a45ab63d4805c53d1f8fcf5c30d095 Mon Sep 17 00:00:00 2001 |
334 |
+From: ROCm CI Service Account <66695075+rocm-ci@××××××××××××××××××××.com> |
335 |
+Date: Fri, 6 Jan 2023 02:37:15 +0530 |
336 |
+Subject: [PATCH 3/3] SWDEV-352878 - Removed relative path based CLANG include, |
337 |
+ CLANGRT dependencies (#3124) |
338 |
+ |
339 |
+Change-Id: Ifdcd117679bff548a6351ba915a8272689e647de |
340 |
+Signed-off-by: Yiyang Wu <xgreenlandforwyy@×××××.com> |
341 |
+--- |
342 |
+ cmake/FindHIP.cmake | 37 ++++++++++++++++++++++++++++- |
343 |
+ hip-lang-config.cmake.in | 51 +++++++++++++++++++++------------------- |
344 |
+ 2 files changed, 63 insertions(+), 25 deletions(-) |
345 |
+ |
346 |
+diff --git a/cmake/FindHIP.cmake b/cmake/FindHIP.cmake |
347 |
+index 8b196dea..109c9f65 100644 |
348 |
+--- a/cmake/FindHIP.cmake |
349 |
++++ b/cmake/FindHIP.cmake |
350 |
+@@ -48,6 +48,29 @@ mark_as_advanced(HIP_HOST_COMPILATION_CPP) |
351 |
+ # FIND: HIP and associated helper binaries |
352 |
+ ############################################################################### |
353 |
+ |
354 |
++if(NOT HIP_CXX_COMPILER) |
355 |
++ set(HIP_CXX_COMPILER ${CMAKE_CXX_COMPILER}) |
356 |
++endif() |
357 |
++ |
358 |
++# Approach: To find HIP_CLANG_PATH using HIP_CXX_COMPILER options |
359 |
++# Using --version option of HIP_CXX_COMPILER get the Install Directory |
360 |
++# This install directory is set as the HIP_CLANG_PATH. |
361 |
++# IF not successful in getting the Install Directory using HIP_CXX_COMPILER |
362 |
++# fallback to Old Method to find HIP_CLANG_PATH from ENV Vars, ROCMPATH, HIPPATH etc. |
363 |
++execute_process(COMMAND ${HIP_CXX_COMPILER} --version |
364 |
++ OUTPUT_STRIP_TRAILING_WHITESPACE |
365 |
++ OUTPUT_VARIABLE HIP_CXX_COMPILER_VERSION_OUTPUT) |
366 |
++if(HIP_CXX_COMPILER MATCHES ".*hipcc") |
367 |
++ if(HIP_CXX_COMPILER_VERSION_OUTPUT MATCHES "InstalledDir:[ \t]*([^\n]*)") |
368 |
++ get_filename_component(HIP_CLANG_INSTALL_DIR "${CMAKE_MATCH_1}" DIRECTORY) |
369 |
++ endif() |
370 |
++elseif (HIP_CXX_COMPILER MATCHES ".*clang\\+\\+") |
371 |
++ get_filename_component(_HIP_CLANG_REAL_PATH "${HIP_CXX_COMPILER}" REALPATH) |
372 |
++ get_filename_component(_HIP_CLANG_BIN_PATH "${_HIP_CLANG_REAL_PATH}" DIRECTORY) |
373 |
++ get_filename_component(HIP_CLANG_INSTALL_DIR "${_HIP_CLANG_BIN_PATH}" DIRECTORY) |
374 |
++endif() |
375 |
++ |
376 |
++ |
377 |
+ get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../" REALPATH) |
378 |
+ |
379 |
+ # HIP is currently not supported for apple |
380 |
+@@ -230,6 +253,10 @@ if("${HIP_COMPILER}" STREQUAL "nvcc") |
381 |
+ elseif("${HIP_COMPILER}" STREQUAL "clang") |
382 |
+ #Set HIP_CLANG_PATH |
383 |
+ if("x${HIP_CLANG_PATH}" STREQUAL "x") |
384 |
++ # IF HIP_CLANG_INSTALL_DIR is Found |
385 |
++ if( HIP_CLANG_INSTALL_DIR ) |
386 |
++ set(HIP_CLANG_PATH ${HIP_CLANG_INSTALL_DIR}) |
387 |
++ else() # IF HIP_CLANG_INSTALL_DIR is not found |
388 |
+ if(DEFINED ENV{HIP_CLANG_PATH}) |
389 |
+ set(HIP_CLANG_PATH $ENV{HIP_CLANG_PATH}) |
390 |
+ elseif(DEFINED ENV{ROCM_PATH}) |
391 |
+@@ -252,7 +279,9 @@ elseif("${HIP_COMPILER}" STREQUAL "clang") |
392 |
+ else() |
393 |
+ message(FATAL_ERROR "Unable to find the clang compiler path. Set ROCM_PATH or HIP_PATH in env ") |
394 |
+ endif() |
395 |
+- endif() |
396 |
++ endif() # HIP_CLANG_INSTALL_DIR Check |
397 |
++ endif() # Set HIP_CLANG_PATH |
398 |
++ |
399 |
+ #Number of parallel jobs by default is 1 |
400 |
+ if(NOT DEFINED HIP_CLANG_NUM_PARALLEL_JOBS) |
401 |
+ set(HIP_CLANG_NUM_PARALLEL_JOBS 1) |
402 |
+@@ -660,6 +689,10 @@ macro(HIP_ADD_EXECUTABLE hip_target) |
403 |
+ endif() |
404 |
+ if("${HIP_COMPILER}" STREQUAL "clang") |
405 |
+ if("x${HIP_CLANG_PATH}" STREQUAL "x") |
406 |
++ # IF HIP_CLANG_INSTALL_DIR is Found |
407 |
++ if( HIP_CLANG_INSTALL_DIR ) |
408 |
++ set(HIP_CLANG_PATH ${HIP_CLANG_INSTALL_DIR}) |
409 |
++ else() # IF HIP_CLANG_INSTALL_DIR is not found |
410 |
+ if(DEFINED ENV{HIP_CLANG_PATH}) |
411 |
+ set(HIP_CLANG_PATH $ENV{HIP_CLANG_PATH}) |
412 |
+ elseif(DEFINED ENV{ROCM_PATH}) |
413 |
+@@ -682,7 +715,9 @@ macro(HIP_ADD_EXECUTABLE hip_target) |
414 |
+ else() |
415 |
+ message(FATAL_ERROR "Unable to find the clang compiler path. Set ROCM_PATH or HIP_PATH in env") |
416 |
+ endif() |
417 |
++ endif() # HIP_CLANG_INSTALL_DIR Check |
418 |
+ endif() |
419 |
++ |
420 |
+ set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HIP_CLANG_PATH} ${HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") |
421 |
+ else() |
422 |
+ set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") |
423 |
+diff --git a/hip-lang-config.cmake.in b/hip-lang-config.cmake.in |
424 |
+index 9250a68a..1cf4e40f 100644 |
425 |
+--- a/hip-lang-config.cmake.in |
426 |
++++ b/hip-lang-config.cmake.in |
427 |
+@@ -70,15 +70,6 @@ get_filename_component(_DIR "${CMAKE_CURRENT_LIST_DIR}" REALPATH) |
428 |
+ get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH) |
429 |
+ |
430 |
+ |
431 |
+-#need _IMPORT_PREFIX to be set #FILE_REORG_BACKWARD_COMPATIBILITY |
432 |
+-file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "${_IMPORT_PREFIX}/../llvm/lib/clang/*/include") |
433 |
+-file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG "${_IMPORT_PREFIX}/llvm/lib/clang/*/include") |
434 |
+-find_path(HIP_CLANG_INCLUDE_PATH __clang_cuda_math.h |
435 |
+- HINTS ${HIP_CLANG_INCLUDE_SEARCH_PATHS} |
436 |
+- ${HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG} |
437 |
+- NO_DEFAULT_PATH) |
438 |
+-get_filename_component(HIP_CLANG_INCLUDE_PATH "${HIP_CLANG_INCLUDE_PATH}" DIRECTORY) |
439 |
+- |
440 |
+ #If HIP isnot installed under ROCm, need this to find HSA assuming HSA is under ROCm |
441 |
+ if( DEFINED ENV{ROCM_PATH} ) |
442 |
+ set(ROCM_PATH "$ENV{ROCM_PATH}") |
443 |
+@@ -96,18 +87,10 @@ if (NOT HSA_HEADER) |
444 |
+ message (FATAL_ERROR "HSA header not found! ROCM_PATH environment not set") |
445 |
+ endif() |
446 |
+ |
447 |
+-get_filename_component(HIP_COMPILER_INSTALL_PATH ${CMAKE_HIP_COMPILER} DIRECTORY) |
448 |
+-file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "${HIP_COMPILER_INSTALL_PATH}/../lib/clang/*/lib/*") |
449 |
+-find_library(CLANGRT_BUILTINS |
450 |
+- NAMES |
451 |
+- clang_rt.builtins |
452 |
+- clang_rt.builtins-x86_64 |
453 |
+- PATHS |
454 |
+- ${HIP_CLANGRT_LIB_SEARCH_PATHS} |
455 |
+- ${HIP_CLANG_INCLUDE_PATH}/../lib/linux) |
456 |
++ |
457 |
+ set_target_properties(hip-lang::device PROPERTIES |
458 |
+- INTERFACE_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:HIP>:${_IMPORT_PREFIX}/include;${HIP_CLANG_INCLUDE_PATH}>" |
459 |
+- INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:HIP>:${_IMPORT_PREFIX}/include;${HIP_CLANG_INCLUDE_PATH}>" |
460 |
++ INTERFACE_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:HIP>:${_IMPORT_PREFIX}/include>" |
461 |
++ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:HIP>:${_IMPORT_PREFIX}/include>" |
462 |
+ ) |
463 |
+ |
464 |
+ set_target_properties(hip-lang::amdhip64 PROPERTIES |
465 |
+@@ -133,13 +116,33 @@ set_property(TARGET hip-lang::device APPEND PROPERTY |
466 |
+ INTERFACE_LINK_OPTIONS "$<$<LINK_LANGUAGE:HIP>:--hip-link>" |
467 |
+ ) |
468 |
+ |
469 |
++# Approach: Check CLANGRT LIB support for CMAKE_HIP_COMPILER |
470 |
++# Use CMAKE_HIP_COMPILER option -print-libgcc-file-name --rtlib=compiler-rt |
471 |
++# Note: For Linux add additional option -unwindlib=libgcc also |
472 |
++# To fetch the compiler rt library file name and confirm. |
473 |
++# If unsuccessful in getting clangrt using this option then |
474 |
++# FATAL_ERROR message send since compiler-rt linkage dependency is mandatory. |
475 |
++# If successful then --rtlib=compiler-rt (and -unwindlib=libgcc for non windows) |
476 |
++# added to Target's INTERFACE_LINK_LIBRARIES property |
477 |
++if (NOT WIN32) |
478 |
++ set(CLANGRT_LINUX_OPTION "-unwindlib=libgcc") |
479 |
++endif() |
480 |
++ |
481 |
++execute_process( |
482 |
++ COMMAND ${CMAKE_HIP_COMPILER} -print-libgcc-file-name --rtlib=compiler-rt ${CLANGRT_LINUX_OPTION} |
483 |
++ OUTPUT_VARIABLE CLANGRT_BUILTINS |
484 |
++ OUTPUT_STRIP_TRAILING_WHITESPACE |
485 |
++ RESULT_VARIABLE CLANGRT_BUILTINS_FETCH_EXIT_CODE) |
486 |
++ |
487 |
+ # Add support for __fp16 and _Float16, explicitly link with compiler-rt |
488 |
+-if(NOT CLANGRT_BUILTINS) |
489 |
+- message(FATAL_ERROR "clangrt builtins lib not found") |
490 |
+-else() |
491 |
++if( "${CLANGRT_BUILTINS_FETCH_EXIT_CODE}" STREQUAL "0" ) |
492 |
+ set_property(TARGET hip-lang::device APPEND PROPERTY |
493 |
+- INTERFACE_LINK_LIBRARIES "$<$<LINK_LANGUAGE:HIP>:${CLANGRT_BUILTINS}>" |
494 |
++ INTERFACE_LINK_OPTIONS $<$<LINK_LANGUAGE:HIP>:--rtlib=compiler-rt ${CLANGRT_LINUX_OPTION}> |
495 |
+ ) |
496 |
++else() |
497 |
++ # FATAL_ERROR send if not successfull on compiler-rt linkage dependency |
498 |
++ message(FATAL_ERROR |
499 |
++ "${CMAKE_FIND_PACKAGE_NAME} Error:${CLANGRT_BUILTINS_FETCH_EXIT_CODE} - clangrt builtins lib could not be found.") |
500 |
+ endif() |
501 |
+ |
502 |
+ # Approved by CMake to use this name. This is used so that HIP can |
503 |
+-- |
504 |
+2.38.1 |
505 |
+ |
506 |
|
507 |
diff --git a/dev-util/hip/files/hipvars-5.3.3.pm b/dev-util/hip/files/hipvars-5.3.3.pm |
508 |
new file mode 100644 |
509 |
index 000000000000..fd1403661efb |
510 |
--- /dev/null |
511 |
+++ b/dev-util/hip/files/hipvars-5.3.3.pm |
512 |
@@ -0,0 +1,20 @@ |
513 |
+#!/usr/bin/perl -w |
514 |
+package hipvars; |
515 |
+ |
516 |
+$HIP_BASE_VERSION_MAJOR = "@HIP_BASE_VERSION_MAJOR@"; |
517 |
+$HIP_BASE_VERSION_MINOR = "@HIP_BASE_VERSION_MINOR@"; |
518 |
+ |
519 |
+$isWindows = 0; |
520 |
+$HIP_PATH='/usr'; |
521 |
+$ROCM_PATH='/usr'; |
522 |
+$CUDA_PATH='/opt/cuda'; |
523 |
+$HSA_PATH='/usr'; |
524 |
+$HIP_CLANG_PATH='@CLANG_PATH@'; |
525 |
+$HIP_ROCCLR_HOME=$HIP_PATH; |
526 |
+$HIP_PLATFORM='amd'; |
527 |
+$HIP_COMPILER = "clang"; |
528 |
+$HIP_RUNTIME = "rocclr"; |
529 |
+$HIP_VERSION_MAJOR = $HIP_BASE_VERSION_MAJOR; |
530 |
+$HIP_VERSION_MINOR = $HIP_BASE_VERSION_MINOR; |
531 |
+$HIP_VERSION_PATCH = "@HIP_VERSION_PATCH@"; |
532 |
+$HIP_VERSION="$HIP_VERSION_MAJOR.$HIP_VERSION_MINOR.$HIP_VERSION_PATCH"; |
533 |
|
534 |
diff --git a/dev-util/hip/hip-5.3.3-r2.ebuild b/dev-util/hip/hip-5.3.3-r2.ebuild |
535 |
index 23778ce69cb9..d52892ff9c6f 100644 |
536 |
--- a/dev-util/hip/hip-5.3.3-r2.ebuild |
537 |
+++ b/dev-util/hip/hip-5.3.3-r2.ebuild |
538 |
@@ -47,6 +47,7 @@ PATCHES=( |
539 |
"${FILESDIR}/${PN}-5.0.1-hip_vector_types.patch" |
540 |
"${FILESDIR}/${PN}-5.0.2-set-build-id.patch" |
541 |
"${FILESDIR}/${PN}-5.3.3-remove-cmake-doxygen-commands.patch" |
542 |
+ "${FILESDIR}/0001-SWDEV-352878-LLVM-pkg-search-directly-using-find_dep.patch" |
543 |
) |
544 |
|
545 |
python_check_deps() { |
546 |
@@ -74,7 +75,6 @@ src_prepare() { |
547 |
|
548 |
# correctly find HIP_CLANG_INCLUDE_PATH using cmake |
549 |
local LLVM_PREFIX="$(get_llvm_prefix "${LLVM_MAX_SLOT}")" |
550 |
- local CLANG_RESOURCE_DIR=$("${LLVM_PREFIX}/bin/clang" -print-resource-dir) |
551 |
sed -e "/set(HIP_CLANG_ROOT/s:\"\${ROCM_PATH}/llvm\":${LLVM_PREFIX}:" -i hip-config.cmake.in || die |
552 |
|
553 |
# correct libs and cmake install dir |
554 |
@@ -84,18 +84,18 @@ src_prepare() { |
555 |
-e "/CPACK_RESOURCE_FILE_LICENSE/d" -i packaging/CMakeLists.txt || die |
556 |
|
557 |
pushd ${HIP_S} || die |
558 |
- eapply "${FILESDIR}/${PN}-5.1.3-clang-include-path.patch" |
559 |
eapply "${FILESDIR}/${PN}-5.1.3-rocm-path.patch" |
560 |
eapply "${FILESDIR}/${PN}-5.1.3-fno-stack-protector.patch" |
561 |
+ eapply "${FILESDIR}/0001-SWDEV-344620-hipcc-fails-to-parse-version-of-clang-i.patch" |
562 |
+ eapply "${FILESDIR}/0002-SWDEV-355608-Remove-clang-include-path-2996.patch" |
563 |
+ eapply "${FILESDIR}/0003-SWDEV-352878-Removed-relative-path-based-CLANG-inclu.patch" |
564 |
# Setting HSA_PATH to "/usr" results in setting "-isystem /usr/include" |
565 |
# which makes "stdlib.h" not found when using "#include_next" in header files; |
566 |
sed -e "/FLAGS .= \" -isystem \$HSA_PATH/d" \ |
567 |
-e "/HIP.*FLAGS.*isystem.*HIP_INCLUDE_PATH/d" \ |
568 |
-e "s:\$ENV{'DEVICE_LIB_PATH'}:'${EPREFIX}/usr/lib/amdgcn/bitcode':" \ |
569 |
-e "s:\$ENV{'HIP_LIB_PATH'}:'${EPREFIX}/usr/$(get_libdir)':" \ |
570 |
- -e "/rpath/s,--rpath=[^ ]*,," \ |
571 |
- -e "s,\$HIP_CLANG_PATH/../lib/clang/\$HIP_CLANG_VERSION/,${CLANG_RESOURCE_DIR}/,g" \ |
572 |
- -i bin/hipcc.pl || die |
573 |
+ -e "/rpath/s,--rpath=[^ ]*,," -i bin/hipcc.pl || die |
574 |
|
575 |
# change --hip-device-lib-path to "/usr/lib/amdgcn/bitcode", must align with "dev-libs/rocm-device-libs" |
576 |
sed -e "s:\${AMD_DEVICE_LIBS_PREFIX}/lib:${EPREFIX}/usr/lib/amdgcn/bitcode:" \ |
577 |
@@ -105,15 +105,10 @@ src_prepare() { |
578 |
hprefixify $(grep -rl --exclude-dir=build/ --exclude="hip-config.cmake.in" "/usr" "${S}") |
579 |
hprefixify $(grep -rl --exclude-dir=build/ --exclude="hipcc.pl" "/usr" "${HIP_S}") |
580 |
|
581 |
- cp "$(prefixify_ro "${FILESDIR}"/hipvars-5.1.3.pm)" bin/hipvars.pm || die "failed to replace hipvars.pm" |
582 |
+ cp "$(prefixify_ro "${FILESDIR}"/hipvars-5.3.3.pm)" bin/hipvars.pm || die "failed to replace hipvars.pm" |
583 |
sed -e "s,@HIP_BASE_VERSION_MAJOR@,$(ver_cut 1)," -e "s,@HIP_BASE_VERSION_MINOR@,$(ver_cut 2)," \ |
584 |
-e "s,@HIP_VERSION_PATCH@,$(ver_cut 3)," \ |
585 |
- -e "s,@CLANG_INCLUDE_PATH@,${CLANG_RESOURCE_DIR}/include," \ |
586 |
-e "s,@CLANG_PATH@,${LLVM_PREFIX}/bin," -i bin/hipvars.pm || die |
587 |
- |
588 |
- sed -e "/HIP_CLANG_INCLUDE_SEARCH_PATHS/s,\${_IMPORT_PREFIX}.*/include,${CLANG_RESOURCE_DIR}/include," -i hip-lang-config.cmake.in || die |
589 |
- popd || die |
590 |
- sed -e "/HIP_CLANG_INCLUDE_SEARCH_PATHS/s,\${HIP_CLANG_ROOT}.*/include,${CLANG_RESOURCE_DIR}/include," -i hip-config.cmake.in || die |
591 |
} |
592 |
|
593 |
src_configure() { |