Skip to content

Commit

Permalink
Some cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
justxi committed Dec 23, 2020
1 parent 20842d7 commit d7dd7f8
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
1 change: 1 addition & 0 deletions sys-devel/hip/Manifest
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ EBUILD hip-3.7.0.ebuild 3246 BLAKE2B 6545cfc345fc4a68c5107e6bb55ee6ede4e69d538e1
EBUILD hip-3.8.0.ebuild 3320 BLAKE2B 9d4826a00068c284f10f46797447cea9c7d98107397b47dfbdd8fe2d32e25781d9134a6f07d081e584164d965fad9f058ba6b3214b5e7629b668536b8f31690b SHA512 f72f67158141e966e86c3347c9b49a399743db77b2fcc16079e8d9e3d611b541dffbc43a0735491694e965a09345901e94a101c73bbc762a47574518fb09af0f
EBUILD hip-3.9.0.ebuild 3458 BLAKE2B cb7ab3188adea56ba563359b82ea4e38d3b8b6cddd0c6c3f46d232660c00eb89b131b1bcd52a9839a580794c95da55c62c459b8b9963a2af06dfe57d2609bfd0 SHA512 53a13b4a5a458f57284456385b1e9c2d86f2e65e7a3a27400c5eb9bf296582d7737a573d3d1d5f1030650cf9d1aba8dfcad8e240fb2de4f6da2b605b6c6717f3
EBUILD hip-4.0.0-r1.ebuild 3939 BLAKE2B f59bb4ceb075e7bebea62c15e344fe36529112c18e254115e7b5a44bb87089d49f42fe72ec8d61a211a362058a4137d64152dfc2247b8affe2d1d43ef03681e2 SHA512 8a6dbcf4c524ec85d593f2f6fae3a3ae83ae014de2981d918e6701d1b4da7c86aeb5eb6b4bc990544e2f659b384206e5c725d86926bed12e2235a5eb279f6eff
EBUILD hip-4.0.0-r2.ebuild 3776 BLAKE2B 1303907aa184f32b90a13fc51057199142a71c94ccc090aa339649ff54c1bef4d843335306de10080336a80334948c4f99f637a15344a04026f1d01d653be7ce SHA512 7b6c67eebdee08ced1573fe579526d4957bdebd5ebf605ee5d631c85f9331dc33aa12d47ded2a609e8e286772c06847252afcc12b73f5e045758df5f52ad8640
EBUILD hip-4.0.0.ebuild 3822 BLAKE2B 76666c84bd735e7eab89d64580086b7ea53c8aeec51112f936dec208b5fc93b54c9995015784644bdf6b5357da5493e8d8a0ee2eb360d03b4559c6a7d39a1321 SHA512 c8ba1271b0ba82377468e856c8f7b897bb2cacfde92db6a08aa2d963eb82fae05c8e1f7448d06585d6c4bfaeb173eaec2c2a50963efe7dc3f74476d46a79b4f0
EBUILD hip-9999.ebuild 2010 BLAKE2B eb8998450638acdd5b3ae55f5eb3bd56ac6afc69743bad85b57833c15813d2507715f1f8ccce070461bfcc120b2b9c185b9cc4b3d587c919afb6fc4542455711 SHA512 132de2fc64c9430f9aa499aaddf48ad61923078ce73fe3496144b31cce8269015c298c22162ea6b932b4d2da7aa1aade4ab3c24de53f34c919aabed0d74790a4
111 changes: 111 additions & 0 deletions sys-devel/hip/hip-4.0.0-r2.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Copyright
# Distributed under the terms of the GNU General Public License v2

EAPI=7
inherit cmake-utils flag-o-matic

DESCRIPTION="C++ Heterogeneous-Compute Interface for Portability"
HOMEPAGE="https://github.com/ROCm-Developer-Tools/HIP"
SRC_URI="https://github.com/ROCm-Developer-Tools/HIP/archive/rocm-${PV}.tar.gz -> rocm-hip-${PV}.tar.gz"

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

IUSE="debug hipify profile"
# Currently enabling "hipify" is known to fail!

# Don't strip to prevent some tests to fail
RESRICT="strip"

DEPEND=">=dev-libs/rocclr-$(ver_cut 1-2)
>=dev-util/rocminfo-$(ver_cut 1-2)
=sys-devel/llvm-roc-${PV}*[runtime]
hipify? ( >=sys-devel/clang-10.0.0 )"
RDEPEND="${DEPEND}"


PATCHES=(
"${FILESDIR}/${PN}-3.9.0-DisableTest.patch"
"${FILESDIR}/${PN}-3.9.0-add-include-directories.patch"
"${FILESDIR}/${PN}-3.5.1-config-cmake-in.patch"
"${FILESDIR}/${PN}-3.5.1-hip_vector_types.patch"
"${FILESDIR}/${PN}-3.5.1-detect_offload-arch_for_clang-roc.patch"
"${FILESDIR}/${PN}-3.9.0-lpl_ca-add-include.patch"
)

S="${WORKDIR}/HIP-rocm-${PV}"

src_prepare() {
# 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 "${S}/CMakeLists.txt" || die

# "hcc" is deprecated and not installed, new platform is "rocclr"
sed -e "s:\$HIP_PLATFORM eq \"hcc\" and \$HIP_COMPILER eq \"clang\":\$HIP_PLATFORM eq \"rocclr\" and \$HIP_COMPILER eq \"clang\":" -i "${S}/bin/hipcc" || die

# Due to setting HAS_PATH to "/usr", this results in setting "-isystem /usr/include"
# which results in a e.g. "stdlib.h" not found when using "#include_next" in header files
sed -e "s: \$HIPCXXFLAGS .= \" -isystem \$HSA_PATH/include\";:# \$HIPCXXFLAGS .= \" -isystem \$HSA_PATH/include\";:" -i bin/hipcc || 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"

#prefixing hipcc and its utils
grep -rl --exclude-dir=build/ "/usr" ${S} | xargs sed -e "s:/usr:${EPREFIX}/usr:g" -i || die

eapply_user
cmake-utils_src_prepare
}

src_configure() {
strip-flags
if ! use debug; then
append-cflags "-DNDEBUG"
append-cxxflags "-DNDEBUG"
buildtype="Release"
else
buildtype="Debug"
fi

export DEVICE_LIB_PATH="${EPREFIX}/usr/lib/amdgcn/bitcode/"

# 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="/usr/lib/llvm/roc/"
-DCMAKE_BUILD_TYPE=${buildtype}
-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/hip/$(ver_cut 1-2)"
-DBUILD_HIPIFY_CLANG=$(usex hipify)
-DHIP_PLATFORM=rocclr
-DHIP_RUNTIME=ROCclr
-DHIP_COMPILER=clang
-DROCM_PATH="${EPREFIX}/usr"
-DHSA_PATH="${EPREFIX}/usr"
-DUSE_PROF_API=$(usex profile 1 0)
-DROCclr_DIR=${EPREFIX}/usr/include/rocclr
-DLIBROCclr_STATIC_DIR=${EPREFIX}/usr/lib64/cmake/rocclr
)

cmake-utils_src_configure
}

src_install() {
echo "HSA_PATH=${EPREFIX}/usr" > 99hip || die
echo "ROCM_PATH=${EPREFIX}/usr" >> 99hip || die
echo "HIP_PLATFORM=rocclr" >> 99hip || die
echo "HIP_RUNTIME=ROCclr" >> 99hip || die
echo "HIP_COMPILER=clang" >> 99hip || die
echo "HIP_CLANG_PATH=${EPREFIX}/usr/lib/llvm/roc/bin" >> 99hip || die

echo "PATH=${EPREFIX}/usr/lib/hip/$(ver_cut 1-2)/bin" >> 99hip || die
echo "HIP_PATH=${EPREFIX}/usr/lib/hip/$(ver_cut 1-2)" >> 99hip || die
echo "LDPATH=${EPREFIX}/usr/lib/hip/$(ver_cut 1-2)/lib" >> 99hip || die
echo "ROOTPATH=${EPREFIX}/usr/lib/hip/$(ver_cut 1-2)/bin" >> 99hip || die

doenvd 99hip

cmake-utils_src_install
}

0 comments on commit d7dd7f8

Please sign in to comment.