# Copyright 1999-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 # Keep the subslot-pinned ROCm closure on one LLVM major. LLVM_COMPAT=( 23 ) inherit cmake llvm-r2 # Use the matching TheRock archive after retirement of rocm-* releases. Keep # MY_P aligned with rocm-device-libs so both reuse one distfile. MY_P=llvm-project-therock-$(ver_cut 1-2) components=( "amd/comgr" ) DESCRIPTION="Radeon Open Compute Code Object Manager" HOMEPAGE="https://github.com/ROCm/llvm-project/tree/amd-staging/amd/comgr" SRC_URI="https://github.com/ROCm/llvm-project/archive/therock-$(ver_cut 1-2).tar.gz -> ${MY_P}.tar.gz" S="${WORKDIR}/${MY_P}/${components[0]}" LICENSE="MIT" SLOT="0/$(ver_cut 1-2)" KEYWORDS="~amd64" IUSE="test" RESTRICT="!test? ( test )" PATCHES=( "${FILESDIR}/${PN}-6.4.1-extend-isa-compatibility-check.patch" "${FILESDIR}/${PN}-6.1.0-dont-add-nogpulib.patch" "${FILESDIR}/${PN}-10.0.0-add-missing-headers.patch" "${FILESDIR}/${PN}-10.0.0-hotswap-llvm-dylib.patch" ) RDEPEND=" dev-libs/rocm-device-libs:${SLOT} llvm-runtimes/clang-runtime:= $(llvm_gen_dep " llvm-core/clang:\${LLVM_SLOT}= llvm-core/lld:\${LLVM_SLOT}= llvm-core/llvm:\${LLVM_SLOT}= ") dev-util/hipcc:${SLOT} " DEPEND="${RDEPEND}" # Tests require a functional HIP compiler, creating a build cycle. BDEPEND="test? ( dev-util/hip:${SLOT} )" CMAKE_BUILD_TYPE=Release src_unpack() { if [[ ${PV} == *9999 ]] ; then git-r3_fetch git-r3_checkout '' . '' "${components[@]}" else archive="${MY_P}.tar.gz" ebegin "Unpacking from ${archive}" tar -x -z -o \ -f "${DISTDIR}/${archive}" \ "${components[@]/#/${MY_P}/}" || die eend ${?} fi } src_prepare() { # Assert the brittle resource-path anchor before rewriting it. # verified 2026-08-29 grep -q 'CLANG_CMAKE_DIR}/\.\./\.\./\.\./\*' cmake/opencl_header.cmake || die "opencl_header.cmake anchor moved; re-check the sed below" sed -e "s:\${CLANG_CMAKE_DIR}/../../../\*:${EPREFIX}/usr/lib/clang/${LLVM_SLOT}/include:" \ -i cmake/opencl_header.cmake || die cmake_src_prepare } src_configure() { llvm_prepend_path "${LLVM_SLOT}" local mycmakeargs=( -DCMAKE_STRIP="" # Preserve artifacts; upstream strips by default. -DBUILD_TESTING=$(usex test ON OFF) # Requires ROCm's SPIRV-LLVM-Translator fork. -DCOMGR_DISABLE_SPIRV=ON ) # System HIP discovery breaks the test build. use test && mycmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_hip=ON ) cmake_src_configure } src_test() { cmake_src_test }