# Copyright 1999-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 PYTHON_COMPAT=( python3_{12..14} ) inherit bash-completion-r1 cmake python-any-r1 DESCRIPTION="Runtime for AIE and FPGA based platforms" HOMEPAGE="https://github.com/Xilinx/XRT" if [[ ${PV} == 999999 ]] ; then EGIT_REPO_URI="https://github.com/Xilinx/XRT.git" EGIT_BRANCH="XRT-2.25" EGIT_SUBMODULES=( src/runtime_src/aie-codegen src/runtime_src/aie-codegen/aie-regdb src/runtime_src/core/common/aiebu src/runtime_src/core/common/elf src/runtime_src/core/common/aiebu/src/cpp/ELFIO src/runtime_src/xdp ) inherit git-r3 else declare -Ag submodules submodules["src/runtime_src/core/common/aiebu"]=https://github.com/Xilinx/aiebu.git@c108cc4bc7d68021b53bac08235258512d24188c submodules["src/runtime_src/core/common/elf"]=https://github.com/serge1/ELFIO.git@f849001fc229c2598f8557e0df22866af194ef98 submodules["src/runtime_src/aie-codegen"]=https://github.com/Xilinx/aie-codegen.git@95342426953e6bb3b4e5ae8cb1aa5018cf78ae51 submodules["src/runtime_src/aie-codegen/aie-regdb"]=https://github.com/Xilinx/aie-regdb.git@3faba137f02db4dd3f64331e3a74a9b5584df8b7 submodules["src/runtime_src/xdp"]=https://github.com/Xilinx/XDP.git@0da0510938441a9c5f408298e26315db5b23204d MGS_HASH=554d75e924ed621f23d077b0495c247c329bc770 MGS=markdown_graphviz_svg MGS_PY=${MGS}-${MGS_HASH:0:8}.py SRC_URI=" https://github.com/Xilinx/XRT/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz https://raw.githubusercontent.com/Tanami/markdown-graphviz-svg/${MGS_HASH}/src/${MGS}/${MGS}.py -> ${MGS_PY} " for k in "${!submodules[@]}"; do git_url="${submodules[$k]%@*}" commit_hash="${submodules[$k]#*@}" url_prefix="${git_url%.git}" SRC_URI+=" ${url_prefix}/archive/${commit_hash}.tar.gz -> ${url_prefix##*/}-${commit_hash:0:8}.tar.gz"; done KEYWORDS="~amd64" S="${WORKDIR}/XRT-${PV}" fi LICENSE="Apache-2.0" SLOT="0" IUSE="test" RESTRICT="!test? ( test )" RDEPEND=" dev-debug/systemtap dev-libs/boost:= dev-libs/openssl:= sys-apps/util-linux " DEPEND=" ${RDEPEND} dev-libs/cxxopts dev-libs/opencl-icd-loader dev-libs/rapidjson dev-util/opencl-headers x11-libs/libdrm dev-cpp/ms-gsl " BDEPEND=" ${PYTHON_DEPS} test? ( dev-libs/elfutils ) $(python_gen_any_dep " dev-python/jinja2[\${PYTHON_USEDEP}] dev-python/markdown[\${PYTHON_USEDEP}] dev-python/pybind11[\${PYTHON_USEDEP}] dev-python/pyyaml[\${PYTHON_USEDEP}] ") " python_check_deps() { python_has_version -b "dev-python/jinja2[${PYTHON_USEDEP}]" && \ python_has_version -b "dev-python/markdown[${PYTHON_USEDEP}]" && \ python_has_version -b "dev-python/pybind11[${PYTHON_USEDEP}]" && \ python_has_version -b "dev-python/pyyaml[${PYTHON_USEDEP}]" } src_prepare() { if [[ ${PV} != 999999 ]] ; then for k in $(printf '%s\n' "${!submodules[@]}" | sort); do git_url="${submodules[$k]%@*}" commit_hash="${submodules[$k]#*@}" url_prefix="${git_url%.git}" rm -r "$k" || die ln -s "${WORKDIR}/${url_prefix##*/}-${commit_hash}" "$k" || die done fi pushd "src/runtime_src/core/common/aiebu" || die eapply "${FILESDIR}"/aiebu-no-downloads.patch popd || die sed -e 's/-Werror//' -i src/runtime_src/core/common/aiebu/cmake/linux.cmake || die # Enable instead of sed -e "/OPENCL_ICD_LOADER/c #if 1" \ -i src/runtime_src/xocl/api/icd/ocl_icd_bindings.h \ -i src/runtime_src/xocl/api/icd/ocl_icd_bindings.cpp || die # template for isa.h is damaged in git, skip regeneration # Bug: https://github.com/Xilinx/aiebu/issues/144 sed -e '/BYPRODUCTS .*isa\.h/d' \ -i src/runtime_src/core/common/aiebu/specification/aie2ps/CMakeLists.txt || die sed -e "s/set (XRT_UPSTREAM 0)/set (XRT_UPSTREAM 1)/" \ -i src/CMake/settings.cmake || die sed -e "s|\${XRT_INSTALL_DIR}/share/doc|\${CMAKE_INSTALL_DOCDIR}|" \ -i src/CMake/changelog.cmake || die cmake_src_prepare } src_configure() { local mycmakeargs=( -DCMAKE_INSTALL_PREFIX="${EPREFIX}"/usr -DPython3_EXECUTABLE="${PYTHON}" -DSPEC_TOOL_DEPS_DOWNLOADED=ON -DXRT_ENABLE_WERROR=OFF -DXRT_NPU=ON -Wno-dev ) [[ ${PV} != 999999 ]] && mycmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON ) cmake_src_configure ln -s "${DISTDIR}/${MGS_PY}" \ "${BUILD_DIR}/src/runtime_src/core/common/aiebu/specification/${MGS}.py" || die } src_test() { DESTDIR=. cmake_build install cmake_src_test } src_install() { cmake_src_install rm -r "${ED}"/usr/{license,version.json} || die rm -r "${ED}"/usr/share/completions || die newbashcomp "${S}/src/runtime_src/core/tools/xbutil2/xbutil-bash-completion" xrt-smi } # XRT NPU access maps its user heap with MAP_LOCKED; the default 8 MiB # RLIMIT_MEMLOCK makes device access fail. On systemd hosts pam_limits / # /etc/security/limits.conf are not consulted, so ship the manager # default as a drop-in. pkg_preinst() { dodir /etc/systemd/system.conf.d printf '[Manager]\nDefaultLimitMEMLOCK=infinity\n' \ > "${ED}/etc/systemd/system.conf.d/10-xrt.conf" \ || die "failed to install 10-xrt.conf drop-in" } pkg_postinst() { elog "Installed /etc/systemd/system.conf.d/10-xrt.conf" elog "(DefaultLimitMEMLOCK=infinity, required by XRT's MAP_LOCKED heap)." elog "Run 'systemctl daemon-reexec', then log out and back in." elog "System services using the NPU need their own LimitMEMLOCK=infinity." }