# Copyright 1999-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 # Keep ROCm 10's subslot-pinned stack on LLVM 23. verified 2026-08-29 LLVM_COMPAT=( 23 ) ROCM_SKIP_GLOBALS=1 inherit cmake flag-o-matic linux-info llvm-r2 rocm if [[ ${PV} == *9999 ]] ; then EGIT_SUBMODULES=() EGIT_REPO_URI="https://github.com/ROCm/rocm-systems.git" inherit git-r3 S="${WORKDIR}/${P}/projects/rocr-runtime/libhsakmt" else # Share rocr-runtime's archive and distfile name. SRC_URI="https://github.com/ROCm/rocm-systems/releases/download/therock-$(ver_cut 1-2)/rocr-runtime.tar.gz -> rocr-runtime-${PV}.tar.gz" S="${WORKDIR}/rocr-runtime/libhsakmt" KEYWORDS="~amd64" fi DESCRIPTION="Radeon Open Compute Thunk Interface" HOMEPAGE="https://github.com/ROCm/rocm-systems/tree/develop/projects/rocr-runtime/libhsakmt" CONFIG_CHECK="~HSA_AMD ~HMM_MIRROR ~ZONE_DEVICE ~DRM_AMDGPU ~DRM_AMDGPU_USERPTR" LICENSE="MIT" SLOT="0/$(ver_cut 1-2)" RDEPEND=" sys-process/numactl x11-libs/libdrm[video_cards_amdgpu] " DEPEND="${RDEPEND} test? ( $(llvm_gen_dep "llvm-core/llvm:\${LLVM_SLOT}") dev-cpp/gtest )" IUSE="test" RESTRICT="!test? ( test )" CMAKE_BUILD_TYPE=Release PATCHES=( "${FILESDIR}/${PN}-10.0.0-functions.patch" "${FILESDIR}/${PN}-10.0.0-extsem-visibility.patch" "${FILESDIR}/kfdtest-6.1.0-skipIPCtest.patch" "${FILESDIR}/kfdtest-6.2.4-fix-llvm-header.patch" ) test_wrapper() { local S="$1" shift 1 local CMAKE_USE_DIR="${S}" local BUILD_DIR="${S}_build" cd "${S}" || die "$@" } src_prepare() { # Guard the version anchor; a stale sed would preserve the wrong SONAME. grep -qF 'get_version ( "1.0.0" )' CMakeLists.txt || die 'get_version ( "1.0.0" ) anchor moved in CMakeLists.txt' sed -e "s/get_version ( \"1.0.0\" )/get_version ( \"${PV}\" )/" -i CMakeLists.txt || die # Build shared libhsakmt (ROCR-Runtime#263); guard sed's anchor. grep -qF '${HSAKMT_TARGET} STATIC' CMakeLists.txt || die 'HSAKMT_TARGET STATIC anchor moved in CMakeLists.txt' sed -e "s/\${HSAKMT_TARGET} STATIC/\${HSAKMT_TARGET}/" -i CMakeLists.txt || die cmake_src_prepare } src_configure() { llvm_prepend_path "${LLVM_SLOT}" append-cxxflags -Wno-unused-value local mycmakeargs=( -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" -DBUILD_SHARED_LIBS=ON -DCMAKE_DISABLE_FIND_PACKAGE_NUMA=ON # find_library handles NUMA ) cmake_src_configure if use test; then # Avoid test ODR violations (Gentoo bug 956958). filter-lto export LIBHSAKMT_PATH="${BUILD_DIR}" test_wrapper "${S}/tests/kfdtest" cmake_src_configure fi } src_compile() { cmake_src_compile if use test; then LIBRARY_PATH="${BUILD_DIR}" test_wrapper "${S}/tests/kfdtest" cmake_src_compile fi } src_test() { check_amdgpu cd "${S}/tests/kfdtest_build/" || die # Known hardware-specific failures: rocm-systems issue 3635. local skipped_tests=( KFDMemoryTest.LargestSysBufferTest # OOMs with gfx1151 KFDMemoryTest.LargestVramBufferTest # OOMs with gfx1151 KFDMemoryTest.BigSysBufferStressTest # OOMs with gfx1151 KFDQMTest.mGPUShareBO # wants at least two GPUs? KFDPCSamplingTest.* # gfx1151: no pc sampling? KFDQMTest.QueueLatency # gfx1151: fails (issues with iGPU clock?) ) local IFS=: ./run_kfdtest.sh -e "${skipped_tests[*]}" || die }