1 |
commit: 010c911622d92aa323f97072c2b7b35a0ec79b69 |
2 |
Author: Yiyang Wu <xgreenlandforwyy <AT> gmail <DOT> com> |
3 |
AuthorDate: Wed Jun 15 12:34:43 2022 +0000 |
4 |
Commit: Benda XU <heroxbd <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Aug 6 14:20:28 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=010c9116 |
7 |
|
8 |
dev-libs/rocm-comgr: add 5.1.3 |
9 |
|
10 |
Drop llvm-roc indirect dependency, and fix clang include dir and |
11 |
rocm-path for vanilla clang. rocm-comgr depend on clang. |
12 |
|
13 |
Closes: https://github.com/gentoo/gentoo/pull/26441 |
14 |
Signed-off-by: Yiyang Wu <xgreenlandforwyy <AT> gmail.com> |
15 |
Signed-off-by: Benda Xu <heroxbd <AT> gentoo.org> |
16 |
|
17 |
dev-libs/rocm-comgr/Manifest | 1 + |
18 |
...01-COMGR-changes-needed-for-upstream-llvm.patch | 66 ++++++++++++++++++++ |
19 |
.../rocm-comgr-5.1.3-Find-CLANG_RESOURCE_DIR.patch | 71 ++++++++++++++++++++++ |
20 |
.../files/rocm-comgr-5.1.3-clang-fix-include.patch | 12 ++++ |
21 |
.../files/rocm-comgr-5.1.3-clang-link.patch | 17 ++++++ |
22 |
.../files/rocm-comgr-5.1.3-rocm-path.patch | 14 +++++ |
23 |
dev-libs/rocm-comgr/rocm-comgr-5.1.3.ebuild | 57 +++++++++++++++++ |
24 |
dev-libs/rocr-runtime/rocr-runtime-5.1.3.ebuild | 4 +- |
25 |
8 files changed, 240 insertions(+), 2 deletions(-) |
26 |
|
27 |
diff --git a/dev-libs/rocm-comgr/Manifest b/dev-libs/rocm-comgr/Manifest |
28 |
index 37fa70a1b490..ec997d659c13 100644 |
29 |
--- a/dev-libs/rocm-comgr/Manifest |
30 |
+++ b/dev-libs/rocm-comgr/Manifest |
31 |
@@ -6,3 +6,4 @@ DIST rocm-comgr-4.2.0.tar.gz 101877 BLAKE2B 6796ab4fc7139224af9e26f6adc5ac3ef260 |
32 |
DIST rocm-comgr-4.3.0.tar.gz 106250 BLAKE2B 40a3a69147ae4fc96d3713331d35ae65d952dbf92fb3c92bee75bbef394342b11f383cb51c6def85c256326905c5067b1da816e853f793fd3c40a5af9a6e0122 SHA512 5961720bdc78c6d3fc626bd83f52be0aa32b01178bf4db0a503a0639fe05c5c589b7feb2dcbeb78021d36a40ac6f936cb1262cd5ab5cda4689e8e642ab7eddc3 |
33 |
DIST rocm-comgr-4.5.2.tar.gz 108521 BLAKE2B 9fe238a17bac5739d2d103d859a8dd16cb95d0333f9f85e7fd94463c4ee8bd88801b7b1d1278d978fda7425f391de5e9043a3539583ed3b8d45393a613c19bba SHA512 c466a9bb1b725b79d056673824c6dd79919866f42db88b611e4ac24b0624b12c078affe8bfc7ad7c1373ce0ca60607904c46f13751b47c9f4deaf4105e2c7cd3 |
34 |
DIST rocm-comgr-5.0.2.tar.gz 117092 BLAKE2B 1ffcb74f9716a8f050d722f569cced66e8e9fa5a23a7156edd1b4dfd7dd7b09a175f3555bbf29ef452d7e4371f65ebe4c6fac30c583468a5563dd59fa92b53e4 SHA512 d2cf4517fc1da1adc367aaa6f53cc099547a931be30cc261d68c8174a5a9ffe3af937fbb298987abbdd7fd5d80364bef6ea9112dcaaf326a410fdd215e568f2f |
35 |
+DIST rocm-comgr-5.1.3.tar.gz 117155 BLAKE2B 40e415c4c7ae3e709dd50981299291f0fc1133f35310b4c86a86847d3bce5fd7685a3f4480f8f156873ca922921c1d4e1cb620fd33bd5cdc87f155af839f2bbe SHA512 5927250f5e03c32b7f270a1dbfe5221d349dfe32aba34143040da53d4e7eb83faa3073a43edabcff13e1fc977bc17088404523f2ab2ea95e207d2c00beb4249b |
36 |
|
37 |
diff --git a/dev-libs/rocm-comgr/files/0001-COMGR-changes-needed-for-upstream-llvm.patch b/dev-libs/rocm-comgr/files/0001-COMGR-changes-needed-for-upstream-llvm.patch |
38 |
new file mode 100644 |
39 |
index 000000000000..8200d4414f8b |
40 |
--- /dev/null |
41 |
+++ b/dev-libs/rocm-comgr/files/0001-COMGR-changes-needed-for-upstream-llvm.patch |
42 |
@@ -0,0 +1,66 @@ |
43 |
+From be2bcaaea228cdcb5981b261046175275c402fb9 Mon Sep 17 00:00:00 2001 |
44 |
+From: Konstantin Zhuravlyov <kzhuravl_dev@×××××××.com> |
45 |
+Date: Wed, 26 Jan 2022 12:02:52 -0500 |
46 |
+Subject: [PATCH] COMGR changes needed for |
47 |
+ https://github.com/llvm/llvm-project/commit/83d59e05b201760e3f364ff6316301d347cbad95 |
48 |
+ |
49 |
+Change-Id: Iac01d024463865734879faf5f814e0862c26f7a1 |
50 |
+--- |
51 |
+ lib/comgr/src/comgr-compiler.cpp | 3 ++- |
52 |
+ lib/comgr/src/comgr-env.h | 1 + |
53 |
+ lib/comgr/src/comgr-objdump.cpp | 4 +++- |
54 |
+ 3 files changed, 6 insertions(+), 2 deletions(-) |
55 |
+ |
56 |
+diff --git a/lib/comgr/src/comgr-compiler.cpp b/lib/comgr/src/comgr-compiler.cpp |
57 |
+index 6c2cba2..db4c8d5 100644 |
58 |
+--- a/src/comgr-compiler.cpp |
59 |
++++ b/src/comgr-compiler.cpp |
60 |
+@@ -605,7 +605,8 @@ static amd_comgr_status_t linkWithLLD(llvm::ArrayRef<const char *> Args, |
61 |
+ ArrayRef<const char *> ArgRefs = llvm::makeArrayRef(LLDArgs); |
62 |
+ static std::mutex MScreen; |
63 |
+ MScreen.lock(); |
64 |
+- bool LLDRet = lld::elf::link(ArgRefs, false, LogS, LogE); |
65 |
++ bool LLDRet = lld::elf::link(ArgRefs, LogS, LogE, false, false); |
66 |
++ lld::CommonLinkerContext::destroy(); |
67 |
+ MScreen.unlock(); |
68 |
+ if (!LLDRet) { |
69 |
+ return AMD_COMGR_STATUS_ERROR; |
70 |
+diff --git a/lib/comgr/src/comgr-env.h b/lib/comgr/src/comgr-env.h |
71 |
+index eb13e61..aef57b3 100644 |
72 |
+--- a/src/comgr-env.h |
73 |
++++ b/src/comgr-env.h |
74 |
+@@ -36,6 +36,7 @@ |
75 |
+ #ifndef COMGR_ENV_H |
76 |
+ #define COMGR_ENV_H |
77 |
+ |
78 |
++#include "llvm/ADT/Optional.h" |
79 |
+ #include "llvm/ADT/StringRef.h" |
80 |
+ |
81 |
+ namespace COMGR { |
82 |
+diff --git a/lib/comgr/src/comgr-objdump.cpp b/lib/comgr/src/comgr-objdump.cpp |
83 |
+index 094bbac..b41e6c1 100644 |
84 |
+--- a/src/comgr-objdump.cpp |
85 |
++++ b/src/comgr-objdump.cpp |
86 |
+@@ -43,6 +43,7 @@ |
87 |
+ #include "llvm/ADT/STLExtras.h" |
88 |
+ #include "llvm/ADT/StringExtras.h" |
89 |
+ #include "llvm/ADT/Triple.h" |
90 |
++#include "llvm/CodeGen/CommandFlags.h" |
91 |
+ #include "llvm/DebugInfo/DWARF/DWARFContext.h" |
92 |
+ #include "llvm/DebugInfo/Symbolize/Symbolize.h" |
93 |
+ #include "llvm/MC/MCAsmInfo.h" |
94 |
+@@ -2395,9 +2396,10 @@ llvm::DisassemHelper::disassembleAction(StringRef Input, |
95 |
+ size_t ArgC = ArgV.size(); |
96 |
+ ArgV.push_back(nullptr); |
97 |
+ COMGR::clearLLVMOptions(); |
98 |
++ llvm::codegen::RegisterCodeGenFlags CGF; |
99 |
+ cl::ParseCommandLineOptions(ArgC, ArgV.data(), "llvm object file dumper\n", |
100 |
+ &ErrS); |
101 |
+- MCPU = lld::getCPUStr(); |
102 |
++ MCPU = llvm::codegen::getCPUStr(); |
103 |
+ |
104 |
+ ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr = |
105 |
+ MemoryBuffer::getMemBuffer(Input); |
106 |
+-- |
107 |
+2.35.1 |
108 |
+ |
109 |
|
110 |
diff --git a/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-Find-CLANG_RESOURCE_DIR.patch b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-Find-CLANG_RESOURCE_DIR.patch |
111 |
new file mode 100644 |
112 |
index 000000000000..362f5fcf16ca |
113 |
--- /dev/null |
114 |
+++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-Find-CLANG_RESOURCE_DIR.patch |
115 |
@@ -0,0 +1,71 @@ |
116 |
+From 4c01c63a49af5748a8ee698553aa107803b60362 Mon Sep 17 00:00:00 2001 |
117 |
+From: Yiyang Wu <xgreenlandforwyy@×××××.com> |
118 |
+Date: Tue, 14 Jun 2022 20:21:22 +0800 |
119 |
+Subject: [PATCH] Find CLANG_RESOURCE_DIR using clang -print-resource-dir |
120 |
+ |
121 |
+Suggested-By: https://reviews.llvm.org/D49486 |
122 |
+Signed-off-by: Yiyang Wu <xgreenlandforwyy@×××××.com> |
123 |
+--- |
124 |
+ lib/comgr/cmake/opencl_pch.cmake | 24 +++--------------------- |
125 |
+ 1 file changed, 3 insertions(+), 21 deletions(-) |
126 |
+ |
127 |
+Index: comgr/cmake/opencl_pch.cmake |
128 |
+=================================================================== |
129 |
+--- comgr.orig/cmake/opencl_pch.cmake |
130 |
++++ comgr/cmake/opencl_pch.cmake |
131 |
+@@ -1,26 +1,8 @@ |
132 |
+ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) |
133 |
+ find_package(Clang REQUIRED CONFIG) |
134 |
+- |
135 |
+- # FIXME: CLANG_CMAKE_DIR seems like the most stable way to find this, but |
136 |
+- # really there is no way to reliably discover this header. |
137 |
+- # |
138 |
+- # We effectively back up to the Clang output directory (for the case of a build |
139 |
+- # tree) or install prefix (for the case of an installed copy), and then search |
140 |
+- # for a file named opencl-c.h anywhere below that. We take the first result in |
141 |
+- # the case where there are multiple (e.g. if there is an installed copy nested |
142 |
+- # in a build directory). This is a bit imprecise, but it covers cases like MSVC |
143 |
+- # adding some additional configuration-specific subdirectories to the build |
144 |
+- # tree but not to an installed copy. |
145 |
+- file(GLOB_RECURSE OPENCL_C_H_LIST "${CLANG_CMAKE_DIR}/../../../*/opencl-c.h") |
146 |
+- |
147 |
+- list(GET OPENCL_C_H_LIST 0 OPENCL_C_H) |
148 |
+- |
149 |
+- if (NOT EXISTS "${OPENCL_C_H}" OR IS_DIRECTORY "${OPENCL_C_H}") |
150 |
+- message(FATAL_ERROR "Unable to locate opencl-c.h from the supplied Clang. The path '${CLANG_CMAKE_DIR}/../../../*' was searched.") |
151 |
+- endif() |
152 |
+-else() |
153 |
+- get_target_property(clang_build_header_dir clang-resource-headers RUNTIME_OUTPUT_DIRECTORY) |
154 |
+- set(OPENCL_C_H "${clang_build_header_dir}/opencl-c.h") |
155 |
++ execute_process(COMMAND "${CLANG_INSTALL_PREFIX}/bin/clang" -print-resource-dir OUTPUT_VARIABLE CLANG_RESOURCE_DIR) |
156 |
++ string(STRIP ${CLANG_RESOURCE_DIR} CLANG_RESOURCE_DIR) |
157 |
++ set(OPENCL_C_H "${CLANG_RESOURCE_DIR}/include/opencl-c.h") |
158 |
+ endif() |
159 |
+ |
160 |
+ # Macro to create and install a custom target for generating PCH for given |
161 |
+Index: comgr/src/comgr-compiler.cpp |
162 |
+=================================================================== |
163 |
+--- comgr.orig/src/comgr-compiler.cpp |
164 |
++++ comgr/src/comgr-compiler.cpp |
165 |
+@@ -42,6 +42,7 @@ |
166 |
+ #include "lld/Common/Driver.h" |
167 |
+ #include "clang/Basic/Version.h" |
168 |
+ #include "clang/CodeGen/CodeGenAction.h" |
169 |
++#include "clang/Config/config.h" |
170 |
+ #include "clang/Driver/Compilation.h" |
171 |
+ #include "clang/Driver/DriverDiagnostic.h" |
172 |
+ #include "clang/Driver/Job.h" |
173 |
+@@ -988,11 +989,8 @@ amd_comgr_status_t AMDGPUCompiler::addCo |
174 |
+ HIPIncludePath = (Twine(env::getHIPPath()) + "/include").str(); |
175 |
+ // HIP headers depend on hsa.h which is in ROCM_DIR/include. |
176 |
+ ROCMIncludePath = (Twine(env::getROCMPath()) + "/include").str(); |
177 |
+- ClangIncludePath = |
178 |
+- (Twine(env::getLLVMPath()) + "/lib/clang/" + CLANG_VERSION_STRING).str(); |
179 |
+- ClangIncludePath2 = (Twine(env::getLLVMPath()) + "/lib/clang/" + |
180 |
+- CLANG_VERSION_STRING + "/include") |
181 |
+- .str(); |
182 |
++ ClangIncludePath = (Twine(env::getLLVMPath()) + "/bin/" + CLANG_RESOURCE_DIR).str(); |
183 |
++ ClangIncludePath2 = (Twine(env::getLLVMPath()) + "/bin/" + CLANG_RESOURCE_DIR + "/include").str(); |
184 |
+ |
185 |
+ Args.push_back("-x"); |
186 |
+ |
187 |
|
188 |
diff --git a/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-fix-include.patch b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-fix-include.patch |
189 |
new file mode 100644 |
190 |
index 000000000000..6bf47c610dfc |
191 |
--- /dev/null |
192 |
+++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-fix-include.patch |
193 |
@@ -0,0 +1,12 @@ |
194 |
+Index: comgr/src/comgr-env.h |
195 |
+=================================================================== |
196 |
+--- comgr.orig/src/comgr-env.h |
197 |
++++ comgr/src/comgr-env.h |
198 |
+@@ -37,6 +37,7 @@ |
199 |
+ #define COMGR_ENV_H |
200 |
+ |
201 |
+ #include "llvm/ADT/StringRef.h" |
202 |
++#include "llvm/ADT/Optional.h" |
203 |
+ |
204 |
+ namespace COMGR { |
205 |
+ namespace env { |
206 |
|
207 |
diff --git a/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-link.patch b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-link.patch |
208 |
new file mode 100644 |
209 |
index 000000000000..0e2a9a668216 |
210 |
--- /dev/null |
211 |
+++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-link.patch |
212 |
@@ -0,0 +1,17 @@ |
213 |
+Index: comgr/CMakeLists.txt |
214 |
+=================================================================== |
215 |
+--- comgr.orig/CMakeLists.txt |
216 |
++++ comgr/CMakeLists.txt |
217 |
+@@ -283,11 +283,7 @@ install(FILES |
218 |
+ DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}") |
219 |
+ |
220 |
+ set(CLANG_LIBS |
221 |
+- clangFrontendTool |
222 |
+- clangFrontend |
223 |
+- clangBasic |
224 |
+- clangDriver |
225 |
+- clangSerialization) |
226 |
++ clang-cpp) |
227 |
+ |
228 |
+ set(LLD_LIBS |
229 |
+ lldELF |
230 |
|
231 |
diff --git a/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-rocm-path.patch b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-rocm-path.patch |
232 |
new file mode 100644 |
233 |
index 000000000000..c6d39715e864 |
234 |
--- /dev/null |
235 |
+++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-rocm-path.patch |
236 |
@@ -0,0 +1,14 @@ |
237 |
+Add --rocm-path=/usr argument in runtime because our rocm path is not in default seach list. |
238 |
+--- comgr/src/comgr-compiler.cpp |
239 |
++++ comgr.orig/src/comgr-compiler.cpp |
240 |
+@@ -1096,6 +1096,10 @@ |
241 |
+ } |
242 |
+ } |
243 |
+ } |
244 |
++ else { |
245 |
++ llvm::SmallString<128> RealRocmDir = env::getLLVMPath(); |
246 |
++ Args.push_back(Saver.save(Twine("--rocm-path=") + RealRocmDir).data()); |
247 |
++ } |
248 |
+ |
249 |
+ return processFiles(AMD_COMGR_DATA_KIND_BC, ".bc"); |
250 |
+ } |
251 |
|
252 |
diff --git a/dev-libs/rocm-comgr/rocm-comgr-5.1.3.ebuild b/dev-libs/rocm-comgr/rocm-comgr-5.1.3.ebuild |
253 |
new file mode 100644 |
254 |
index 000000000000..8f03fe89a883 |
255 |
--- /dev/null |
256 |
+++ b/dev-libs/rocm-comgr/rocm-comgr-5.1.3.ebuild |
257 |
@@ -0,0 +1,57 @@ |
258 |
+# Copyright 1999-2022 Gentoo Authors |
259 |
+# Distributed under the terms of the GNU General Public License v2 |
260 |
+ |
261 |
+EAPI=8 |
262 |
+ |
263 |
+inherit cmake llvm prefix |
264 |
+ |
265 |
+LLVM_MAX_SLOT=14 |
266 |
+ |
267 |
+if [[ ${PV} == *9999 ]] ; then |
268 |
+ EGIT_REPO_URI="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/" |
269 |
+ inherit git-r3 |
270 |
+ S="${WORKDIR}/${P}/lib/comgr" |
271 |
+else |
272 |
+ SRC_URI="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/archive/rocm-${PV}.tar.gz -> ${P}.tar.gz" |
273 |
+ S="${WORKDIR}/ROCm-CompilerSupport-rocm-${PV}/lib/comgr" |
274 |
+ KEYWORDS="~amd64" |
275 |
+fi |
276 |
+ |
277 |
+PATCHES=( |
278 |
+ "${FILESDIR}/${PN}-4.5.2-dependencies.patch" |
279 |
+ "${FILESDIR}/${PN}-5.1.3-Find-CLANG_RESOURCE_DIR.patch" |
280 |
+ "${FILESDIR}/${PN}-5.1.3-clang-link.patch" |
281 |
+ "${FILESDIR}/${PN}-5.1.3-clang-fix-include.patch" |
282 |
+ "${FILESDIR}/${PN}-5.1.3-rocm-path.patch" |
283 |
+ "${FILESDIR}/0001-COMGR-changes-needed-for-upstream-llvm.patch" |
284 |
+) |
285 |
+ |
286 |
+DESCRIPTION="Radeon Open Compute Code Object Manager" |
287 |
+HOMEPAGE="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport" |
288 |
+LICENSE="MIT" |
289 |
+SLOT="0/$(ver_cut 1-2)" |
290 |
+ |
291 |
+RDEPEND=">=dev-libs/rocm-device-libs-${PV} |
292 |
+ sys-devel/clang:${LLVM_MAX_SLOT}= |
293 |
+ sys-devel/clang-runtime:= |
294 |
+ sys-devel/lld" |
295 |
+DEPEND="${RDEPEND}" |
296 |
+ |
297 |
+CMAKE_BUILD_TYPE=Release |
298 |
+ |
299 |
+src_prepare() { |
300 |
+ sed '/sys::path::append(HIPPath/s,"hip","",' -i src/comgr-env.cpp || die |
301 |
+ sed "/return LLVMPath;/s,LLVMPath,llvm::SmallString<128>(\"$(get_llvm_prefix ${LLVM_MAX_SLOT})\")," -i src/comgr-env.cpp || die |
302 |
+ sed '/Args.push_back(HIPIncludePath/,+1d' -i src/comgr-compiler.cpp || die |
303 |
+ sed '/Args.push_back(ROCMIncludePath/,+1d' -i src/comgr-compiler.cpp || die # ROCM and HIPIncludePath is now /usr, which disturb the include order |
304 |
+ eapply $(prefixify_ro "${FILESDIR}"/${PN}-5.0-rocm_path.patch) |
305 |
+ cmake_src_prepare |
306 |
+} |
307 |
+ |
308 |
+src_configure() { |
309 |
+ local mycmakeargs=( |
310 |
+ -DLLVM_DIR="$(get_llvm_prefix ${LLVM_MAX_SLOT})" |
311 |
+ -DCMAKE_STRIP="" # disable stripping defined at lib/comgr/CMakeLists.txt:58 |
312 |
+ ) |
313 |
+ cmake_src_configure |
314 |
+} |
315 |
|
316 |
diff --git a/dev-libs/rocr-runtime/rocr-runtime-5.1.3.ebuild b/dev-libs/rocr-runtime/rocr-runtime-5.1.3.ebuild |
317 |
index dfd62ed66bd7..51cc36741308 100644 |
318 |
--- a/dev-libs/rocr-runtime/rocr-runtime-5.1.3.ebuild |
319 |
+++ b/dev-libs/rocr-runtime/rocr-runtime-5.1.3.ebuild |
320 |
@@ -32,8 +32,8 @@ RDEPEND="${COMMON_DEPEND}" |
321 |
DEPEND="${COMMON_DEPEND} |
322 |
>=dev-libs/roct-thunk-interface-${PV} |
323 |
>=dev-libs/rocm-device-libs-${PV} |
324 |
- sys-devel/lld |
325 |
- sys-devel/clang-runtime" |
326 |
+ sys-devel/clang |
327 |
+ sys-devel/lld" |
328 |
BDEPEND="app-editors/vim-core" |
329 |
# vim-core is needed for "xxd" |