From 24164d675bc7ae5387d92b19bfcd0677a7c4d785 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sat, 15 Nov 2025 17:33:46 +0100 Subject: [PATCH 01/22] Add Arch Linux support for xdna-driver This commit adds complete support for building and installing the AMD XDNA driver on Arch Linux. Changes: - tools/amdxdna_deps.sh: Add pacman support for jq installation - CMake/pkg.cmake: Add Arch Linux detection and TGZ package generation - xrt submodule: Updated with Arch Linux support (packaging + dependencies) - README.md: Add detailed Arch Linux installation instructions New files: - PKGBUILD-xrt-plugin: Arch package build script for XDNA driver plugin - xrt-plugin-amdxdna.install: Pacman install hooks for DKMS and kernel module XRT-specific packaging: - XRT PKGBUILDs moved to xrt/packaging/arch/ (maintained in XRT submodule) - See xrt/packaging/arch/README.md for XRT packaging instructions The build system now properly detects Arch Linux and generates .tar.gz packages that can be repackaged into proper Arch packages (.pkg.tar.zst) using the provided PKGBUILDs. Tested on Arch Linux with kernel 6.17.8 and AMD Ryzen AI 9 HX 370 (NPU Strix). --- CMake/pkg.cmake | 17 +++++++-- PKGBUILD-xrt-plugin | 26 ++++++++++++++ README.md | 51 +++++++++++++++++++++++++-- tools/amdxdna_deps.sh | 2 ++ xrt | 2 +- xrt-plugin-amdxdna.install | 70 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 PKGBUILD-xrt-plugin create mode 100644 xrt-plugin-amdxdna.install diff --git a/CMake/pkg.cmake b/CMake/pkg.cmake index 747973a9..c53fbdc3 100644 --- a/CMake/pkg.cmake +++ b/CMake/pkg.cmake @@ -134,7 +134,7 @@ if("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "debian") set(CPACK_DEB_COMPONENT_INSTALL ON) set(CPACK_DEBIAN_PACKAGE_DEPENDS "xrt-base (>= ${XDNA_CPACK_XRT_BASE_VERSION}), xrt-base (<< ${XDNA_CPACK_XRT_BASE_NEXT_VERSION})") if(NOT SKIP_KMOD) - set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/package/postinst" + set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/package/postinst" "${CMAKE_CURRENT_BINARY_DIR}/package/prerm") endif() elseif("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "fedora") @@ -142,8 +142,19 @@ elseif("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "fedora") set(CPACK_RPM_COMPONENT_INSTALL ON) set(CPACK_RPM_PACKAGE_REQUIRES "xrt-base >= ${XDNA_CPACK_XRT_BASE_VERSION}, xrt-base < ${XDNA_CPACK_XRT_BASE_NEXT_VERSION}") if(NOT SKIP_KMOD) - set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/package/postinst") - set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/package/prerm") + set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/package/postinst") + set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/package/prerm") + endif() +elseif("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "arch") + set(CPACK_GENERATOR "TGZ") + # For Arch Linux, we generate a tarball that can be used for manual installation + # or to create a PKGBUILD. Post-install scripts need to be run manually. + set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) + message(STATUS "Arch Linux detected - generating TGZ package") + if(NOT SKIP_KMOD) + message(STATUS "Post-install script: ${CMAKE_CURRENT_BINARY_DIR}/package/postinst") + message(STATUS "Pre-remove script: ${CMAKE_CURRENT_BINARY_DIR}/package/prerm") + message(STATUS "Note: For Arch Linux, you'll need to run these scripts manually or create a PKGBUILD") endif() else("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "debian") message(FATAL_ERROR "Unknown Linux package flavor: ${XDNA_CPACK_LINUX_PKG_FLAVOR}") diff --git a/PKGBUILD-xrt-plugin b/PKGBUILD-xrt-plugin new file mode 100644 index 00000000..ac77c515 --- /dev/null +++ b/PKGBUILD-xrt-plugin @@ -0,0 +1,26 @@ +# Maintainer: Your Name +pkgname=xrt-plugin-amdxdna +pkgver=2.21.0 +pkgrel=1 +pkgdesc="AMD XDNA Driver plugin for Xilinx RunTime" +arch=('x86_64') +url="https://github.com/amd/xdna-driver" +license=('Apache-2.0') +depends=('xrt-base' 'xrt-npu' 'dkms' 'linux-headers') +provides=('xrt-plugin-amdxdna') +conflicts=('amdxdna-driver' 'amdxdna-driver-bin') +install=xrt-plugin-amdxdna.install + +package() { + cd "$srcdir" + + # Extract the tarball directly into the package directory + tar -xzf /home/kashif/Downloads/xdna-driver/build/Release/xrt_plugin.2.21.0_-x86_64-amdxdna.tar.gz -C "$pkgdir" + + # Copy the install scripts for reference (they'll be called from .install file) + mkdir -p "$pkgdir/opt/xilinx/xrt/share/amdxdna/package" + install -Dm755 /home/kashif/Downloads/xdna-driver/build/Release/package/postinst \ + "$pkgdir/opt/xilinx/xrt/share/amdxdna/package/postinst" + install -Dm755 /home/kashif/Downloads/xdna-driver/build/Release/package/prerm \ + "$pkgdir/opt/xilinx/xrt/share/amdxdna/package/prerm" +} diff --git a/README.md b/README.md index faa4d1bf..3424062a 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ cd exit ``` -### Steps to create release build DEB package: +### Steps to create release build DEB package (Ubuntu/Debian): ``` bash cd /build @@ -121,7 +121,54 @@ cd ../../build # To adapt according to your OS & version sudo apt reinstall ./Release/xrt_plugin.2.19.0_ubuntu22.04-x86_64-amdxdna.deb ``` -You will find `xrt_plugin\*-amdxdna.deb` in Release/ folder. This package includes: + +### Steps to create release build packages (Arch Linux): + +``` bash +cd + +# Install dependencies (requires sudo) +sudo ./tools/amdxdna_deps.sh + +# Get submodules +git submodule update --init --recursive + +# Build XRT +cd xrt/build +./build.sh -npu -opt + +# Build and install XRT packages using pacman +# PKGBUILDs are in xrt/packaging/arch/ +cd ../packaging/arch +makepkg -p PKGBUILD-xrt-base +sudo pacman -U xrt-base-*.pkg.tar.zst + +makepkg -p PKGBUILD-xrt-npu +sudo pacman -U xrt-npu-*.pkg.tar.zst + +# Build XDNA driver +cd ../../../build +./build.sh -release + +# Build and install XDNA plugin package +cd .. +makepkg -p PKGBUILD-xrt-plugin +sudo pacman -U xrt-plugin-amdxdna-*.pkg.tar.zst + +# Configure memory limits (required for NPU access) +sudo bash -c 'echo "* soft memlock unlimited" >> /etc/security/limits.conf' +sudo bash -c 'echo "* hard memlock unlimited" >> /etc/security/limits.conf' + +# Log out and log back in (or reboot) for memory limit changes to take effect +``` + +**Note for Arch Linux users**: The build system generates `.tar.gz` packages which are repackaged into proper Arch packages (`.pkg.tar.zst`) using the provided PKGBUILDs: +- XRT packages: `xrt/packaging/arch/` (PKGBUILD-xrt-base, PKGBUILD-xrt-npu) +- XDNA driver: root directory (PKGBUILD-xrt-plugin) + +This ensures proper integration with pacman for installation, upgrades, and removal. + +You will find `xrt_plugin\*-amdxdna.deb` (Ubuntu/Debian) or `xrt_plugin*.tar.gz` (Arch Linux) in Release/ folder. This package includes: * The `.so` library files, which will be installed into `/opt/xilinx/xrt/lib` folder * The XDNA driver and DKMS script, which build, install and load `amdxdna.ko` driver when installing the .DEB package on target machine diff --git a/tools/amdxdna_deps.sh b/tools/amdxdna_deps.sh index 35dca97b..0178a19b 100755 --- a/tools/amdxdna_deps.sh +++ b/tools/amdxdna_deps.sh @@ -10,6 +10,8 @@ if [ -x "$(command -v apt-get)" ]; then apt-get install -y jq elif [ -x "$(command -v dnf)" ]; then dnf install -y jq +elif [ -x "$(command -v pacman)" ]; then + pacman -Syu --needed --noconfirm jq fi $SCRIPT_DIR/../xrt/src/runtime_src/tools/scripts/xrtdeps.sh diff --git a/xrt b/xrt index f848f6f0..0dd1c847 160000 --- a/xrt +++ b/xrt @@ -1 +1 @@ -Subproject commit f848f6f093a174bbbe82b8a9b7fe44ff91295661 +Subproject commit 0dd1c84777f00d8785d6c1e0efa15a29b72dd69b diff --git a/xrt-plugin-amdxdna.install b/xrt-plugin-amdxdna.install new file mode 100644 index 00000000..196b715f --- /dev/null +++ b/xrt-plugin-amdxdna.install @@ -0,0 +1,70 @@ +post_install() { + echo "Installing AMD XDNA driver via DKMS..." + + install_datadir=/opt/xilinx/xrt/share/amdxdna + udev_rules_d=/etc/udev/rules.d + amdxdna_rules_file=99-amdxdna.rules + dracut_conf_d=/etc/dracut.conf.d + dracut_conf_file=amdxdna.dracut.conf + + # On systems with dracut, exclude driver from initram + if [ -e ${dracut_conf_d} ]; then + if [ ! -f ${dracut_conf_d}/${dracut_conf_file} ]; then + touch ${dracut_conf_d}/${dracut_conf_file} + fi + echo "omit_drivers+=\" amdxdna \"" > ${dracut_conf_d}/${dracut_conf_file} + fi + + # Install DKMS module + echo "Installing amdxdna Linux kernel module via DKMS..." + $install_datadir/dkms_driver.sh --install + + # Setup udev rules + echo "Setting up udev rules..." + if [ ! -f ${udev_rules_d}/${amdxdna_rules_file} ]; then + touch ${udev_rules_d}/${amdxdna_rules_file} + fi + echo 'KERNEL=="accel*",DRIVERS=="amdxdna",MODE="0666"' > ${udev_rules_d}/${amdxdna_rules_file} + + # Load the kernel module + echo "Loading amdxdna kernel module..." + rmmod amdxdna > /dev/null 2>&1 || true + modprobe amdxdna + + echo "AMD XDNA driver installation complete!" + echo "You can test it with: source /opt/xilinx/xrt/setup.sh && xrt-smi validate" +} + +post_upgrade() { + post_install +} + +pre_remove() { + echo "Removing AMD XDNA driver..." + + install_datadir=/opt/xilinx/xrt/share/amdxdna + udev_rules_d=/etc/udev/rules.d + amdxdna_rules_file=99-amdxdna.rules + dracut_conf_d=/etc/dracut.conf.d + dracut_conf_file=amdxdna.dracut.conf + + # Unload kernel module + if lsmod | grep -q "amdxdna "; then + rmmod amdxdna + fi + + # Remove dracut config + if [ -f ${dracut_conf_d}/${dracut_conf_file} ]; then + rm -f ${dracut_conf_d}/${dracut_conf_file} + fi + + # Remove udev rules + if [ -f ${udev_rules_d}/${amdxdna_rules_file} ]; then + rm -f ${udev_rules_d}/${amdxdna_rules_file} + fi + + # Remove DKMS module + $install_datadir/dkms_driver.sh --remove + + echo "AMD XDNA driver removed!" +} From 126c1a51278ca5255afcbf2f00d5cd4be342b3f6 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sun, 16 Nov 2025 16:42:35 +0100 Subject: [PATCH 02/22] Update submodule to use kashif/XRT fork arch branch - Point .gitmodules to https://github.com/kashif/XRT.git arch branch - Ensures users get Arch-specific XRT patches automatically --- .gitmodules | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 9cf659f4..4c78f7f1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "xrt"] path = xrt - url = https://github.com/Xilinx/XRT.git + url = https://github.com/kashif/XRT.git + branch = arch From dd70faa4b3ede0fa2b1043c625d0f2a9f4bfeb45 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sun, 16 Nov 2025 16:56:04 +0100 Subject: [PATCH 03/22] Update paths to use build/arch instead of packaging/arch - Move Arch packaging to xrt/build/arch/ to match existing convention - XRT already has build/debian/, so build/arch/ is consistent - Update README.md with correct paths - Update xrt submodule reference --- README.md | 6 +++--- xrt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3424062a..9108bcfa 100644 --- a/README.md +++ b/README.md @@ -138,8 +138,8 @@ cd xrt/build ./build.sh -npu -opt # Build and install XRT packages using pacman -# PKGBUILDs are in xrt/packaging/arch/ -cd ../packaging/arch +# PKGBUILDs are in xrt/build/arch/ +cd arch makepkg -p PKGBUILD-xrt-base sudo pacman -U xrt-base-*.pkg.tar.zst @@ -163,7 +163,7 @@ sudo bash -c 'echo "* hard memlock unlimited" >> /etc/security/limits.conf' ``` **Note for Arch Linux users**: The build system generates `.tar.gz` packages which are repackaged into proper Arch packages (`.pkg.tar.zst`) using the provided PKGBUILDs: -- XRT packages: `xrt/packaging/arch/` (PKGBUILD-xrt-base, PKGBUILD-xrt-npu) +- XRT packages: `xrt/build/arch/` (PKGBUILD-xrt-base, PKGBUILD-xrt-npu) - XDNA driver: root directory (PKGBUILD-xrt-plugin) This ensures proper integration with pacman for installation, upgrades, and removal. diff --git a/xrt b/xrt index 0dd1c847..01acb68a 160000 --- a/xrt +++ b/xrt @@ -1 +1 @@ -Subproject commit 0dd1c84777f00d8785d6c1e0efa15a29b72dd69b +Subproject commit 01acb68acce82d57cfb82d03f35cd6981ac836e2 From 5aa2e92a791ba77a0c6c6b3b3bfafa3f5d84dd29 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sun, 16 Nov 2025 17:01:08 +0100 Subject: [PATCH 04/22] Remove hardcoded paths from PKGBUILD-xrt-plugin - Replace absolute paths with relative paths using XDNA_BUILD_DIR variable - Default to build/Release (relative path) - Allow customization via environment variable - Add error checking for missing tarballs - Makes PKGBUILD portable across different systems --- PKGBUILD-xrt-plugin | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/PKGBUILD-xrt-plugin b/PKGBUILD-xrt-plugin index ac77c515..d9f7ad9a 100644 --- a/PKGBUILD-xrt-plugin +++ b/PKGBUILD-xrt-plugin @@ -11,16 +11,28 @@ provides=('xrt-plugin-amdxdna') conflicts=('amdxdna-driver' 'amdxdna-driver-bin') install=xrt-plugin-amdxdna.install +# Set this to your xdna-driver build directory +: ${XDNA_BUILD_DIR:="build/Release"} + package() { cd "$srcdir" # Extract the tarball directly into the package directory - tar -xzf /home/kashif/Downloads/xdna-driver/build/Release/xrt_plugin.2.21.0_-x86_64-amdxdna.tar.gz -C "$pkgdir" + # The tarball should be at $XDNA_BUILD_DIR/xrt_plugin*.tar.gz + local tarball=$(ls ${XDNA_BUILD_DIR}/xrt_plugin*-amdxdna.tar.gz 2>/dev/null | head -1) + if [ -z "$tarball" ]; then + error "XDNA plugin tarball not found in ${XDNA_BUILD_DIR}" + error "Please build XDNA driver first: cd build && ./build.sh -release" + return 1 + fi + + msg2 "Extracting $tarball" + tar -xzf "$tarball" -C "$pkgdir" # Copy the install scripts for reference (they'll be called from .install file) mkdir -p "$pkgdir/opt/xilinx/xrt/share/amdxdna/package" - install -Dm755 /home/kashif/Downloads/xdna-driver/build/Release/package/postinst \ + install -Dm755 ${XDNA_BUILD_DIR}/package/postinst \ "$pkgdir/opt/xilinx/xrt/share/amdxdna/package/postinst" - install -Dm755 /home/kashif/Downloads/xdna-driver/build/Release/package/prerm \ + install -Dm755 ${XDNA_BUILD_DIR}/package/prerm \ "$pkgdir/opt/xilinx/xrt/share/amdxdna/package/prerm" } From d6fcf49e07a518100a58e33d6f07d42f4272aa44 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sun, 16 Nov 2025 17:20:02 +0100 Subject: [PATCH 05/22] Fix PKGBUILD-xrt-plugin path resolution using $startdir - Use $startdir to properly resolve paths when makepkg changes to $srcdir - Fixes tarball and install script paths - Update xrt submodule reference to include PKGBUILD fixes --- PKGBUILD-xrt-plugin | 10 +++++----- xrt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PKGBUILD-xrt-plugin b/PKGBUILD-xrt-plugin index d9f7ad9a..87666a41 100644 --- a/PKGBUILD-xrt-plugin +++ b/PKGBUILD-xrt-plugin @@ -11,15 +11,15 @@ provides=('xrt-plugin-amdxdna') conflicts=('amdxdna-driver' 'amdxdna-driver-bin') install=xrt-plugin-amdxdna.install -# Set this to your xdna-driver build directory +# Set this to your xdna-driver build directory (relative to PKGBUILD location) : ${XDNA_BUILD_DIR:="build/Release"} package() { cd "$srcdir" # Extract the tarball directly into the package directory - # The tarball should be at $XDNA_BUILD_DIR/xrt_plugin*.tar.gz - local tarball=$(ls ${XDNA_BUILD_DIR}/xrt_plugin*-amdxdna.tar.gz 2>/dev/null | head -1) + # The tarball should be at $startdir/$XDNA_BUILD_DIR/xrt_plugin*.tar.gz + local tarball=$(ls $startdir/${XDNA_BUILD_DIR}/xrt_plugin*-amdxdna.tar.gz 2>/dev/null | head -1) if [ -z "$tarball" ]; then error "XDNA plugin tarball not found in ${XDNA_BUILD_DIR}" error "Please build XDNA driver first: cd build && ./build.sh -release" @@ -31,8 +31,8 @@ package() { # Copy the install scripts for reference (they'll be called from .install file) mkdir -p "$pkgdir/opt/xilinx/xrt/share/amdxdna/package" - install -Dm755 ${XDNA_BUILD_DIR}/package/postinst \ + install -Dm755 $startdir/${XDNA_BUILD_DIR}/package/postinst \ "$pkgdir/opt/xilinx/xrt/share/amdxdna/package/postinst" - install -Dm755 ${XDNA_BUILD_DIR}/package/prerm \ + install -Dm755 $startdir/${XDNA_BUILD_DIR}/package/prerm \ "$pkgdir/opt/xilinx/xrt/share/amdxdna/package/prerm" } diff --git a/xrt b/xrt index 01acb68a..be99b58f 160000 --- a/xrt +++ b/xrt @@ -1 +1 @@ -Subproject commit 01acb68acce82d57cfb82d03f35cd6981ac836e2 +Subproject commit be99b58fa996aadab1b3b561b1c248ef172e4ad1 From 63480a42cc14537f8e2b1713e74576ef2bb79be4 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Tue, 18 Nov 2025 10:22:36 +0100 Subject: [PATCH 06/22] move to build/ dir --- README.md | 3 +-- PKGBUILD-xrt-plugin => build/PKGBUILD-xrt-plugin | 4 ++-- .../xrt-plugin-amdxdna.install | 0 3 files changed, 3 insertions(+), 4 deletions(-) rename PKGBUILD-xrt-plugin => build/PKGBUILD-xrt-plugin (91%) rename xrt-plugin-amdxdna.install => build/xrt-plugin-amdxdna.install (100%) diff --git a/README.md b/README.md index 9108bcfa..517b5baf 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,6 @@ cd ../../../build ./build.sh -release # Build and install XDNA plugin package -cd .. makepkg -p PKGBUILD-xrt-plugin sudo pacman -U xrt-plugin-amdxdna-*.pkg.tar.zst @@ -164,7 +163,7 @@ sudo bash -c 'echo "* hard memlock unlimited" >> /etc/security/limits.conf' **Note for Arch Linux users**: The build system generates `.tar.gz` packages which are repackaged into proper Arch packages (`.pkg.tar.zst`) using the provided PKGBUILDs: - XRT packages: `xrt/build/arch/` (PKGBUILD-xrt-base, PKGBUILD-xrt-npu) -- XDNA driver: root directory (PKGBUILD-xrt-plugin) +- XDNA driver: `build/` directory (PKGBUILD-xrt-plugin) This ensures proper integration with pacman for installation, upgrades, and removal. diff --git a/PKGBUILD-xrt-plugin b/build/PKGBUILD-xrt-plugin similarity index 91% rename from PKGBUILD-xrt-plugin rename to build/PKGBUILD-xrt-plugin index 87666a41..200f395c 100644 --- a/PKGBUILD-xrt-plugin +++ b/build/PKGBUILD-xrt-plugin @@ -11,8 +11,8 @@ provides=('xrt-plugin-amdxdna') conflicts=('amdxdna-driver' 'amdxdna-driver-bin') install=xrt-plugin-amdxdna.install -# Set this to your xdna-driver build directory (relative to PKGBUILD location) -: ${XDNA_BUILD_DIR:="build/Release"} +# Set this to your xdna-driver build output directory (relative to PKGBUILD location) +: ${XDNA_BUILD_DIR:="Release"} package() { cd "$srcdir" diff --git a/xrt-plugin-amdxdna.install b/build/xrt-plugin-amdxdna.install similarity index 100% rename from xrt-plugin-amdxdna.install rename to build/xrt-plugin-amdxdna.install From 16f0a4ae973170bf28e99b34aa32bc882647be15 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sat, 22 Nov 2025 12:32:16 +0100 Subject: [PATCH 07/22] update xrt --- xrt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrt b/xrt index be99b58f..288900e9 160000 --- a/xrt +++ b/xrt @@ -1 +1 @@ -Subproject commit be99b58fa996aadab1b3b561b1c248ef172e4ad1 +Subproject commit 288900e986663300b2a8d3ecaf82449213cc8702 From 88d87590f35ec5bc1a775709ea84527e3ad90ba0 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sat, 22 Nov 2025 12:41:15 +0100 Subject: [PATCH 08/22] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- build/xrt-plugin-amdxdna.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/xrt-plugin-amdxdna.install b/build/xrt-plugin-amdxdna.install index 196b715f..e8cfb669 100644 --- a/build/xrt-plugin-amdxdna.install +++ b/build/xrt-plugin-amdxdna.install @@ -7,7 +7,7 @@ post_install() { dracut_conf_d=/etc/dracut.conf.d dracut_conf_file=amdxdna.dracut.conf - # On systems with dracut, exclude driver from initram + # On systems with dracut, exclude driver from initramfs if [ -e ${dracut_conf_d} ]; then if [ ! -f ${dracut_conf_d}/${dracut_conf_file} ]; then touch ${dracut_conf_d}/${dracut_conf_file} From e3650e41f7e9f5b6280867bbe92ee3c29e08e952 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sat, 22 Nov 2025 12:41:52 +0100 Subject: [PATCH 09/22] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- build/xrt-plugin-amdxdna.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/xrt-plugin-amdxdna.install b/build/xrt-plugin-amdxdna.install index e8cfb669..4f3749f3 100644 --- a/build/xrt-plugin-amdxdna.install +++ b/build/xrt-plugin-amdxdna.install @@ -49,7 +49,7 @@ pre_remove() { dracut_conf_file=amdxdna.dracut.conf # Unload kernel module - if lsmod | grep -q "amdxdna "; then + if lsmod | grep -q "amdxdna"; then rmmod amdxdna fi From dfef9f3b943e5ff796fd314ec048a3708a590ca4 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sat, 22 Nov 2025 13:03:17 +0100 Subject: [PATCH 10/22] Update build/PKGBUILD-xrt-plugin Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- build/PKGBUILD-xrt-plugin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/PKGBUILD-xrt-plugin b/build/PKGBUILD-xrt-plugin index 200f395c..fd506f2a 100644 --- a/build/PKGBUILD-xrt-plugin +++ b/build/PKGBUILD-xrt-plugin @@ -19,7 +19,7 @@ package() { # Extract the tarball directly into the package directory # The tarball should be at $startdir/$XDNA_BUILD_DIR/xrt_plugin*.tar.gz - local tarball=$(ls $startdir/${XDNA_BUILD_DIR}/xrt_plugin*-amdxdna.tar.gz 2>/dev/null | head -1) + local tarballs=("$startdir/${XDNA_BUILD_DIR}"/xrt_plugin*-amdxdna.tar.gz) if [ -z "$tarball" ]; then error "XDNA plugin tarball not found in ${XDNA_BUILD_DIR}" error "Please build XDNA driver first: cd build && ./build.sh -release" From bfd2b64d749e03ce5c3df6e04dac411a58221d83 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sat, 22 Nov 2025 13:03:36 +0100 Subject: [PATCH 11/22] Update build/xrt-plugin-amdxdna.install Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- build/xrt-plugin-amdxdna.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/xrt-plugin-amdxdna.install b/build/xrt-plugin-amdxdna.install index 4f3749f3..900a45a9 100644 --- a/build/xrt-plugin-amdxdna.install +++ b/build/xrt-plugin-amdxdna.install @@ -12,7 +12,7 @@ post_install() { if [ ! -f ${dracut_conf_d}/${dracut_conf_file} ]; then touch ${dracut_conf_d}/${dracut_conf_file} fi - echo "omit_drivers+=\" amdxdna \"" > ${dracut_conf_d}/${dracut_conf_file} + grep -q '^omit_drivers\+=\" amdxdna \"' "${dracut_conf_d}/${dracut_conf_file}" || echo 'omit_drivers+=" amdxdna "' >> "${dracut_conf_d}/${dracut_conf_file}" fi # Install DKMS module From 4f80d4914e41afa56f72e051d9982991dc4fb3b7 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sat, 22 Nov 2025 13:03:56 +0100 Subject: [PATCH 12/22] Update build/xrt-plugin-amdxdna.install Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- build/xrt-plugin-amdxdna.install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/xrt-plugin-amdxdna.install b/build/xrt-plugin-amdxdna.install index 900a45a9..799b3467 100644 --- a/build/xrt-plugin-amdxdna.install +++ b/build/xrt-plugin-amdxdna.install @@ -24,7 +24,8 @@ post_install() { if [ ! -f ${udev_rules_d}/${amdxdna_rules_file} ]; then touch ${udev_rules_d}/${amdxdna_rules_file} fi - echo 'KERNEL=="accel*",DRIVERS=="amdxdna",MODE="0666"' > ${udev_rules_d}/${amdxdna_rules_file} + grep -q '^KERNEL=="accel\*",DRIVERS=="amdxdna",MODE="0666"$' ${udev_rules_d}/${amdxdna_rules_file} || \ + echo 'KERNEL=="accel*",DRIVERS=="amdxdna",MODE="0666"' >> ${udev_rules_d}/${amdxdna_rules_file} # Load the kernel module echo "Loading amdxdna kernel module..." From ea156e088a32bf47927b63295b7c18644f64fa80 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sat, 22 Nov 2025 13:04:28 +0100 Subject: [PATCH 13/22] Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 517b5baf..448a8e03 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ sudo bash -c 'echo "* hard memlock unlimited" >> /etc/security/limits.conf' This ensures proper integration with pacman for installation, upgrades, and removal. -You will find `xrt_plugin\*-amdxdna.deb` (Ubuntu/Debian) or `xrt_plugin*.tar.gz` (Arch Linux) in Release/ folder. This package includes: +You will find `xrt_plugin*-amdxdna.deb` (Ubuntu/Debian) or `xrt_plugin*.tar.gz` (Arch Linux) in Release/ folder. This package includes: * The `.so` library files, which will be installed into `/opt/xilinx/xrt/lib` folder * The XDNA driver and DKMS script, which build, install and load `amdxdna.ko` driver when installing the .DEB package on target machine From 8cf1ba47d6fec73f76cc6af50d8572a1bee69607 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Mon, 24 Nov 2025 13:09:47 +0100 Subject: [PATCH 14/22] Update build/PKGBUILD-xrt-plugin Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- build/PKGBUILD-xrt-plugin | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/PKGBUILD-xrt-plugin b/build/PKGBUILD-xrt-plugin index fd506f2a..0f107226 100644 --- a/build/PKGBUILD-xrt-plugin +++ b/build/PKGBUILD-xrt-plugin @@ -20,12 +20,13 @@ package() { # Extract the tarball directly into the package directory # The tarball should be at $startdir/$XDNA_BUILD_DIR/xrt_plugin*.tar.gz local tarballs=("$startdir/${XDNA_BUILD_DIR}"/xrt_plugin*-amdxdna.tar.gz) - if [ -z "$tarball" ]; then + if [ ${#tarballs[@]} -eq 0 ] || [ ! -f "${tarballs[0]}" ]; then error "XDNA plugin tarball not found in ${XDNA_BUILD_DIR}" error "Please build XDNA driver first: cd build && ./build.sh -release" return 1 fi + local tarball="${tarballs[0]}" msg2 "Extracting $tarball" tar -xzf "$tarball" -C "$pkgdir" From a666c05529868f26f96ab849517de34d76dae64f Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Fri, 28 Nov 2025 23:59:20 +0100 Subject: [PATCH 15/22] Switch XRT submodule to official Xilinx/XRT repo @ a07ada1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Arch Linux changes have been merged upstream, so we can now point to the official XRT repository instead of the fork. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .gitmodules | 3 +-- xrt | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 4c78f7f1..9cf659f4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,3 @@ [submodule "xrt"] path = xrt - url = https://github.com/kashif/XRT.git - branch = arch + url = https://github.com/Xilinx/XRT.git diff --git a/xrt b/xrt index 288900e9..a07ada1c 160000 --- a/xrt +++ b/xrt @@ -1 +1 @@ -Subproject commit 288900e986663300b2a8d3ecaf82449213cc8702 +Subproject commit a07ada1c2cb33b79d8d3a96efe853b2452e57711 From 3deb899914355baf00c88c8a1fe94cd70a6932ac Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sat, 29 Nov 2025 00:02:25 +0100 Subject: [PATCH 16/22] Fix CMake pkg.cmake: improve Arch comments and else() syntax Applied review suggestions from PR #866: - Clarify that PKGBUILD handles install hooks automatically via pacman - Fix incorrect else("condition") syntax to proper else() --- CMake/pkg.cmake | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMake/pkg.cmake b/CMake/pkg.cmake index a1002dd9..0ec12587 100644 --- a/CMake/pkg.cmake +++ b/CMake/pkg.cmake @@ -131,17 +131,18 @@ elseif("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "fedora") endif() elseif("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "arch") set(CPACK_GENERATOR "TGZ") - # For Arch Linux, we generate a tarball that can be used for manual installation - # or to create a PKGBUILD. Post-install scripts need to be run manually. + # For Arch Linux, we generate a tarball that can be repackaged into a proper + # Arch package using the provided PKGBUILD. When using the PKGBUILD, install + # hooks handle post-install/pre-remove automatically via pacman. set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) message(STATUS "Arch Linux detected - generating TGZ package") if(NOT SKIP_KMOD) message(STATUS "Post-install script: ${CMAKE_CURRENT_BINARY_DIR}/package/postinst") message(STATUS "Pre-remove script: ${CMAKE_CURRENT_BINARY_DIR}/package/prerm") - message(STATUS "Note: For Arch Linux, you'll need to run these scripts manually or create a PKGBUILD") + message(STATUS "Note: Use the provided PKGBUILD to create an Arch package with proper install hooks") endif() -else("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "debian") +else() message(FATAL_ERROR "Unknown Linux package flavor: ${XDNA_CPACK_LINUX_PKG_FLAVOR}") -endif("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "debian") +endif() include(CPack) From fb81b6645eabc1178c88d32812b9dbff3eef7f39 Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sat, 29 Nov 2025 00:07:10 +0100 Subject: [PATCH 17/22] Apply Copilot review suggestions from PR #866 - Use -d instead of -e for directory check in dracut config - Add existence check for dkms_driver.sh before execution - Add warning message if modprobe amdxdna fails - Change pacman -Syu to -S to avoid full system upgrade - Clarify PKGBUILD comment about $startdir --- build/PKGBUILD-xrt-plugin | 2 +- build/xrt-plugin-amdxdna.install | 10 +++++++--- tools/amdxdna_deps.sh | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/build/PKGBUILD-xrt-plugin b/build/PKGBUILD-xrt-plugin index 0f107226..f66e0c29 100644 --- a/build/PKGBUILD-xrt-plugin +++ b/build/PKGBUILD-xrt-plugin @@ -11,7 +11,7 @@ provides=('xrt-plugin-amdxdna') conflicts=('amdxdna-driver' 'amdxdna-driver-bin') install=xrt-plugin-amdxdna.install -# Set this to your xdna-driver build output directory (relative to PKGBUILD location) +# Set this to your xdna-driver build output directory (relative to $startdir, the PKGBUILD's directory) : ${XDNA_BUILD_DIR:="Release"} package() { diff --git a/build/xrt-plugin-amdxdna.install b/build/xrt-plugin-amdxdna.install index 799b3467..20bea020 100644 --- a/build/xrt-plugin-amdxdna.install +++ b/build/xrt-plugin-amdxdna.install @@ -8,7 +8,7 @@ post_install() { dracut_conf_file=amdxdna.dracut.conf # On systems with dracut, exclude driver from initramfs - if [ -e ${dracut_conf_d} ]; then + if [ -d ${dracut_conf_d} ]; then if [ ! -f ${dracut_conf_d}/${dracut_conf_file} ]; then touch ${dracut_conf_d}/${dracut_conf_file} fi @@ -17,7 +17,11 @@ post_install() { # Install DKMS module echo "Installing amdxdna Linux kernel module via DKMS..." - $install_datadir/dkms_driver.sh --install + if [ ! -x "$install_datadir/dkms_driver.sh" ]; then + echo "Error: $install_datadir/dkms_driver.sh not found or not executable." >&2 + return 1 + fi + "$install_datadir/dkms_driver.sh" --install # Setup udev rules echo "Setting up udev rules..." @@ -30,7 +34,7 @@ post_install() { # Load the kernel module echo "Loading amdxdna kernel module..." rmmod amdxdna > /dev/null 2>&1 || true - modprobe amdxdna + modprobe amdxdna || echo "Warning: Failed to load amdxdna module. Check dmesg for details." echo "AMD XDNA driver installation complete!" echo "You can test it with: source /opt/xilinx/xrt/setup.sh && xrt-smi validate" diff --git a/tools/amdxdna_deps.sh b/tools/amdxdna_deps.sh index 0178a19b..9560b8be 100755 --- a/tools/amdxdna_deps.sh +++ b/tools/amdxdna_deps.sh @@ -11,7 +11,7 @@ if [ -x "$(command -v apt-get)" ]; then elif [ -x "$(command -v dnf)" ]; then dnf install -y jq elif [ -x "$(command -v pacman)" ]; then - pacman -Syu --needed --noconfirm jq + pacman -S --needed --noconfirm jq fi $SCRIPT_DIR/../xrt/src/runtime_src/tools/scripts/xrtdeps.sh From 8d9c15d6f3ee4a89351ea160fb5476bac3fa38df Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Wed, 3 Dec 2025 09:37:39 +0100 Subject: [PATCH 18/22] fix merge --- CMake/pkg.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMake/pkg.cmake b/CMake/pkg.cmake index 168595e4..0ec12587 100644 --- a/CMake/pkg.cmake +++ b/CMake/pkg.cmake @@ -141,8 +141,6 @@ elseif("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "arch") message(STATUS "Pre-remove script: ${CMAKE_CURRENT_BINARY_DIR}/package/prerm") message(STATUS "Note: Use the provided PKGBUILD to create an Arch package with proper install hooks") endif() -elseif("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "debian") - message(WARNING "Unknown Linux package flavor: ${XDNA_CPACK_LINUX_PKG_FLAVOR}") else() message(FATAL_ERROR "Unknown Linux package flavor: ${XDNA_CPACK_LINUX_PKG_FLAVOR}") endif() From d76a44b5c621a870eee8775f168724acfd6a093b Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Wed, 3 Dec 2025 09:39:50 +0100 Subject: [PATCH 19/22] fix nullglob --- build/PKGBUILD-xrt-plugin | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/PKGBUILD-xrt-plugin b/build/PKGBUILD-xrt-plugin index f66e0c29..8d4084b2 100644 --- a/build/PKGBUILD-xrt-plugin +++ b/build/PKGBUILD-xrt-plugin @@ -19,7 +19,11 @@ package() { # Extract the tarball directly into the package directory # The tarball should be at $startdir/$XDNA_BUILD_DIR/xrt_plugin*.tar.gz + # Use nullglob to handle case where no files match the glob pattern + local _nullglob_set=$(shopt -p nullglob) + shopt -s nullglob local tarballs=("$startdir/${XDNA_BUILD_DIR}"/xrt_plugin*-amdxdna.tar.gz) + $_nullglob_set if [ ${#tarballs[@]} -eq 0 ] || [ ! -f "${tarballs[0]}" ]; then error "XDNA plugin tarball not found in ${XDNA_BUILD_DIR}" error "Please build XDNA driver first: cd build && ./build.sh -release" From 71dd5c67ebbb3234f62adffab60e9da21e048886 Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Fri, 5 Dec 2025 21:38:32 +0100 Subject: [PATCH 20/22] fix: Let the driver build on ArchLinux too Signed-off-by: X-Ryl669 --- CMake/pkg.cmake | 14 +++++++++----- src/driver/amdxdna/Makefile | 3 ++- src/driver/amdxdna/aie2_pci.c | 3 +-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CMake/pkg.cmake b/CMake/pkg.cmake index 0ec12587..967a7a56 100644 --- a/CMake/pkg.cmake +++ b/CMake/pkg.cmake @@ -28,11 +28,15 @@ execute_process( OUTPUT_VARIABLE XDNA_CPACK_LINUX_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ) -execute_process( - COMMAND bash -c "source /etc/os-release && echo \"\$ID \$ID_LIKE\"" - OUTPUT_VARIABLE XDNA_CPACK_LINUX_PKG_FLAVOR - OUTPUT_STRIP_TRAILING_WHITESPACE - ) +if (EXISTS "/etc/arch-release") + set(XDNA_CPACK_LINUX_PKG_FLAVOR "arch") +else() + execute_process( + COMMAND bash -c "source /etc/os-release && echo \"\$ID \$ID_LIKE\"" + OUTPUT_VARIABLE XDNA_CPACK_LINUX_PKG_FLAVOR + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() execute_process( COMMAND echo ${XRT_VERSION_STRING} COMMAND awk -F. "{print $1}" diff --git a/src/driver/amdxdna/Makefile b/src/driver/amdxdna/Makefile index caa0d670..1c1ee72c 100644 --- a/src/driver/amdxdna/Makefile +++ b/src/driver/amdxdna/Makefile @@ -41,6 +41,7 @@ endif XDNA_DRIVER_VERSION ?= 2.21.0 XDNA_DATE ?= $(shell date +%Y%m%d) XDNA_HASH ?= $(shell git rev-parse HEAD) +USE_LLVM ?= $(shell zgrep "CONFIG_CC_IS_CLANG" /proc/config.gz 1>/dev/null && echo -n "LLVM=1") ifndef MODULE_VER_STR MODULE_VER_STR := $(XDNA_DRIVER_VERSION)_$(XDNA_DATE),$(XDNA_HASH) @@ -49,7 +50,7 @@ endif DEFINES += -DMODULE_VER_STR='\"$(MODULE_VER_STR)\"' modules: - $(MAKE) -C $(KERNEL_SRC) M=$(SRC_DIR) CFLAGS_MODULE="$(DEFINES)" OFT_CONFIG_AMDXDNA_PCI=$(PCI) OFT_CONFIG_AMDXDNA_OF=$(OF) modules + $(MAKE) -C $(KERNEL_SRC) M=$(SRC_DIR) CFLAGS_MODULE="$(DEFINES)" OFT_CONFIG_AMDXDNA_PCI=$(PCI) OFT_CONFIG_AMDXDNA_OF=$(OF) $(USE_LLVM) modules modules_install: $(MAKE) -C $(KERNEL_SRC) M=$(SRC_DIR) modules_install diff --git a/src/driver/amdxdna/aie2_pci.c b/src/driver/amdxdna/aie2_pci.c index e527fd75..5f7ce0f2 100644 --- a/src/driver/amdxdna/aie2_pci.c +++ b/src/driver/amdxdna/aie2_pci.c @@ -1331,6 +1331,7 @@ static int aie2_get_array_async_error(struct amdxdna_dev *xdna, struct amdxdna_d static int aie2_get_array_hwctx(struct amdxdna_client *client, struct amdxdna_drm_get_array *args) { struct amdxdna_dev *xdna = client->xdna; + struct amdxdna_drm_hwctx_entry input = {}; struct amdxdna_drm_hwctx_entry *tmp; int ctx_limit, ctx_cnt, ret; u32 buf_size; @@ -1363,8 +1364,6 @@ static int aie2_get_array_hwctx(struct amdxdna_client *client, struct amdxdna_dr break; case DRM_AMDXDNA_HW_CONTEXT_BY_ID: - struct amdxdna_drm_hwctx_entry input = {}; - ret = amdxdna_drm_copy_array_from_user(args, &input, sizeof(input), 1); if (ret) goto exit; From 8e1a43ba345743affe2f9993e041ea5f1f04b12d Mon Sep 17 00:00:00 2001 From: Kashif Rasul Date: Sun, 14 Dec 2025 19:34:51 +0100 Subject: [PATCH 21/22] Apply Copilot review suggestions - PKGBUILD: Quote variable references to prevent word splitting - Makefile: Add fallback LLVM detection for /boot/config-* when /proc/config.gz doesn't exist, and check for =y specifically - pkg.cmake: Improve FATAL_ERROR message with supported distros and link to open issues for unsupported distributions Signed-off-by: Kashif Rasul --- CMake/pkg.cmake | 4 +++- build/PKGBUILD-xrt-plugin | 4 ++-- src/driver/amdxdna/Makefile | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CMake/pkg.cmake b/CMake/pkg.cmake index 967a7a56..b590c1f3 100644 --- a/CMake/pkg.cmake +++ b/CMake/pkg.cmake @@ -146,7 +146,9 @@ elseif("${XDNA_CPACK_LINUX_PKG_FLAVOR}" MATCHES "arch") message(STATUS "Note: Use the provided PKGBUILD to create an Arch package with proper install hooks") endif() else() - message(FATAL_ERROR "Unknown Linux package flavor: ${XDNA_CPACK_LINUX_PKG_FLAVOR}") + message(FATAL_ERROR "Unknown Linux package flavor: ${XDNA_CPACK_LINUX_PKG_FLAVOR}. " + "Supported distributions: Debian/Ubuntu (deb), Fedora/RHEL (rpm), Arch Linux (TGZ). " + "To add support for your distribution, please open an issue at https://github.com/amd/xdna-driver/issues") endif() include(CPack) diff --git a/build/PKGBUILD-xrt-plugin b/build/PKGBUILD-xrt-plugin index 8d4084b2..f9bf3ec4 100644 --- a/build/PKGBUILD-xrt-plugin +++ b/build/PKGBUILD-xrt-plugin @@ -36,8 +36,8 @@ package() { # Copy the install scripts for reference (they'll be called from .install file) mkdir -p "$pkgdir/opt/xilinx/xrt/share/amdxdna/package" - install -Dm755 $startdir/${XDNA_BUILD_DIR}/package/postinst \ + install -Dm755 "$startdir/${XDNA_BUILD_DIR}/package/postinst" \ "$pkgdir/opt/xilinx/xrt/share/amdxdna/package/postinst" - install -Dm755 $startdir/${XDNA_BUILD_DIR}/package/prerm \ + install -Dm755 "$startdir/${XDNA_BUILD_DIR}/package/prerm" \ "$pkgdir/opt/xilinx/xrt/share/amdxdna/package/prerm" } diff --git a/src/driver/amdxdna/Makefile b/src/driver/amdxdna/Makefile index 1c1ee72c..c534a58f 100644 --- a/src/driver/amdxdna/Makefile +++ b/src/driver/amdxdna/Makefile @@ -41,7 +41,13 @@ endif XDNA_DRIVER_VERSION ?= 2.21.0 XDNA_DATE ?= $(shell date +%Y%m%d) XDNA_HASH ?= $(shell git rev-parse HEAD) -USE_LLVM ?= $(shell zgrep "CONFIG_CC_IS_CLANG" /proc/config.gz 1>/dev/null && echo -n "LLVM=1") +# Detect if kernel was built with Clang - check /proc/config.gz first, then /boot/config-* +USE_LLVM ?= $(shell \ + if [ -e /proc/config.gz ]; then \ + zgrep -q "CONFIG_CC_IS_CLANG=y" /proc/config.gz 2>/dev/null && echo -n "LLVM=1"; \ + elif [ -e /boot/config-$(KERNEL_VER) ]; then \ + grep -q "CONFIG_CC_IS_CLANG=y" /boot/config-$(KERNEL_VER) 2>/dev/null && echo -n "LLVM=1"; \ + fi) ifndef MODULE_VER_STR MODULE_VER_STR := $(XDNA_DRIVER_VERSION)_$(XDNA_DATE),$(XDNA_HASH) From 81179fa591cdcfb28ad374f63fc85db156570a8a Mon Sep 17 00:00:00 2001 From: X-Ryl669 Date: Mon, 15 Dec 2025 07:38:27 +0100 Subject: [PATCH 22/22] fix: Fix build for kernel built with clang Signed-off-by: X-Ryl669 --- src/driver/tools/configure_kernel.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/driver/tools/configure_kernel.sh b/src/driver/tools/configure_kernel.sh index bf4b5083..b89b3f1a 100755 --- a/src/driver/tools/configure_kernel.sh +++ b/src/driver/tools/configure_kernel.sh @@ -41,6 +41,13 @@ try_compile() { tmpdir=$(mktemp -d /tmp/conftest-XXXXXX) conftest_c="$tmpdir/conftest.c" conftest_mk="$tmpdir/Makefile" + USE_LLVM="" + if [ -e /proc/config.gz ]; then + USE_LLVM=$(zgrep -q "CONFIG_CC_IS_CLANG=y" /proc/config.gz 2>/dev/null && echo -n "LLVM=1"); + elif [ -e /boot/config-$(KERNEL_VER) ]; then + USE_LLVM=$(grep -q "CONFIG_CC_IS_CLANG=y" /boot/config-$(KERNEL_VER) 2>/dev/null && echo -n "LLVM=1"); + fi + # Minimal Kbuild for an external module cat > "$conftest_mk" <> "$conftest_c" # Now build it like your real driver - if make -s -C "$KERNEL_SRC" M="$tmpdir" modules >/dev/null 2>&1; then + if make -s -C "$KERNEL_SRC" M="$tmpdir" modules "$USE_LLVM" >/dev/null 2>&1; then echo "#define $macro 1" >> "$OUT" echo ">>> + $macro: yes" >&2 else