Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/rocm-comgr/, dev-libs/rocm-comgr/files/
Date: Thu, 02 Feb 2023 12:54:33
Message-Id: 1675342381.b9205ac0a5a0626397c00ca60a77933377404232.sam@gentoo
1 commit: b9205ac0a5a0626397c00ca60a77933377404232
2 Author: Yiyang Wu <xgreenlandforwyy <AT> gmail <DOT> com>
3 AuthorDate: Wed Jan 25 06:03:18 2023 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Thu Feb 2 12:53:01 2023 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b9205ac0
7
8 dev-libs/rocm-comgr: fix clang include dir search
9
10 With two patches
11
12 1. rocm-comgr uses clang -print-resource-dir to find correct headers
13 during cmake configuration.
14
15 2. comgr initializes the clang driver correctly, so no need to specify
16 clang include dir.
17
18 Also this makes the original sed command invalid. Turn it into another
19 patch.
20
21 Signed-off-by: Yiyang Wu <xgreenlandforwyy <AT> gmail.com>
22 Signed-off-by: Sam James <sam <AT> gentoo.org>
23
24 ...RESOURCE_DIR-using-clang-print-resource-d.patch | 48 ++++++++++++++++++++
25 ...Specify-clang-exe-path-in-Driver-Creation.patch | 52 ++++++++++++++++++++++
26 ...ocm-comgr-5.3.3-HIPIncludePath-not-needed.patch | 15 +++++++
27 ...mgr-5.3.3.ebuild => rocm-comgr-5.3.3-r1.ebuild} | 9 ++--
28 4 files changed, 120 insertions(+), 4 deletions(-)
29
30 diff --git a/dev-libs/rocm-comgr/files/0001-Find-CLANG_RESOURCE_DIR-using-clang-print-resource-d.patch b/dev-libs/rocm-comgr/files/0001-Find-CLANG_RESOURCE_DIR-using-clang-print-resource-d.patch
31 new file mode 100644
32 index 000000000000..a61d92794d51
33 --- /dev/null
34 +++ b/dev-libs/rocm-comgr/files/0001-Find-CLANG_RESOURCE_DIR-using-clang-print-resource-d.patch
35 @@ -0,0 +1,48 @@
36 +From 4c210fdf6943c0c40b5fe0f66800c7b9c7ca84d3 Mon Sep 17 00:00:00 2001
37 +From: Yiyang Wu <xgreenlandforwyy@×××××.com>
38 +Date: Tue, 14 Jun 2022 20:21:22 +0800
39 +Subject: [PATCH] Find CLANG_RESOURCE_DIR using clang -print-resource-dir
40 +
41 +Suggested-By: https://reviews.llvm.org/D49486
42 +Signed-off-by: Yiyang Wu <xgreenlandforwyy@×××××.com>
43 +---
44 + lib/comgr/cmake/opencl_pch.cmake | 24 +++---------------------
45 + 1 file changed, 3 insertions(+), 21 deletions(-)
46 +
47 +diff --git a/lib/comgr/cmake/opencl_pch.cmake b/lib/comgr/cmake/opencl_pch.cmake
48 +index 95311fc..71050c8 100644
49 +--- a/cmake/opencl_pch.cmake
50 ++++ b/cmake/opencl_pch.cmake
51 +@@ -1,26 +1,8 @@
52 + if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
53 + find_package(Clang REQUIRED CONFIG)
54 +-
55 +- # FIXME: CLANG_CMAKE_DIR seems like the most stable way to find this, but
56 +- # really there is no way to reliably discover this header.
57 +- #
58 +- # We effectively back up to the Clang output directory (for the case of a build
59 +- # tree) or install prefix (for the case of an installed copy), and then search
60 +- # for a file named opencl-c.h anywhere below that. We take the first result in
61 +- # the case where there are multiple (e.g. if there is an installed copy nested
62 +- # in a build directory). This is a bit imprecise, but it covers cases like MSVC
63 +- # adding some additional configuration-specific subdirectories to the build
64 +- # tree but not to an installed copy.
65 +- file(GLOB_RECURSE OPENCL_C_H_LIST "${CLANG_CMAKE_DIR}/../../../*/opencl-c.h")
66 +-
67 +- list(GET OPENCL_C_H_LIST 0 OPENCL_C_H)
68 +-
69 +- if (NOT EXISTS "${OPENCL_C_H}" OR IS_DIRECTORY "${OPENCL_C_H}")
70 +- message(FATAL_ERROR "Unable to locate opencl-c.h from the supplied Clang. The path '${CLANG_CMAKE_DIR}/../../../*' was searched.")
71 +- endif()
72 +-else()
73 +- get_target_property(clang_build_header_dir clang-resource-headers RUNTIME_OUTPUT_DIRECTORY)
74 +- set(OPENCL_C_H "${clang_build_header_dir}/opencl-c.h")
75 ++ execute_process(COMMAND "${CLANG_CMAKE_DIR}/../../../bin/clang" -print-resource-dir OUTPUT_VARIABLE CLANG_RESOURCE_DIR)
76 ++ string(STRIP ${CLANG_RESOURCE_DIR} CLANG_RESOURCE_DIR)
77 ++ set(OPENCL_C_H "${CLANG_RESOURCE_DIR}/include/opencl-c.h")
78 + endif()
79 +
80 + # Macro to create and install a custom target for generating PCH for given
81 +--
82 +2.39.0
83 +
84
85 diff --git a/dev-libs/rocm-comgr/files/0001-Specify-clang-exe-path-in-Driver-Creation.patch b/dev-libs/rocm-comgr/files/0001-Specify-clang-exe-path-in-Driver-Creation.patch
86 new file mode 100644
87 index 000000000000..a1ce8cae50b8
88 --- /dev/null
89 +++ b/dev-libs/rocm-comgr/files/0001-Specify-clang-exe-path-in-Driver-Creation.patch
90 @@ -0,0 +1,52 @@
91 +From e0fb8aca856eb61d2f774a0893e2243742eed341 Mon Sep 17 00:00:00 2001
92 +From: Yiyang Wu <xgreenlandforwyy@×××××.com>
93 +Date: Fri, 18 Nov 2022 15:41:53 +0800
94 +Subject: [PATCH] Specify clang exe path in Driver Creation
95 +
96 +By doing so, TheDriver can get the correct resource dir.
97 +
98 +Closes: #48
99 +Reference: #49
100 +---
101 + lib/comgr/src/comgr-compiler.cpp | 11 +----------
102 + 1 file changed, 1 insertion(+), 10 deletions(-)
103 +
104 +diff --git a/lib/comgr/src/comgr-compiler.cpp b/lib/comgr/src/comgr-compiler.cpp
105 +index 80849d4..67fe82b 100644
106 +--- a/src/comgr-compiler.cpp
107 ++++ b/src/comgr-compiler.cpp
108 +@@ -660,7 +660,7 @@ AMDGPUCompiler::executeInProcessDriver(ArrayRef<const char *> Args) {
109 + IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs);
110 + DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagClient);
111 + ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false);
112 +- Driver TheDriver("", "", Diags);
113 ++ Driver TheDriver((Twine(env::getLLVMPath()) + "/bin/clang").str(), "", Diags);
114 + TheDriver.setTitle("AMDGPU Code Object Manager");
115 + TheDriver.setCheckInputsExist(false);
116 +
117 +@@ -998,11 +998,6 @@ amd_comgr_status_t AMDGPUCompiler::addCompilationFlags() {
118 + HIPIncludePath = (Twine(env::getHIPPath()) + "/include").str();
119 + // HIP headers depend on hsa.h which is in ROCM_DIR/include.
120 + ROCMIncludePath = (Twine(env::getROCMPath()) + "/include").str();
121 +- ClangIncludePath =
122 +- (Twine(env::getLLVMPath()) + "/lib/clang/" + CLANG_VERSION_STRING).str();
123 +- ClangIncludePath2 = (Twine(env::getLLVMPath()) + "/lib/clang/" +
124 +- CLANG_VERSION_STRING + "/include")
125 +- .str();
126 +
127 + Args.push_back("-x");
128 +
129 +@@ -1028,10 +1023,6 @@ amd_comgr_status_t AMDGPUCompiler::addCompilationFlags() {
130 + Args.push_back(ROCMIncludePath.c_str());
131 + Args.push_back("-isystem");
132 + Args.push_back(HIPIncludePath.c_str());
133 +- Args.push_back("-isystem");
134 +- Args.push_back(ClangIncludePath.c_str());
135 +- Args.push_back("-isystem");
136 +- Args.push_back(ClangIncludePath2.c_str());
137 + break;
138 + default:
139 + return AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT;
140 +--
141 +2.39.0
142 +
143
144 diff --git a/dev-libs/rocm-comgr/files/rocm-comgr-5.3.3-HIPIncludePath-not-needed.patch b/dev-libs/rocm-comgr/files/rocm-comgr-5.3.3-HIPIncludePath-not-needed.patch
145 new file mode 100644
146 index 000000000000..54b98726026f
147 --- /dev/null
148 +++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.3.3-HIPIncludePath-not-needed.patch
149 @@ -0,0 +1,15 @@
150 +ROCM and HIPIncludePath is now /usr, which disturb the include order
151 +===================================================================
152 +--- comgr.orig/src/comgr-compiler.cpp
153 ++++ comgr/src/comgr-compiler.cpp
154 +@@ -1010,10 +1010,6 @@ amd_comgr_status_t AMDGPUCompiler::addCo
155 + Args.push_back("x86_64-unknown-linux-gnu");
156 + Args.push_back("--cuda-device-only");
157 + Args.push_back("-nogpulib");
158 +- Args.push_back("-isystem");
159 +- Args.push_back(ROCMIncludePath.c_str());
160 +- Args.push_back("-isystem");
161 +- Args.push_back(HIPIncludePath.c_str());
162 + break;
163 + default:
164 + return AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT;
165
166 diff --git a/dev-libs/rocm-comgr/rocm-comgr-5.3.3.ebuild b/dev-libs/rocm-comgr/rocm-comgr-5.3.3-r1.ebuild
167 similarity index 82%
168 rename from dev-libs/rocm-comgr/rocm-comgr-5.3.3.ebuild
169 rename to dev-libs/rocm-comgr/rocm-comgr-5.3.3-r1.ebuild
170 index 5a5aa22a9098..0215adeaba17 100644
171 --- a/dev-libs/rocm-comgr/rocm-comgr-5.3.3.ebuild
172 +++ b/dev-libs/rocm-comgr/rocm-comgr-5.3.3-r1.ebuild
173 @@ -1,4 +1,4 @@
174 -# Copyright 1999-2022 Gentoo Authors
175 +# Copyright 1999-2023 Gentoo Authors
176 # Distributed under the terms of the GNU General Public License v2
177
178 EAPI=8
179 @@ -18,10 +18,12 @@ else
180 fi
181
182 PATCHES=(
183 - "${FILESDIR}/${PN}-5.1.3-Find-CLANG_RESOURCE_DIR.patch"
184 "${FILESDIR}/${PN}-5.1.3-clang-fix-include.patch"
185 "${FILESDIR}/${PN}-5.1.3-rocm-path.patch"
186 "${FILESDIR}/${PN}-5.1.3-llvm-15-remove-zlib-gnu"
187 + "${FILESDIR}/0001-Specify-clang-exe-path-in-Driver-Creation.patch"
188 + "${FILESDIR}/0001-Find-CLANG_RESOURCE_DIR-using-clang-print-resource-d.patch"
189 + "${FILESDIR}/${PN}-5.3.3-HIPIncludePath-not-needed.patch"
190 )
191
192 DESCRIPTION="Radeon Open Compute Code Object Manager"
193 @@ -40,8 +42,6 @@ CMAKE_BUILD_TYPE=Release
194 src_prepare() {
195 sed '/sys::path::append(HIPPath/s,"hip","",' -i src/comgr-env.cpp || die
196 sed "/return LLVMPath;/s,LLVMPath,llvm::SmallString<128>(\"$(get_llvm_prefix ${LLVM_MAX_SLOT})\")," -i src/comgr-env.cpp || die
197 - sed '/Args.push_back(HIPIncludePath/,+1d' -i src/comgr-compiler.cpp || die
198 - sed '/Args.push_back(ROCMIncludePath/,+1d' -i src/comgr-compiler.cpp || die # ROCM and HIPIncludePath is now /usr, which disturb the include order
199 eapply $(prefixify_ro "${FILESDIR}"/${PN}-5.0-rocm_path.patch)
200 cmake_src_prepare
201 }
202 @@ -50,6 +50,7 @@ src_configure() {
203 local mycmakeargs=(
204 -DLLVM_DIR="$(get_llvm_prefix ${LLVM_MAX_SLOT})"
205 -DCMAKE_STRIP="" # disable stripping defined at lib/comgr/CMakeLists.txt:58
206 + -DBUILD_TESTING=$(usex test ON OFF)
207 )
208 cmake_src_configure
209 }