Gentoo Archives: gentoo-commits

From: Andrew Ammerlaan <andrewammerlaan@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-util/hip/
Date: Sat, 05 Mar 2022 20:52:04
Message-Id: 1646513511.cadd3e208390316e2bfb03345cfb922eb67555a1.andrewammerlaan@gentoo
1 commit: cadd3e208390316e2bfb03345cfb922eb67555a1
2 Author: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
3 AuthorDate: Sat Mar 5 14:03:17 2022 +0000
4 Commit: Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
5 CommitDate: Sat Mar 5 20:51:51 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cadd3e20
7
8 dev-util/hip: fix compile, add missing dep
9
10 Co-authored-by: Dennis Schridde <devurandom <AT> gmx.net>
11 Co-authored-by: Paul Preney <paul <AT> preney.ca>
12 Closes: https://bugs.gentoo.org/790164
13 Package-Manager: Portage-3.0.30, Repoman-3.0.3
14 Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>
15
16 dev-util/hip/hip-4.3.0-r2.ebuild | 112 +++++++++++++++++++++++++++++++++++++++
17 1 file changed, 112 insertions(+)
18
19 diff --git a/dev-util/hip/hip-4.3.0-r2.ebuild b/dev-util/hip/hip-4.3.0-r2.ebuild
20 new file mode 100644
21 index 000000000000..9547abd69ae1
22 --- /dev/null
23 +++ b/dev-util/hip/hip-4.3.0-r2.ebuild
24 @@ -0,0 +1,112 @@
25 +# Copyright 1999-2022 Gentoo Authors
26 +# Distributed under the terms of the GNU General Public License v2
27 +
28 +EAPI=8
29 +inherit cmake prefix
30 +
31 +DESCRIPTION="C++ Heterogeneous-Compute Interface for Portability"
32 +HOMEPAGE="https://github.com/ROCm-Developer-Tools/HIP"
33 +SRC_URI="https://github.com/ROCm-Developer-Tools/HIP/archive/rocm-${PV}.tar.gz -> rocm-hip-${PV}.tar.gz
34 + https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/archive/rocm-${PV}.tar.gz -> rocm-opencl-runtime-${PV}.tar.gz"
35 +S="${WORKDIR}/HIP-rocm-${PV}"
36 +
37 +KEYWORDS="~amd64"
38 +LICENSE="MIT"
39 +SLOT="0/$(ver_cut 1-2)"
40 +
41 +IUSE="debug profile"
42 +
43 +DEPEND="
44 + dev-libs/rocclr:${SLOT}
45 + dev-util/rocminfo:${SLOT}
46 + dev-libs/roct-thunk-interface:${SLOT}
47 + =sys-devel/llvm-roc-${PV}*[runtime]
48 + profile? ( dev-util/roctracer:${SLOT} )"
49 +RDEPEND="${DEPEND}
50 + dev-perl/URI-Encode"
51 +
52 +PATCHES=(
53 + "${FILESDIR}/${PN}-4.1.0-DisableTest.patch"
54 + "${FILESDIR}/${PN}-3.9.0-add-include-directories.patch"
55 + "${FILESDIR}/${PN}-4.2.0-config-cmake-in.patch"
56 + "${FILESDIR}/${PN}-4.3.0-hip_vector_types.patch"
57 + "${FILESDIR}/${PN}-4.2.0-cancel-hcc-header-removal.patch"
58 +)
59 +
60 +src_prepare() {
61 + cmake_src_prepare
62 +
63 + # Use Gentoo slot number, otherwise git hash is attempted in vain.
64 + sed -e "/set (HIP_LIB_VERSION_STRING/cset (HIP_LIB_VERSION_STRING ${SLOT#*/})" -i CMakeLists.txt || die
65 +
66 + # disable PCH, because it results in a build error in ROCm 4.0.0
67 + sed -e "s:option(__HIP_ENABLE_PCH:#option(__HIP_ENABLE_PCH:" -i CMakeLists.txt || die
68 +
69 + # remove forcing set USE_PROF_API to 1
70 + sed -e '/set(USE_PROF_API "1")/d' -i rocclr/CMakeLists.txt || die
71 +
72 + # "hcc" is deprecated and not installed, new platform is "rocclr";
73 + # Setting HSA_PATH to "/usr" results in setting "-isystem /usr/include"
74 + # which makes "stdlib.h" not found when using "#include_next" in header files;
75 + sed -e "/FLAGS .= \" -isystem \$HSA_PATH/d" \
76 + -e "s:\$ENV{'DEVICE_LIB_PATH'}:'/usr/lib/amdgcn/bitcode':" \
77 + -e "/rpath/s,--rpath=[^ ]*,," \
78 + -i bin/hipcc || die
79 +
80 + # correctly find HIP_CLANG_INCLUDE_PATH using cmake
81 + sed -e "/set(HIP_CLANG_ROOT/s:\"\${ROCM_PATH}/llvm\":/usr/lib/llvm/roc:" -i hip-config.cmake.in || die
82 +
83 + # change --hip-device-lib-path to "/usr/lib/amdgcn/bitcode", must align with "dev-libs/rocm-device-libs"
84 + sed -e "s:\${AMD_DEVICE_LIBS_PREFIX}/lib:/usr/lib/amdgcn/bitcode:" \
85 + -i "${S}/hip-config.cmake.in" || die
86 +
87 + einfo "prefixing hipcc and its utils..."
88 + hprefixify $(grep -rl --exclude-dir=build/ "/usr" "${S}")
89 +
90 + cp "$(prefixify_ro "${FILESDIR}"/hipvars.pm)" bin/ || die "failed to replace hipvars.pm"
91 + sed -e "s,@HIP_BASE_VERSION_MAJOR@,$(ver_cut 1)," -e "s,@HIP_BASE_VERSION_MINOR@,$(ver_cut 2)," \
92 + -e "s,@HIP_VERSION_PATCH@,$(ver_cut 3)," -i bin/hipvars.pm || die
93 +
94 + cp -a "${WORKDIR}"/ROCm-OpenCL-Runtime-rocm-${PV}/amdocl/cl_vk_amd.hpp amdocl/ || die
95 +
96 + # Bug 790164
97 + rm amdocl/CL/cl{,_icd,_gl,_gl_ext,_platform}.h || die
98 + sed -i 's/CL_EXT_SUFFIX/CL_API_SUFFIX/' amdocl/cl_icd_amd.h amdocl/CL/cl_ext.h rocclr/cl_lqdflash_amd.h || die
99 +}
100 +
101 +src_configure() {
102 + use debug && CMAKE_BUILD_TYPE="Debug"
103 +
104 + # TODO: Currently a GENTOO configuration is build,
105 + # this is also used in the cmake configuration files
106 + # which will be installed to find HIP;
107 + # Other ROCm packages expect a "RELEASE" configuration,
108 + # see "hipBLAS"
109 + local mycmakeargs=(
110 + -DCMAKE_PREFIX_PATH="${EPREFIX}/usr/lib/llvm/roc"
111 + -DCMAKE_BUILD_TYPE=${buildtype}
112 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/hip"
113 + -DBUILD_HIPIFY_CLANG=OFF
114 + -DHIP_PLATFORM=rocclr
115 + -DHIP_COMPILER=clang
116 + -DROCM_PATH="${EPREFIX}/usr"
117 + -DHSA_PATH="${EPREFIX}/usr"
118 + -DUSE_PROF_API=$(usex profile 1 0)
119 + -DPROF_API_HEADER_PATH="${EPREFIX}"/usr/include/roctracer/ext
120 + -DROCclr_DIR="${EPREFIX}"/usr/include/rocclr
121 + )
122 +
123 + cmake_src_configure
124 +}
125 +
126 +src_install() {
127 + echo "PATH=${EPREFIX}/usr/lib/hip/bin" >> 99hip || die
128 + echo "LDPATH=${EPREFIX}/usr/lib/hip/lib" >> 99hip || die
129 + echo "ROOTPATH=${EPREFIX}/usr/lib/hip/bin" >> 99hip || die
130 +
131 + doenvd 99hip
132 +
133 + cmake_src_install
134 +
135 + rm "${ED}/usr/lib/hip/include/hip/hcc_detail" || die
136 +}