Skip to content

Commit

Permalink
dev-libs/rocm-comgr: drop 6.0.0, cleanup in 6.1.1 patches
Browse files Browse the repository at this point in the history
* fix hip compiler on musl profile
* fix tests
* make 6.1.1 compatible with LLVM 18

Signed-off-by: Sv. Lockal <[email protected]>
  • Loading branch information
AngryLoki committed Jun 11, 2024
1 parent 08f671c commit dc52d05
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 189 deletions.
1 change: 0 additions & 1 deletion dev-libs/rocm-comgr/Manifest
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ DIST rocm-comgr-5.3.3.tar.gz 120414 BLAKE2B 29b9d466d74ef94165a2b9bea35eac4616f6
DIST rocm-comgr-5.4.3.tar.gz 120461 BLAKE2B c4eb79dd5a72a2b18e16841fc8cb9a3a33efb0c7b04a7585df9672d682bba6fa826ab8b37dba5febca3b8c5ee5aca30d8546e1fa69e77671e5c750e2a8c1f12f SHA512 1a25af99a0166d70ca6dc5df5a667068eaf583dccd74bbb18a2a5de3c1b769e0c1eb9a0c539e0cd88bc50bbbe53214a1d1b23fbdfd6fc5b6507c44da259815c4
DIST rocm-comgr-5.5.1.tar.gz 127475 BLAKE2B dbcb6729b27c0b4a4be37f5e462d96b10c15a6a3b540a81a74a648fc45dc727ea5706db1a0f4583a31ac4cb5c9f0d9f4e258fa5ac792b327f4cb1dfe6d585937 SHA512 09174ef2ad21f62b197e439bb5b04a365233c360c57cc2ccf0ea3d53edfa8880dff4f127c6d6c1d430b63b6f7ea666705b14cadc2bccb89c0fefed943b0cf1c7
DIST rocm-comgr-5.7.1.tar.gz 137923 BLAKE2B e215f51137fd0c4b67e85496bf289dc0afde6ebc9efb9416f5fc4cf312b2be9be26da35cb70965bf4857a0f1434d750bcc03ce83095173098487ef7805948735 SHA512 cdd2609b858d9503c30122a2d328d36baa8a930a05bcb6c38e30723909c492b4d47eaaf4884dbb7aa82053e7cda6c22ee1aa16fc5ba266e272d98ff772c5079d
DIST rocm-comgr-6.0.0.tar.gz 142129 BLAKE2B 65d00a79ead48872e3b94e5239a07c476288c611aa3ce2311a345bec5f7d277dc67910fa5f4ef000a5e94e6bed148baa4b1c7fe2b1cfaae2cc39555d716668d5 SHA512 877d2042bdafa6b503ee8f24d3a9c4ac9e001a7884211df47b2237d8a5ead66ced0f352c7b76d96190cd407461f5434fb1a5a4508067e432eb93c0f2fd066053
22 changes: 0 additions & 22 deletions dev-libs/rocm-comgr/files/rocm-comgr-6.0.0-llvm-18-compat.patch

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Remove HIP/ROCM includes ("-isystem /usr/include"), as they break inclusion of <math.h>.
Add inclusion of Clang resource dir (e.g. /usr/lib/clang/17), as it is used in hip runtime like that.
Issue: https://github.com/ROCm/clr/issues/82
Remove hardcoded target to fix HIP on musl.

Issues:
* https://github.com/ROCm/clr/issues/82
* https://github.com/ROCm/llvm-project/issues/92
--- a/src/comgr-compiler.cpp
+++ b/src/comgr-compiler.cpp
@@ -1028,9 +1028,8 @@ AMDGPUCompiler::addTargetIdentifierFlags(llvm::StringRef IdentStr,
Expand All @@ -15,8 +19,12 @@ Issue: https://github.com/ROCm/clr/issues/82

Args.push_back("-x");

@@ -1055,9 +1054,7 @@ amd_comgr_status_t AMDGPUCompiler::addCompilationFlags() {
Args.push_back("x86_64-unknown-linux-gnu");
@@ -1051,13 +1050,9 @@ amd_comgr_status_t AMDGPUCompiler::addCompilationFlags() {
case AMD_COMGR_LANGUAGE_HIP:
Args.push_back("hip");
Args.push_back("-std=c++11");
- Args.push_back("-target");
- Args.push_back("x86_64-unknown-linux-gnu");
Args.push_back("--cuda-device-only");
Args.push_back("-isystem");
- Args.push_back(ROCMIncludePath.c_str());
Expand Down
79 changes: 79 additions & 0 deletions dev-libs/rocm-comgr/files/rocm-comgr-6.1.0-llvm-18-compat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
ROCm 6.0.0 and 6.0.2 releases use mix between LLVM 17 and 18
forked as https://github.com/RadeonOpenCompute/llvm-project
which makes some libraries compatible with LLVM 17,
while other require LLVM 18.

Backports:
* https://github.com/ROCm/llvm-project/commit/6cbc4dc91dfeb1cf2295cb350866e0b3a07dfee4
* https://github.com/ROCm/llvm-project/commit/179ec2e67bf882c6bccb27f81db3d80f7eb9946e
* https://github.com/ROCm/llvm-project/commit/ee123c3d1706bc4346511b1a9032020782576350
--- a/src/comgr-compiler.cpp
+++ b/src/comgr-compiler.cpp
@@ -205,7 +205,11 @@ bool AssemblerInvocation::createFromArgs(AssemblerInvocation &Opts,
// Parse the arguments.
const OptTable &OptTbl = getDriverOptTable();

+#if LLVM_VERSION_MAJOR == 17
const unsigned IncludedFlagsBitmask = options::CC1AsOption;
+#else
+ llvm::opt::Visibility IncludedFlagsBitmask(options::CC1AsOption);
+#endif
unsigned MissingArgIndex, MissingArgCount;
InputArgList Args = OptTbl.ParseArgs(Argv, MissingArgIndex, MissingArgCount,
IncludedFlagsBitmask);
@@ -1041,11 +1045,15 @@ amd_comgr_status_t AMDGPUCompiler::addCompilationFlags() {
Args.push_back("cl");
Args.push_back("-std=cl1.2");
Args.push_back("-cl-no-stdinc");
+ Args.push_back("-mllvm");
+ Args.push_back("-amdgpu-internalize-symbols");
break;
case AMD_COMGR_LANGUAGE_OPENCL_2_0:
Args.push_back("cl");
Args.push_back("-std=cl2.0");
Args.push_back("-cl-no-stdinc");
+ Args.push_back("-mllvm");
+ Args.push_back("-amdgpu-internalize-symbols");
break;
case AMD_COMGR_LANGUAGE_HIP:
Args.push_back("hip");
@@ -1605,6 +1613,9 @@ amd_comgr_status_t AMDGPUCompiler::assembleToRelocatable() {
Args.push_back("-x");
Args.push_back("assembler");

+ // -nogpulib option not needed for assembling to relocatable
+ NoGpuLib = false;
+
return processFiles(AMD_COMGR_DATA_KIND_RELOCATABLE, ".o");
}

--- a/src/comgr-metadata.cpp
+++ b/src/comgr-metadata.cpp
@@ -1087,7 +1087,12 @@ amd_comgr_status_t lookUpCodeObject(DataObject *DataP,
}

BinaryStreamReader Reader(StringRef(DataP->Data, DataP->Size),
- support::little);
+#if LLVM_VERSION_MAJOR == 17
+ support::little
+#else
+ llvm::endianness::little
+#endif
+ );

StringRef Magic;
if (auto EC = Reader.readFixedString(Magic, OffloadBundleMagicLen)) {
--- a/test/compile_log_remarks_test.c
+++ b/test/compile_log_remarks_test.c
@@ -107,7 +107,11 @@ int main(int argc, char *argv[]) {
AMD_COMGR_DATA_KIND_SOURCE, 1);

checkLogs("AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY", DataSetAsm,
+#if LLVM_VERSION_MAJOR == 17
"remark: <unknown>:0:0: 8 stack bytes in function "
+#else
+ "remark: <unknown>:0:0: 8 stack bytes in function 'f' "
+#endif
"[-Rpass-analysis=prologepilog]");

Status = amd_comgr_destroy_data_set(DataSetCl);
68 changes: 0 additions & 68 deletions dev-libs/rocm-comgr/rocm-comgr-6.0.0-r1.ebuild

This file was deleted.

29 changes: 10 additions & 19 deletions dev-libs/rocm-comgr/rocm-comgr-6.1.1.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ inherit cmake llvm-r1 prefix
MY_P=llvm-project-rocm-${PV}
components=( "amd/comgr" )

if [[ ${PV} == *9999 ]] ; then
EGIT_REPO_URI="https://github.com/ROCm/llvm-project"
inherit git-r3
S="${WORKDIR}/${P}/${components[0]}"
else
SRC_URI="https://github.com/ROCm/llvm-project/archive/rocm-${PV}.tar.gz -> ${MY_P}.tar.gz"
S="${WORKDIR}/${MY_P}/${components[0]}"
KEYWORDS="~amd64"
fi
DESCRIPTION="Radeon Open Compute Code Object Manager"
HOMEPAGE="https://github.com/ROCm/ROCm-CompilerSupport"
SRC_URI="https://github.com/ROCm/llvm-project/archive/rocm-${PV}.tar.gz -> ${MY_P}.tar.gz"
S="${WORKDIR}/${MY_P}/${components[0]}"

LICENSE="MIT"
SLOT="0/$(ver_cut 1-2)"
KEYWORDS="~amd64"

IUSE="test"
RESTRICT="!test? ( test )"
Expand All @@ -28,27 +27,19 @@ PATCHES=(
"${FILESDIR}/0001-Find-CLANG_RESOURCE_DIR-using-clang-print-resource-d.patch"
"${FILESDIR}/${PN}-5.7.1-correct-license-install-dir.patch"
"${FILESDIR}/${PN}-6.0.0-extend-isa-compatibility-check.patch"
"${FILESDIR}/${PN}-6.0.0-llvm-18-compat.patch"
"${FILESDIR}/${PN}-6.1.0-llvm-18-compat.patch"
"${FILESDIR}/${PN}-6.1.0-enforce-oop-compiler.patch"
"${FILESDIR}/${PN}-6.1.0-fix-comgr-default-flags.patch"
"${FILESDIR}/${PN}-6.1.0-clang18-option-use-visibility.patch"
"${FILESDIR}/${PN}-6.1.0-clang18-code-object-v5.patch"
"${FILESDIR}/${PN}-6.1.0-clang18-log_remarks_test.patch"
"${FILESDIR}/${PN}-6.1.0-dont-add-nogpulib.patch"
)

DESCRIPTION="Radeon Open Compute Code Object Manager"
HOMEPAGE="https://github.com/ROCm/ROCm-CompilerSupport"
LICENSE="MIT"
SLOT="0/$(ver_cut 1-2)"

RDEPEND=">=dev-libs/rocm-device-libs-${PV}
sys-devel/clang-runtime:=
$(llvm_gen_dep '
sys-devel/clang:${LLVM_SLOT}=
sys-devel/lld:${LLVM_SLOT}=
')
dev-util/hipcc
dev-util/hipcc:${SLOT}
"
DEPEND="${RDEPEND}"

Expand Down

0 comments on commit dc52d05

Please sign in to comment.