Summary
/usr/share/cmake/XRT/xrt-targets.cmake installed from XRT 2.21.75 declares nine imported CMake targets:
XRT::xilinxopencl XRT::xilinxopencl_static
XRT::xrt++ XRT::xrt++_static
XRT::xrt_coreutil XRT::xrt_coreutil_static
XRT::xrt_core XRT::xrt_core_static
XRT::pyxrt
Distro packagers (Arch extra/xrt 2.21.75-6, CachyOS cachyos-extra-znver4/xrt 2.21.75-6.1) ship only the three shared libs (libxrt_core.so, libxrt_coreutil.so, libxrt++.so) without the static archives, OpenCL frontend, or python binding — but the installed xrt-targets.cmake still lists the absent targets, referencing files that don't exist on disk.
Result: any downstream call to find_package(XRT) (including QUIET) hits a hard cmake error:
CMake Error at /usr/share/cmake/XRT/xrt-targets.cmake:118 (message):
The imported target "XRT::xilinxopencl_static" references the file
"/usr/lib/libxrt_xilinxopencl_static.a"
but this file does not exist. Possible reasons include:
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/share/cmake/XRT/xrt-targets.cmake"
but not all the files it references.
Blocks the canonical chain on Strix Halo + Arch / CachyOS:
nod-ai/iree-amd-aie
Xilinx/mlir-aie
ROCm/hsa-runtime (when built against system XRT)
- any consumer using find_package(XRT) against a distro-packaged XRT
Reproduction
# Arch / CachyOS
sudo pacman -S xrt xrt-plugin-amdxdna
cat > /tmp/repro.cmake <<EOC
cmake_minimum_required(VERSION 3.20)
project(repro)
find_package(XRT REQUIRED)
EOC
cmake -S . -B /tmp/repro-build -P /tmp/repro.cmake 2>&1
Root cause (I think)
xrt-targets.cmake is auto-generated by CMake's install(EXPORT xrt-targets) against the full build-component set. When a packager builds with -DXRT_ENABLE_STATIC_BUILD=OFF, -DXRT_ENABLE_OPENCL=OFF, etc., the exported xrt-targets.cmake still contains the static/opencl/pyxrt target entries because the export set isn't component-gated.
Requested fix
Gate the install(EXPORT xrt-targets) entries by component, so that (a) a shared-only build generates a cmake file declaring only shared targets, and (b) -DXRT_BUILD_STATIC=OFF / -DXRT_ENABLE_OPENCL=OFF / -DXRT_ENABLE_PYTHON=OFF fully remove their targets from the generated export file.
Alternatively: emit if(EXISTS "${_IMPORT_PREFIX}/lib/libxrt_xilinxopencl.a") guards around each add_library(... IMPORTED) so a consumer with a partial install degrades to a warning instead of a hard error.
Prior history
Related closed issue #4504 (2020) touched adjacent "duplicate opencl" error. This is a different failure mode — same area of the export-set generation code.
Workaround we're using
Replace xrt-targets.cmake with a minimal hand-written version that only declares the three shared targets actually installed. Automated via pacman PostTransaction hook so it survives pacman -Syu. Script: https://github.com/bong-water-water-bong/halo-ai-rs/blob/main/strixhalo/bin/halo-xrt-cmake-patch.sh
Happy to submit a PKGBUILD-layer fix on the Arch side if upstream can't prioritize; ideally this lands upstream so every distro packager benefits.
Summary
/usr/share/cmake/XRT/xrt-targets.cmakeinstalled from XRT 2.21.75 declares nine imported CMake targets:Distro packagers (Arch
extra/xrt 2.21.75-6, CachyOScachyos-extra-znver4/xrt 2.21.75-6.1) ship only the three shared libs (libxrt_core.so,libxrt_coreutil.so,libxrt++.so) without the static archives, OpenCL frontend, or python binding — but the installedxrt-targets.cmakestill lists the absent targets, referencing files that don't exist on disk.Result: any downstream call to
find_package(XRT)(includingQUIET) hits a hard cmake error:Blocks the canonical chain on Strix Halo + Arch / CachyOS:
nod-ai/iree-amd-aieXilinx/mlir-aieROCm/hsa-runtime(when built against system XRT)Reproduction
Root cause (I think)
xrt-targets.cmakeis auto-generated by CMake'sinstall(EXPORT xrt-targets)against the full build-component set. When a packager builds with-DXRT_ENABLE_STATIC_BUILD=OFF,-DXRT_ENABLE_OPENCL=OFF, etc., the exportedxrt-targets.cmakestill contains the static/opencl/pyxrt target entries because the export set isn't component-gated.Requested fix
Gate the
install(EXPORT xrt-targets)entries by component, so that (a) a shared-only build generates a cmake file declaring only shared targets, and (b)-DXRT_BUILD_STATIC=OFF/-DXRT_ENABLE_OPENCL=OFF/-DXRT_ENABLE_PYTHON=OFFfully remove their targets from the generated export file.Alternatively: emit
if(EXISTS "${_IMPORT_PREFIX}/lib/libxrt_xilinxopencl.a")guards around eachadd_library(... IMPORTED)so a consumer with a partial install degrades to a warning instead of a hard error.Prior history
Related closed issue #4504 (2020) touched adjacent "duplicate opencl" error. This is a different failure mode — same area of the export-set generation code.
Workaround we're using
Replace
xrt-targets.cmakewith a minimal hand-written version that only declares the three shared targets actually installed. Automated via pacman PostTransaction hook so it survivespacman -Syu. Script: https://github.com/bong-water-water-bong/halo-ai-rs/blob/main/strixhalo/bin/halo-xrt-cmake-patch.shHappy to submit a PKGBUILD-layer fix on the Arch side if upstream can't prioritize; ideally this lands upstream so every distro packager benefits.