summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYiyang Wu <xgreenlandforwyy@gmail.com>2022-06-15 20:42:07 +0800
committerBenda Xu <heroxbd@gentoo.org>2022-08-06 22:22:03 +0800
commit82a6c2ca05ccf2dad8cbd75a813d6deafe4f105f (patch)
treeb0191fecd03e91146710d6be86041ddcf54e4953 /dev-util/hip
parentdev-libs/rocm-comgr: add 5.1.3 (diff)
downloadgentoo-82a6c2ca05ccf2dad8cbd75a813d6deafe4f105f.tar.gz
gentoo-82a6c2ca05ccf2dad8cbd75a813d6deafe4f105f.tar.bz2
gentoo-82a6c2ca05ccf2dad8cbd75a813d6deafe4f105f.zip
dev-util/hip: add 5.1.3
Switch from llvm-roc to vanilla clang -- New variables about clang path in hipvars.pm hip-5.1.3-clang-include-path.patch to fix hipcc finding clang hip-5.1.3-rocm-path.patch: add compile flag to support unpatched clang Using sed cmd to fix clang header location in cmake Closes: https://bugs.gentoo.org/851702 Reference: https://github.com/ROCm-Developer-Tools/hipamd/issues/18 Reference: https://github.com/ROCm-Developer-Tools/hipamd/issues/27 Signed-off-by: Yiyang Wu <xgreenlandforwyy@gmail.com> Signed-off-by: Benda Xu <heroxbd@gentoo.org>
Diffstat (limited to 'dev-util/hip')
-rw-r--r--dev-util/hip/Manifest6
-rw-r--r--dev-util/hip/files/0001-SWDEV-316128-HIP-surface-API-support.patch35
-rw-r--r--dev-util/hip/files/hip-5.1.3-clang-include-path.patch12
-rw-r--r--dev-util/hip/files/hip-5.1.3-fix-hip_prof_gen.patch38
-rw-r--r--dev-util/hip/files/hip-5.1.3-rocm-path.patch13
-rw-r--r--dev-util/hip/files/hipvars-5.1.3.pm21
-rw-r--r--dev-util/hip/hip-5.1.3.ebuild161
7 files changed, 286 insertions, 0 deletions
diff --git a/dev-util/hip/Manifest b/dev-util/hip/Manifest
index a5655c73e1a..de73421d0c0 100644
--- a/dev-util/hip/Manifest
+++ b/dev-util/hip/Manifest
@@ -1,11 +1,17 @@
DIST 5.0.2-update-header.patch.gz 5136 BLAKE2B 290b9e250e3004a1147ad28606d7d205078affbd809c6a429744767ebabf35bd8df6395dc135984d345ae2f23fa457dcb2524bcbf31c5bf16903d3ee2007bf5d SHA512 41b1025c403e874026a712ec6f6571c873203b08ddadf68848f6d1f63924c21b206677b330f79edad2c4b85e2ba5053b1d33f70c7c09ff9c17bc5905b849da0c
+DIST hip-5.1.3-update-header.patch.gz 3406 BLAKE2B 805539c3396a9cdcc4b807afd96eacd2de0e494a9ec927a1526cb8ce26b1c6e0a4d06415cd0210cba1398b5ff70f995fa67ad22b659578c075eb24c2a2cc9228 SHA512 eef4d70f9470a61d1d8cb140728cc4f2e792a4e64e0900a7410a74f3a6421410e7546e4e62bbbf35ae231b566bf162fb85de1f1ad1d8cfb2f282d2ed9a34b53a
DIST rocclr-5.0.2.tar.gz 853965 BLAKE2B a0d568eb3b230845970d8256a5a2f32018e4b9fb68e0f1aa13a1f3fc953e614025315b90cbe68c107f7150cf91b4b1ea438455429062c7dc06ef77d65dedd2ec SHA512 b30a57c09973d8ef624511f422babaf9722685b9f85643783aebc000671b41fd54f44b308cece0baab187e1ee00b10335c6d22b6bad6fb3468abe6ef0da97d73
+DIST rocclr-5.1.3.tar.gz 618606 BLAKE2B 02b7732ddd03c0883bee49c56466cd21c649159f801bfb2537eea6e640c65613eb57b37d942f465a9deb83d65735f51212dde5e4f77ba8239d1a6b7037e1800c SHA512 89fd2eca39ed84a1cf525b2c606089ef39f64c1f997c4880e10722da6de4864110752640e1508db1aeb9d15c48ba4e6fe5dbe7a9e56718853ece42548028b2ca
DIST rocm-hip-4.0.0.tar.gz 1012154 BLAKE2B 02343239a5b27c42dafd241f2c9b6f5195c50f78bfd717ae72bcb16d384bd6cf97ff6f2b86bfcf323aaaf022d6897f46d0987826c80d6f6279be4cb4792e15be SHA512 cf840dbe28a9a15e3be14351bfa22d3c81e1654813a7aee55f53e71b2ee183f8dd0de14a79791617fabb5b357cadbf2ce2f476f78884b2843d30f206d65088f6
DIST rocm-hip-4.1.0.tar.gz 954215 BLAKE2B c4b75ab2158e6921be1c34820ab5d1a5e2eb36112834b0143c50023caa27de384e0497f4837947cc7fe05554c6c95201340b1979eb916b31ebb4ffec8c923735 SHA512 420ffd7b79e2b4506873cbfc56e96395f8ed9d9375ce28df51626601199d4d8dca6920528e255d39a48ad66ee11f4b653f3b9f659df489d32b21886fb86c64b5
DIST rocm-hip-4.2.0.tar.gz 918281 BLAKE2B 45c28289c8ff9e600bfd9daff8af162c897fcfdf41ce65d91d1761d58253d87a6385fd4a15e818619ca39d3413479bf043ab2758fead349a243105e979b64f7c SHA512 e620507321c949ded2eab6159099eef0eab267eb686b6ee0ed86022fffaa51fb8714a7f344b79acf76c876c55919360905d1bb3a7c00a87f40174774d6682ce8
DIST rocm-hip-4.3.0.tar.gz 967550 BLAKE2B 263e8bbaa86198d3cb6a29f5597b56a3fe1e9338a8c485935070e6253816ccdba9671f33d8142c260aa3c36f43a71de7f2c1b7a15e1227f97aaf03ed10ce10dd SHA512 bc2d9597200405397387cc8f626f0cc734ee450c462bd7c7a0c655e3dfe2d1e09780328cbfa1c0d1e0db836e561fc450c5d514a6ad1a5828cb913c4c3c535ef1
DIST rocm-hip-5.0.2.tar.gz 958496 BLAKE2B 9c8bb1eacd982203e3bd6c24560672c4a9aaf5606608635d7da5a60f613d9be50998f990c1ea3e0e6f5581e0efcba09af736a77bbc9469b2898e0974d063e8d6 SHA512 4a99e86a4594c15509a1bbfec0678cd05469eb14dcf35ce650e1eb7c2415f57f59071b1b8add2f8566ccf06242bead77abd275987fe79fe6031dea90d5693805
+DIST rocm-hip-5.1.3.tar.gz 967696 BLAKE2B 15cb52b5934b84acf515fe9c83b7c8982e00a23e20af933bdd2c4bc5b56fd42b08c8a08e840c85d2e0a8386d5a0e9c110504f68499989de1aaad00e9a5efcf43 SHA512 6b6fd6c12d73788df1711b12326b97fc7a184f319e0db114947b7967b75f2ee131f81e42e43a4981456b507221a6013133731120409f90214e13304299ccbc24
DIST rocm-hipamd-5.0.2.tar.gz 319973 BLAKE2B ca19938eeca66f0d2614ff933e1d0e75b6b8dbc8d996fd4369e5649897b9948271ac88f2a66f0a40ef586d6185b30d01132decac95d1615c1ee419996050ed07 SHA512 056acab082b5073e81f9e5de00ae12c85021d1c297cdcfc45b85f191dcc68603f64fe5d0e75f9523120657947eb125beaa9c3ce26234968c43b200e638f9afa3
+DIST rocm-hipamd-5.1.3.tar.gz 331996 BLAKE2B 176121fe199d53c02a0fc407015681c2f08c8a72104738b457581fd81b37d16efb8170a46d687fb85a45242ba8564246cdd5746e78d9b73dd0bdc9b24eb8378c SHA512 daa6f4da97f71a5fd1f79d8c9e5fc43324743aec91362a05fa62e08966397a637d794abc7e14230eccf5f1271f9fac58d1336aaad1f2cded6cd10792845a494b
DIST rocm-opencl-runtime-4.3.0.tar.gz 1006792 BLAKE2B 29fd5843bb0153c7d3fe5250898f0fbdd089db6304122698c9ec9a5436e3a6845916f241f1a1e79a614e369f000297ac12413620edec0660d859ccddaa978d07 SHA512 a514d626700350f2c663db468427479eaa9e39dd912266ac2db6830d712351ffbc18737b208fd37f7ab5afdc2c9f6412d8d765973d6c72759bf51f864fc6bf1d
DIST rocm-opencl-runtime-5.0.2.tar.gz 1004855 BLAKE2B e2c2beb987053204fbe8fda562ae65d6c1a58447e9e88bf1081aabeee6c9a10738fd8562114b564b647682438fdbd2c535db1008ac6e1cc4eb9a915998eeb3c7 SHA512 fa01d1fafc890181b9e67070353ee7c9100619494b7509cae1a3659f24ef1d00f650024cb24bdb0e6e7eacfdec1115e4683ec6f320228a19f41ae83321780780
+DIST rocm-opencl-runtime-5.1.3.tar.gz 1004765 BLAKE2B 64d9b42026d2be1d0e4aa666785699f6b4ec0584a927904a94bf830883050943503f8bdd7c97438a2fb11c71686a330d526f633959916c5c6c8da2e037841e79 SHA512 b83c3ae0bfad80f867bacce36710a8964f6dd7e64bf50da3ec6ce842217d6de63299d9ceaab9dc25a22252484520a85d02859809463dad5dda9b1f00a86863e0
DIST rocm-tracer-5.0.2.tar.gz 474669 BLAKE2B b350111590140e1282338e4f134caf6228677c49361ceb9bc7ba0da8709346daa4fd014644c04adff0e903dba6014a84edd2eb3a5c132a8f91b479e4d5b085e5 SHA512 3fc1449cc9c9bf83e5233a7a0e83c0e3fa9da225d5ee4427b7d6fa15e3580497e1b9fbcd63892e4a99df01582aecd3ccfd66d2a19af2d8c25949ee705894ea44
+DIST rocm-tracer-5.1.3.tar.gz 511617 BLAKE2B 4142979b3b7d649798a7ac0b2a04b42aa7fbcbf82f2cf51b0e5363ec0da538046d6e59283d0ce1bfd341317bf24ac2f694d5c8a7d1f132f9b21caea5caf7eda3 SHA512 e73b0c921ffbdcac571d8b0825de39bd8a4fd5f2720ecdd0c189951db85efb607a0b1cd7a9bb02b3dbf329b277cb5e197525216a8e8927eea4e6ce290b7e7c7b
diff --git a/dev-util/hip/files/0001-SWDEV-316128-HIP-surface-API-support.patch b/dev-util/hip/files/0001-SWDEV-316128-HIP-surface-API-support.patch
new file mode 100644
index 00000000000..14af91f9055
--- /dev/null
+++ b/dev-util/hip/files/0001-SWDEV-316128-HIP-surface-API-support.patch
@@ -0,0 +1,35 @@
+From 4168c6ded4e54602f6fad8b0a483b20ab7f83cd5 Mon Sep 17 00:00:00 2001
+From: haoyuan2 <Hao.Yuan@amd.com>
+Date: Mon, 21 Feb 2022 10:10:04 -0800
+Subject: [PATCH] SWDEV-316128 - HIP surface API support
+
+remove redundant code in host API
+
+Change-Id: I8fbf894e858642da4198cc7afd2d2e2f1971e738
+Signed-off-by: YiyangWu <xgreenlandforwyy@gmail.com>
+---
+ src/hip_surface.cpp | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/src/hip_surface.cpp b/src/hip_surface.cpp
+index 831df321..a8e7f71d 100644
+--- a/src/hip_surface.cpp
++++ b/src/hip_surface.cpp
+@@ -1,4 +1,4 @@
+-/* Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc.
++/* Copyright (c) 2015 - 2022 Advanced Micro Devices, Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+@@ -81,8 +81,6 @@ hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject,
+ }
+
+ hipError_t ihipDestroySurfaceObject(hipSurfaceObject_t surfaceObject) {
+- HIP_INIT_API(hipDestroySurfaceObject, surfaceObject);
+-
+ if (surfaceObject == nullptr) {
+ return hipSuccess;
+ }
+--
+2.34.1
+
diff --git a/dev-util/hip/files/hip-5.1.3-clang-include-path.patch b/dev-util/hip/files/hip-5.1.3-clang-include-path.patch
new file mode 100644
index 00000000000..bf1f2dd32ce
--- /dev/null
+++ b/dev-util/hip/files/hip-5.1.3-clang-include-path.patch
@@ -0,0 +1,12 @@
+pass HIP_CLANG_INCLUDE_PATH which is determined by clang -print-resource-dir
+===================================================================
+--- HIP-rocm-5.1.3.orig/bin/hipcc.pl
++++ HIP-rocm-5.1.3/bin/hipcc.pl
+@@ -105,6 +105,7 @@ $ROCM_PATH = $hipvars::ROCM_PATH;
+ $HIP_VERSION = $hipvars::HIP_VERSION;
+ $HSA_PATH = $hipvars::HSA_PATH;
+ $HIP_ROCCLR_HOME = $hipvars::HIP_ROCCLR_HOME;
++$HIP_CLANG_INCLUDE_PATH = $hipvars::HIP_CLANG_INCLUDE_PATH;
+
+ if ($HIP_PLATFORM eq "amd") {
+ # If using ROCclr runtime, need to find HIP_ROCCLR_HOME
diff --git a/dev-util/hip/files/hip-5.1.3-fix-hip_prof_gen.patch b/dev-util/hip/files/hip-5.1.3-fix-hip_prof_gen.patch
new file mode 100644
index 00000000000..05b25e7178f
--- /dev/null
+++ b/dev-util/hip/files/hip-5.1.3-fix-hip_prof_gen.patch
@@ -0,0 +1,38 @@
+Backported fb5a64025bb0e10173a1ee4f3475db322b74b594
+fix an issue in hip_prof_gen.py with GLenum.
+diff --git a/src/hip_prof_gen.py b/src/hip_prof_gen.py
+index bd32d5bf..a3071a75 100755
+--- a/src/hip_prof_gen.py
++++ b/src/hip_prof_gen.py
+@@ -81,7 +81,7 @@ def filtr_api_args(args_str):
+ args_str = re.sub(r'\s*,\s*', r',', args_str);
+ args_str = re.sub(r'\s+', r' ', args_str);
+ args_str = re.sub(r'\s*(\*+)\s*', r'\1 ', args_str);
+- args_str = re.sub(r'(enum|struct) ', '', args_str);
++ args_str = re.sub(r'(\benum|struct) ', '', args_str);
+ return args_str
+
+ # Normalizing types
+@@ -129,7 +129,9 @@ def pointer_ck(arg_type):
+ m = re.match(r'(.*)\*$', arg_type)
+ if m:
+ ptr_type = m.group(1)
+- ptr_type = re.sub(r'const ', '', ptr_type)
++ n = re.match(r'(.*)\*\*$', arg_type)
++ if not n:
++ ptr_type = re.sub(r'const ', '', ptr_type)
+ if ptr_type == 'void': ptr_type = ''
+ return ptr_type
+ #############################################################
+@@ -613,7 +615,7 @@ if (len(sys.argv) < 4):
+ " -p - HIP_INIT_API macro patching mode\n" +
+ "\n" +
+ " Example:\n" +
+- " $ " + sys.argv[0] + " -v -p -t --priv ./include/hip/amd_detail/hip_runtime_api.h" +
++ " $ " + sys.argv[0] + " -v -p -t --priv ../hip/include/hip/hip_runtime_api.h" +
+ " ./src ./include/hip/amd_detail/hip_prof_str.h ./include/hip/amd_detail/hip_prof_str.h.new");
+
+ # API header file given as an argument
+--
+2.34.1
+
diff --git a/dev-util/hip/files/hip-5.1.3-rocm-path.patch b/dev-util/hip/files/hip-5.1.3-rocm-path.patch
new file mode 100644
index 00000000000..2ce68b73357
--- /dev/null
+++ b/dev-util/hip/files/hip-5.1.3-rocm-path.patch
@@ -0,0 +1,13 @@
+explicitly specify `--rocm-path=/usr` because clang does not list
+it among the default paths
+===================================================================
+--- HIP-rocm-5.1.3.orig/bin/hipcc.pl
++++ HIP-rocm-5.1.3/bin/hipcc.pl
+@@ -696,6 +696,7 @@ if ($HIP_PLATFORM eq "amd") {
+
+ if ($hasHIP) {
+ if ($DEVICE_LIB_PATH ne "$ROCM_PATH/amdgcn/bitcode") {
++ $HIPCXXFLAGS .= " --rocm-path=\"$ROCM_PATH\"";
+ $HIPCXXFLAGS .= " --hip-device-lib-path=\"$DEVICE_LIB_PATH\"";
+ }
+ $HIPCXXFLAGS .= " -fhip-new-launch-api";
diff --git a/dev-util/hip/files/hipvars-5.1.3.pm b/dev-util/hip/files/hipvars-5.1.3.pm
new file mode 100644
index 00000000000..7de38b7f3c7
--- /dev/null
+++ b/dev-util/hip/files/hipvars-5.1.3.pm
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+package hipvars;
+
+$HIP_BASE_VERSION_MAJOR = "@HIP_BASE_VERSION_MAJOR@";
+$HIP_BASE_VERSION_MINOR = "@HIP_BASE_VERSION_MINOR@";
+
+$isWindows = 0;
+$HIP_PATH='/usr';
+$ROCM_PATH='/usr';
+$CUDA_PATH='/opt/cuda';
+$HSA_PATH='/usr';
+$HIP_CLANG_PATH='@CLANG_PATH@';
+$HIP_CLANG_INCLUDE_PATH='@CLANG_INCLUDE_PATH@';
+$HIP_ROCCLR_HOME=$HIP_PATH;
+$HIP_PLATFORM='amd';
+$HIP_COMPILER = "clang";
+$HIP_RUNTIME = "rocclr";
+$HIP_VERSION_MAJOR = $HIP_BASE_VERSION_MAJOR;
+$HIP_VERSION_MINOR = $HIP_BASE_VERSION_MINOR;
+$HIP_VERSION_PATCH = "@HIP_VERSION_PATCH@";
+$HIP_VERSION="$HIP_VERSION_MAJOR.$HIP_VERSION_MINOR.$HIP_VERSION_PATCH";
diff --git a/dev-util/hip/hip-5.1.3.ebuild b/dev-util/hip/hip-5.1.3.ebuild
new file mode 100644
index 00000000000..a9e9844fdcc
--- /dev/null
+++ b/dev-util/hip/hip-5.1.3.ebuild
@@ -0,0 +1,161 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{8..11} )
+
+inherit cmake llvm prefix python-any-r1
+
+LLVM_MAX_SLOT=14
+
+DESCRIPTION="C++ Heterogeneous-Compute Interface for Portability"
+HOMEPAGE="https://github.com/ROCm-Developer-Tools/hipamd"
+SRC_URI="https://github.com/ROCm-Developer-Tools/hipamd/archive/rocm-${PV}.tar.gz -> rocm-hipamd-${PV}.tar.gz
+ https://github.com/ROCm-Developer-Tools/HIP/archive/rocm-${PV}.tar.gz -> rocm-hip-${PV}.tar.gz
+ https://github.com/ROCm-Developer-Tools/ROCclr/archive/rocm-${PV}.tar.gz -> rocclr-${PV}.tar.gz
+ https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/archive/rocm-${PV}.tar.gz -> rocm-opencl-runtime-${PV}.tar.gz
+ profile? ( https://github.com/ROCm-Developer-Tools/roctracer/archive/refs/tags/rocm-${PV}.tar.gz -> rocm-tracer-${PV}.tar.gz
+ https://github.com/ROCm-Developer-Tools/hipamd/files/8991181/hip_prof_str_diff.gz -> ${P}-update-header.patch.gz
+ )"
+
+KEYWORDS="~amd64"
+LICENSE="MIT"
+SLOT="0/$(ver_cut 1-2)"
+
+IUSE="debug profile"
+
+DEPEND="
+ >=dev-util/rocminfo-5
+ sys-devel/clang:${LLVM_MAX_SLOT}
+ dev-libs/rocm-comgr:${SLOT}
+ virtual/opengl
+"
+RDEPEND="${DEPEND}
+ dev-perl/URI-Encode
+ sys-devel/clang-runtime:=
+ >=dev-libs/roct-thunk-interface-5"
+BDEPEND="profile? ( $(python_gen_any_dep '
+ dev-python/CppHeaderParser[${PYTHON_USEDEP}]
+ ') )
+"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-5.0.1-DisableTest.patch"
+ "${FILESDIR}/${PN}-4.2.0-config-cmake-in.patch"
+ "${FILESDIR}/${PN}-5.0.1-hip_vector_types.patch"
+ "${FILESDIR}/${PN}-4.2.0-cancel-hcc-header-removal.patch"
+ "${FILESDIR}/${PN}-5.0.2-set-build-id.patch"
+ "${FILESDIR}/${PN}-5.1.3-fix-hip_prof_gen.patch"
+ "${FILESDIR}/0001-SWDEV-316128-HIP-surface-API-support.patch"
+)
+
+python_check_deps() {
+ if use profile; then
+ has_version "dev-python/CppHeaderParser[${PYTHON_USEDEP}]"
+ fi
+}
+
+S="${WORKDIR}/hipamd-rocm-${PV}"
+HIP_S="${WORKDIR}"/HIP-rocm-${PV}
+OCL_S="${WORKDIR}"/ROCm-OpenCL-Runtime-rocm-${PV}
+CLR_S="${WORKDIR}"/ROCclr-rocm-${PV}
+RTC_S="${WORKDIR}"/roctracer-rocm-${PV}
+
+src_prepare() {
+ cmake_src_prepare
+ use profile && eapply "${WORKDIR}/${P}-update-header.patch"
+
+ eapply_user
+
+ # Use Gentoo slot number, otherwise git hash is attempted in vain.
+ sed -e "/set (HIP_LIB_VERSION_STRING/cset (HIP_LIB_VERSION_STRING ${SLOT#*/})" -i CMakeLists.txt || die
+
+ # disable PCH, because it results in a build error in ROCm 4.0.0
+ sed -e "s:option(__HIP_ENABLE_PCH:#option(__HIP_ENABLE_PCH:" -i CMakeLists.txt || die
+
+ # correctly find HIP_CLANG_INCLUDE_PATH using cmake
+ local LLVM_PREFIX="$(get_llvm_prefix "${LLVM_MAX_SLOT}")"
+ local CLANG_RESOURCE_DIR=$("${LLVM_PREFIX}/bin/clang" -print-resource-dir)
+ sed -e "/set(HIP_CLANG_ROOT/s:\"\${ROCM_PATH}/llvm\":${LLVM_PREFIX}:" -i hip-config.cmake.in || die
+
+ # correct libs and cmake install dir
+ sed -e "/LIB_INSTALL_DIR/s:PREFIX}/lib:PREFIX}/$(get_libdir):" \
+ -e "/${HIP_COMMON_DIR}\/cmake DESTINATION/s: .): $(get_libdir)):" -i CMakeLists.txt || die
+ sed -e "/LIBRARY DESTINATION/s:lib:$(get_libdir):" -i src/CMakeLists.txt || die
+
+ sed -e "/\.hip/d" \
+ -e "s,DESTINATION lib,DESTINATION $(get_libdir),g" \
+ -e "/\(cmake\|samples\)/s,DESTINATION \.,DESTINATION share,g" \
+ -e "/CPACK_RESOURCE_FILE_LICENSE/d" -i packaging/CMakeLists.txt || die
+
+ pushd ${HIP_S} || die
+ eapply "${FILESDIR}/${PN}-5.1.3-clang-include-path.patch"
+ eapply "${FILESDIR}/${PN}-5.1.3-rocm-path.patch"
+ eapply "${FILESDIR}/${PN}-5.0.2-correct-ldflag.patch"
+ # Setting HSA_PATH to "/usr" results in setting "-isystem /usr/include"
+ # which makes "stdlib.h" not found when using "#include_next" in header files;
+ sed -e "/FLAGS .= \" -isystem \$HSA_PATH/d" \
+ -e "/HIP.*FLAGS.*isystem.*HIP_INCLUDE_PATH/d" \
+ -e "s:\$ENV{'DEVICE_LIB_PATH'}:'/usr/lib/amdgcn/bitcode':" \
+ -e "s:\$ENV{'HIP_LIB_PATH'}:'/usr/$(get_libdir)':" \
+ -e "/rpath/s,--rpath=[^ ]*,," \
+ -e "s,\$HIP_CLANG_PATH/../lib/clang/\$HIP_CLANG_VERSION/,${CLANG_RESOURCE_DIR}/,g" \
+ -i bin/hipcc.pl || die
+
+ # change --hip-device-lib-path to "/usr/lib/amdgcn/bitcode", must align with "dev-libs/rocm-device-libs"
+ sed -e "s:\${AMD_DEVICE_LIBS_PREFIX}/lib:/usr/lib/amdgcn/bitcode:" \
+ -i "${S}/hip-config.cmake.in" || die
+
+ einfo "prefixing hipcc and its utils..."
+ hprefixify $(grep -rl --exclude-dir=build/ "/usr" "${S}")
+ hprefixify $(grep -rl --exclude-dir=build/ "/usr" "${HIP_S}")
+
+ cp "$(prefixify_ro "${FILESDIR}"/hipvars-5.1.3.pm)" bin/hipvars.pm || die "failed to replace hipvars.pm"
+ sed -e "s,@HIP_BASE_VERSION_MAJOR@,$(ver_cut 1)," -e "s,@HIP_BASE_VERSION_MINOR@,$(ver_cut 2)," \
+ -e "s,@HIP_VERSION_PATCH@,$(ver_cut 3)," \
+ -e "s,@CLANG_INCLUDE_PATH@,${CLANG_RESOURCE_DIR}/include," \
+ -e "s,@CLANG_PATH@,${LLVM_PREFIX}/bin," -i bin/hipvars.pm || die
+
+ sed -e "/HIP_CLANG_INCLUDE_SEARCH_PATHS/s,\${_IMPORT_PREFIX}.*/include,${CLANG_RESOURCE_DIR}/include," -i hip-lang-config.cmake.in || die
+ popd || die
+ sed -e "/HIP_CLANG_INCLUDE_SEARCH_PATHS/s,\${HIP_CLANG_ROOT}.*/include,${CLANG_RESOURCE_DIR}/include," -i hip-config.cmake.in || die
+}
+
+src_configure() {
+ use debug && CMAKE_BUILD_TYPE="Debug"
+
+ # TODO: Currently a GENTOO configuration is build,
+ # this is also used in the cmake configuration files
+ # which will be installed to find HIP;
+ # Other ROCm packages expect a "RELEASE" configuration,
+ # see "hipBLAS"
+ local mycmakeargs=(
+ -DCMAKE_PREFIX_PATH="$(get_llvm_prefix "${LLVM_MAX_SLOT}")"
+ -DCMAKE_BUILD_TYPE=${buildtype}
+ -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
+ -DCMAKE_SKIP_RPATH=ON
+ -DBUILD_HIPIFY_CLANG=OFF
+ -DHIP_PLATFORM=amd
+ -DHIP_COMPILER=clang
+ -DROCM_PATH="${EPREFIX}/usr"
+ -DUSE_PROF_API=$(usex profile 1 0)
+ -DROCCLR_PATH=${CLR_S}
+ -DHIP_COMMON_DIR=${HIP_S}
+ -DAMD_OPENCL_PATH=${OCL_S}
+ )
+
+ use profile && mycmakeargs+=( -DPROF_API_HEADER_PATH="${RTC_S}"/inc/ext )
+
+ cmake_src_configure
+}
+
+src_install() {
+
+ cmake_src_install
+
+ rm "${ED}/usr/include/hip/hcc_detail" || die
+
+ # Don't install .hipInfo and .hipVersion to bin/lib
+ rm "${ED}/usr/lib/.hipInfo" "${ED}/usr/bin/.hipVersion" || die
+}