summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYiyang Wu <xgreenlandforwyy@gmail.com>2022-06-15 20:34:43 +0800
committerBenda Xu <heroxbd@gentoo.org>2022-08-06 22:20:28 +0800
commit010c911622d92aa323f97072c2b7b35a0ec79b69 (patch)
treec810afefc8d6d1f71ab018cad2c9928468075013 /dev-libs
parentdev-libs/rocr-runtime: add 5.1.3 (diff)
downloadgentoo-010c911622d92aa323f97072c2b7b35a0ec79b69.tar.gz
gentoo-010c911622d92aa323f97072c2b7b35a0ec79b69.tar.bz2
gentoo-010c911622d92aa323f97072c2b7b35a0ec79b69.zip
dev-libs/rocm-comgr: add 5.1.3
Drop llvm-roc indirect dependency, and fix clang include dir and rocm-path for vanilla clang. rocm-comgr depend on clang. Closes: https://github.com/gentoo/gentoo/pull/26441 Signed-off-by: Yiyang Wu <xgreenlandforwyy@gmail.com> Signed-off-by: Benda Xu <heroxbd@gentoo.org>
Diffstat (limited to 'dev-libs')
-rw-r--r--dev-libs/rocm-comgr/Manifest1
-rw-r--r--dev-libs/rocm-comgr/files/0001-COMGR-changes-needed-for-upstream-llvm.patch66
-rw-r--r--dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-Find-CLANG_RESOURCE_DIR.patch71
-rw-r--r--dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-fix-include.patch12
-rw-r--r--dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-link.patch17
-rw-r--r--dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-rocm-path.patch14
-rw-r--r--dev-libs/rocm-comgr/rocm-comgr-5.1.3.ebuild57
-rw-r--r--dev-libs/rocr-runtime/rocr-runtime-5.1.3.ebuild4
8 files changed, 240 insertions, 2 deletions
diff --git a/dev-libs/rocm-comgr/Manifest b/dev-libs/rocm-comgr/Manifest
index 37fa70a1b490..ec997d659c13 100644
--- a/dev-libs/rocm-comgr/Manifest
+++ b/dev-libs/rocm-comgr/Manifest
@@ -6,3 +6,4 @@ DIST rocm-comgr-4.2.0.tar.gz 101877 BLAKE2B 6796ab4fc7139224af9e26f6adc5ac3ef260
DIST rocm-comgr-4.3.0.tar.gz 106250 BLAKE2B 40a3a69147ae4fc96d3713331d35ae65d952dbf92fb3c92bee75bbef394342b11f383cb51c6def85c256326905c5067b1da816e853f793fd3c40a5af9a6e0122 SHA512 5961720bdc78c6d3fc626bd83f52be0aa32b01178bf4db0a503a0639fe05c5c589b7feb2dcbeb78021d36a40ac6f936cb1262cd5ab5cda4689e8e642ab7eddc3
DIST rocm-comgr-4.5.2.tar.gz 108521 BLAKE2B 9fe238a17bac5739d2d103d859a8dd16cb95d0333f9f85e7fd94463c4ee8bd88801b7b1d1278d978fda7425f391de5e9043a3539583ed3b8d45393a613c19bba SHA512 c466a9bb1b725b79d056673824c6dd79919866f42db88b611e4ac24b0624b12c078affe8bfc7ad7c1373ce0ca60607904c46f13751b47c9f4deaf4105e2c7cd3
DIST rocm-comgr-5.0.2.tar.gz 117092 BLAKE2B 1ffcb74f9716a8f050d722f569cced66e8e9fa5a23a7156edd1b4dfd7dd7b09a175f3555bbf29ef452d7e4371f65ebe4c6fac30c583468a5563dd59fa92b53e4 SHA512 d2cf4517fc1da1adc367aaa6f53cc099547a931be30cc261d68c8174a5a9ffe3af937fbb298987abbdd7fd5d80364bef6ea9112dcaaf326a410fdd215e568f2f
+DIST rocm-comgr-5.1.3.tar.gz 117155 BLAKE2B 40e415c4c7ae3e709dd50981299291f0fc1133f35310b4c86a86847d3bce5fd7685a3f4480f8f156873ca922921c1d4e1cb620fd33bd5cdc87f155af839f2bbe SHA512 5927250f5e03c32b7f270a1dbfe5221d349dfe32aba34143040da53d4e7eb83faa3073a43edabcff13e1fc977bc17088404523f2ab2ea95e207d2c00beb4249b
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
new file mode 100644
index 000000000000..8200d4414f8b
--- /dev/null
+++ b/dev-libs/rocm-comgr/files/0001-COMGR-changes-needed-for-upstream-llvm.patch
@@ -0,0 +1,66 @@
+From be2bcaaea228cdcb5981b261046175275c402fb9 Mon Sep 17 00:00:00 2001
+From: Konstantin Zhuravlyov <kzhuravl_dev@outlook.com>
+Date: Wed, 26 Jan 2022 12:02:52 -0500
+Subject: [PATCH] COMGR changes needed for
+ https://github.com/llvm/llvm-project/commit/83d59e05b201760e3f364ff6316301d347cbad95
+
+Change-Id: Iac01d024463865734879faf5f814e0862c26f7a1
+---
+ lib/comgr/src/comgr-compiler.cpp | 3 ++-
+ lib/comgr/src/comgr-env.h | 1 +
+ lib/comgr/src/comgr-objdump.cpp | 4 +++-
+ 3 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/lib/comgr/src/comgr-compiler.cpp b/lib/comgr/src/comgr-compiler.cpp
+index 6c2cba2..db4c8d5 100644
+--- a/src/comgr-compiler.cpp
++++ b/src/comgr-compiler.cpp
+@@ -605,7 +605,8 @@ static amd_comgr_status_t linkWithLLD(llvm::ArrayRef<const char *> Args,
+ ArrayRef<const char *> ArgRefs = llvm::makeArrayRef(LLDArgs);
+ static std::mutex MScreen;
+ MScreen.lock();
+- bool LLDRet = lld::elf::link(ArgRefs, false, LogS, LogE);
++ bool LLDRet = lld::elf::link(ArgRefs, LogS, LogE, false, false);
++ lld::CommonLinkerContext::destroy();
+ MScreen.unlock();
+ if (!LLDRet) {
+ return AMD_COMGR_STATUS_ERROR;
+diff --git a/lib/comgr/src/comgr-env.h b/lib/comgr/src/comgr-env.h
+index eb13e61..aef57b3 100644
+--- a/src/comgr-env.h
++++ b/src/comgr-env.h
+@@ -36,6 +36,7 @@
+ #ifndef COMGR_ENV_H
+ #define COMGR_ENV_H
+
++#include "llvm/ADT/Optional.h"
+ #include "llvm/ADT/StringRef.h"
+
+ namespace COMGR {
+diff --git a/lib/comgr/src/comgr-objdump.cpp b/lib/comgr/src/comgr-objdump.cpp
+index 094bbac..b41e6c1 100644
+--- a/src/comgr-objdump.cpp
++++ b/src/comgr-objdump.cpp
+@@ -43,6 +43,7 @@
+ #include "llvm/ADT/STLExtras.h"
+ #include "llvm/ADT/StringExtras.h"
+ #include "llvm/ADT/Triple.h"
++#include "llvm/CodeGen/CommandFlags.h"
+ #include "llvm/DebugInfo/DWARF/DWARFContext.h"
+ #include "llvm/DebugInfo/Symbolize/Symbolize.h"
+ #include "llvm/MC/MCAsmInfo.h"
+@@ -2395,9 +2396,10 @@ llvm::DisassemHelper::disassembleAction(StringRef Input,
+ size_t ArgC = ArgV.size();
+ ArgV.push_back(nullptr);
+ COMGR::clearLLVMOptions();
++ llvm::codegen::RegisterCodeGenFlags CGF;
+ cl::ParseCommandLineOptions(ArgC, ArgV.data(), "llvm object file dumper\n",
+ &ErrS);
+- MCPU = lld::getCPUStr();
++ MCPU = llvm::codegen::getCPUStr();
+
+ ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr =
+ MemoryBuffer::getMemBuffer(Input);
+--
+2.35.1
+
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
new file mode 100644
index 000000000000..362f5fcf16ca
--- /dev/null
+++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-Find-CLANG_RESOURCE_DIR.patch
@@ -0,0 +1,71 @@
+From 4c01c63a49af5748a8ee698553aa107803b60362 Mon Sep 17 00:00:00 2001
+From: Yiyang Wu <xgreenlandforwyy@gmail.com>
+Date: Tue, 14 Jun 2022 20:21:22 +0800
+Subject: [PATCH] Find CLANG_RESOURCE_DIR using clang -print-resource-dir
+
+Suggested-By: https://reviews.llvm.org/D49486
+Signed-off-by: Yiyang Wu <xgreenlandforwyy@gmail.com>
+---
+ lib/comgr/cmake/opencl_pch.cmake | 24 +++---------------------
+ 1 file changed, 3 insertions(+), 21 deletions(-)
+
+Index: comgr/cmake/opencl_pch.cmake
+===================================================================
+--- comgr.orig/cmake/opencl_pch.cmake
++++ comgr/cmake/opencl_pch.cmake
+@@ -1,26 +1,8 @@
+ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ find_package(Clang REQUIRED CONFIG)
+-
+- # FIXME: CLANG_CMAKE_DIR seems like the most stable way to find this, but
+- # really there is no way to reliably discover this header.
+- #
+- # We effectively back up to the Clang output directory (for the case of a build
+- # tree) or install prefix (for the case of an installed copy), and then search
+- # for a file named opencl-c.h anywhere below that. We take the first result in
+- # the case where there are multiple (e.g. if there is an installed copy nested
+- # in a build directory). This is a bit imprecise, but it covers cases like MSVC
+- # adding some additional configuration-specific subdirectories to the build
+- # tree but not to an installed copy.
+- file(GLOB_RECURSE OPENCL_C_H_LIST "${CLANG_CMAKE_DIR}/../../../*/opencl-c.h")
+-
+- list(GET OPENCL_C_H_LIST 0 OPENCL_C_H)
+-
+- if (NOT EXISTS "${OPENCL_C_H}" OR IS_DIRECTORY "${OPENCL_C_H}")
+- message(FATAL_ERROR "Unable to locate opencl-c.h from the supplied Clang. The path '${CLANG_CMAKE_DIR}/../../../*' was searched.")
+- endif()
+-else()
+- get_target_property(clang_build_header_dir clang-resource-headers RUNTIME_OUTPUT_DIRECTORY)
+- set(OPENCL_C_H "${clang_build_header_dir}/opencl-c.h")
++ execute_process(COMMAND "${CLANG_INSTALL_PREFIX}/bin/clang" -print-resource-dir OUTPUT_VARIABLE CLANG_RESOURCE_DIR)
++ string(STRIP ${CLANG_RESOURCE_DIR} CLANG_RESOURCE_DIR)
++ set(OPENCL_C_H "${CLANG_RESOURCE_DIR}/include/opencl-c.h")
+ endif()
+
+ # Macro to create and install a custom target for generating PCH for given
+Index: comgr/src/comgr-compiler.cpp
+===================================================================
+--- comgr.orig/src/comgr-compiler.cpp
++++ comgr/src/comgr-compiler.cpp
+@@ -42,6 +42,7 @@
+ #include "lld/Common/Driver.h"
+ #include "clang/Basic/Version.h"
+ #include "clang/CodeGen/CodeGenAction.h"
++#include "clang/Config/config.h"
+ #include "clang/Driver/Compilation.h"
+ #include "clang/Driver/DriverDiagnostic.h"
+ #include "clang/Driver/Job.h"
+@@ -988,11 +989,8 @@ amd_comgr_status_t AMDGPUCompiler::addCo
+ HIPIncludePath = (Twine(env::getHIPPath()) + "/include").str();
+ // HIP headers depend on hsa.h which is in ROCM_DIR/include.
+ ROCMIncludePath = (Twine(env::getROCMPath()) + "/include").str();
+- ClangIncludePath =
+- (Twine(env::getLLVMPath()) + "/lib/clang/" + CLANG_VERSION_STRING).str();
+- ClangIncludePath2 = (Twine(env::getLLVMPath()) + "/lib/clang/" +
+- CLANG_VERSION_STRING + "/include")
+- .str();
++ ClangIncludePath = (Twine(env::getLLVMPath()) + "/bin/" + CLANG_RESOURCE_DIR).str();
++ ClangIncludePath2 = (Twine(env::getLLVMPath()) + "/bin/" + CLANG_RESOURCE_DIR + "/include").str();
+
+ Args.push_back("-x");
+
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
new file mode 100644
index 000000000000..6bf47c610dfc
--- /dev/null
+++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-fix-include.patch
@@ -0,0 +1,12 @@
+Index: comgr/src/comgr-env.h
+===================================================================
+--- comgr.orig/src/comgr-env.h
++++ comgr/src/comgr-env.h
+@@ -37,6 +37,7 @@
+ #define COMGR_ENV_H
+
+ #include "llvm/ADT/StringRef.h"
++#include "llvm/ADT/Optional.h"
+
+ namespace COMGR {
+ namespace env {
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
new file mode 100644
index 000000000000..0e2a9a668216
--- /dev/null
+++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-clang-link.patch
@@ -0,0 +1,17 @@
+Index: comgr/CMakeLists.txt
+===================================================================
+--- comgr.orig/CMakeLists.txt
++++ comgr/CMakeLists.txt
+@@ -283,11 +283,7 @@ install(FILES
+ DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}")
+
+ set(CLANG_LIBS
+- clangFrontendTool
+- clangFrontend
+- clangBasic
+- clangDriver
+- clangSerialization)
++ clang-cpp)
+
+ set(LLD_LIBS
+ lldELF
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
new file mode 100644
index 000000000000..c6d39715e864
--- /dev/null
+++ b/dev-libs/rocm-comgr/files/rocm-comgr-5.1.3-rocm-path.patch
@@ -0,0 +1,14 @@
+Add --rocm-path=/usr argument in runtime because our rocm path is not in default seach list.
+--- comgr/src/comgr-compiler.cpp
++++ comgr.orig/src/comgr-compiler.cpp
+@@ -1096,6 +1096,10 @@
+ }
+ }
+ }
++ else {
++ llvm::SmallString<128> RealRocmDir = env::getLLVMPath();
++ Args.push_back(Saver.save(Twine("--rocm-path=") + RealRocmDir).data());
++ }
+
+ return processFiles(AMD_COMGR_DATA_KIND_BC, ".bc");
+ }
diff --git a/dev-libs/rocm-comgr/rocm-comgr-5.1.3.ebuild b/dev-libs/rocm-comgr/rocm-comgr-5.1.3.ebuild
new file mode 100644
index 000000000000..8f03fe89a883
--- /dev/null
+++ b/dev-libs/rocm-comgr/rocm-comgr-5.1.3.ebuild
@@ -0,0 +1,57 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit cmake llvm prefix
+
+LLVM_MAX_SLOT=14
+
+if [[ ${PV} == *9999 ]] ; then
+ EGIT_REPO_URI="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/"
+ inherit git-r3
+ S="${WORKDIR}/${P}/lib/comgr"
+else
+ SRC_URI="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/archive/rocm-${PV}.tar.gz -> ${P}.tar.gz"
+ S="${WORKDIR}/ROCm-CompilerSupport-rocm-${PV}/lib/comgr"
+ KEYWORDS="~amd64"
+fi
+
+PATCHES=(
+ "${FILESDIR}/${PN}-4.5.2-dependencies.patch"
+ "${FILESDIR}/${PN}-5.1.3-Find-CLANG_RESOURCE_DIR.patch"
+ "${FILESDIR}/${PN}-5.1.3-clang-link.patch"
+ "${FILESDIR}/${PN}-5.1.3-clang-fix-include.patch"
+ "${FILESDIR}/${PN}-5.1.3-rocm-path.patch"
+ "${FILESDIR}/0001-COMGR-changes-needed-for-upstream-llvm.patch"
+)
+
+DESCRIPTION="Radeon Open Compute Code Object Manager"
+HOMEPAGE="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport"
+LICENSE="MIT"
+SLOT="0/$(ver_cut 1-2)"
+
+RDEPEND=">=dev-libs/rocm-device-libs-${PV}
+ sys-devel/clang:${LLVM_MAX_SLOT}=
+ sys-devel/clang-runtime:=
+ sys-devel/lld"
+DEPEND="${RDEPEND}"
+
+CMAKE_BUILD_TYPE=Release
+
+src_prepare() {
+ sed '/sys::path::append(HIPPath/s,"hip","",' -i src/comgr-env.cpp || die
+ sed "/return LLVMPath;/s,LLVMPath,llvm::SmallString<128>(\"$(get_llvm_prefix ${LLVM_MAX_SLOT})\")," -i src/comgr-env.cpp || die
+ sed '/Args.push_back(HIPIncludePath/,+1d' -i src/comgr-compiler.cpp || die
+ sed '/Args.push_back(ROCMIncludePath/,+1d' -i src/comgr-compiler.cpp || die # ROCM and HIPIncludePath is now /usr, which disturb the include order
+ eapply $(prefixify_ro "${FILESDIR}"/${PN}-5.0-rocm_path.patch)
+ cmake_src_prepare
+}
+
+src_configure() {
+ local mycmakeargs=(
+ -DLLVM_DIR="$(get_llvm_prefix ${LLVM_MAX_SLOT})"
+ -DCMAKE_STRIP="" # disable stripping defined at lib/comgr/CMakeLists.txt:58
+ )
+ cmake_src_configure
+}
diff --git a/dev-libs/rocr-runtime/rocr-runtime-5.1.3.ebuild b/dev-libs/rocr-runtime/rocr-runtime-5.1.3.ebuild
index dfd62ed66bd7..51cc36741308 100644
--- a/dev-libs/rocr-runtime/rocr-runtime-5.1.3.ebuild
+++ b/dev-libs/rocr-runtime/rocr-runtime-5.1.3.ebuild
@@ -32,8 +32,8 @@ RDEPEND="${COMMON_DEPEND}"
DEPEND="${COMMON_DEPEND}
>=dev-libs/roct-thunk-interface-${PV}
>=dev-libs/rocm-device-libs-${PV}
- sys-devel/lld
- sys-devel/clang-runtime"
+ sys-devel/clang
+ sys-devel/lld"
BDEPEND="app-editors/vim-core"
# vim-core is needed for "xxd"