Gentoo Archives: gentoo-commits

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