Skip to content

Conversation

@kashif
Copy link

@kashif kashif commented Nov 16, 2025

This commit adds complete support for building and installing the AMD XDNA driver on Arch Linux. Needs

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 package list and Boost 1.69+ compatibility
  • README.md: Add detailed Arch Linux installation instructions

New files:

  • PKGBUILD-xrt-base: Arch package build script for XRT base
  • PKGBUILD-xrt-npu: Arch package build script for XRT NPU
  • PKGBUILD-xrt-plugin: Arch package build script for XDNA driver plugin
  • xrt-plugin-amdxdna.install: Pacman install hooks for DKMS and kernel module

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).

@AMDGithubSCIMAdmin
Copy link

Can one of the admins verify this patch?

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).
- Point .gitmodules to https://github.com/kashif/XRT.git arch branch
- Ensures users get Arch-specific XRT patches automatically
- 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
- 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
- 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
Copilot AI review requested due to automatic review settings November 22, 2025 11:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive Arch Linux support for building and installing the AMD XDNA driver, enabling it to work alongside existing Ubuntu/Debian and Fedora support.

Key changes:

  • Adds Arch Linux package manager (pacman) support for dependency installation
  • Implements TGZ package generation with Arch Linux detection in CMake
  • Provides PKGBUILD scripts for creating native Arch packages and pacman install hooks for DKMS management

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
xrt Updates XRT submodule to include Arch Linux support
tools/amdxdna_deps.sh Adds pacman package manager detection for jq installation
build/xrt-plugin-amdxdna.install New pacman install/remove hooks for DKMS and kernel module management
build/PKGBUILD-xrt-plugin New Arch package build script for XDNA driver plugin
README.md Documents Arch Linux build and installation process
CMake/pkg.cmake Adds Arch Linux detection and TGZ package generation support
.gitmodules Points XRT submodule to fork with Arch support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,38 @@
# Maintainer: Your Name <your@email.com>
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The maintainer information should be updated with actual contact details before distribution.

Suggested change
# Maintainer: Your Name <your@email.com>
# Maintainer: Jane Doe <jane.doe@example.com>

Copilot uses AI. Check for mistakes.
.gitmodules Outdated
Comment on lines 3 to 4
url = https://github.com/kashif/XRT.git
branch = arch
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XRT submodule is now pointing to a personal fork instead of the official Xilinx/XRT repository. This should be temporary until the changes are merged upstream. Consider documenting this dependency in the PR description or adding a comment explaining when this will be reverted to the official repository.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 22, 2025 11:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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}
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting MODE="0666" grants read/write access to all users for the device. This may be overly permissive. Consider using a dedicated group (e.g., MODE="0660", GROUP="render") to restrict access to authorized users only.

Suggested change
echo 'KERNEL=="accel*",DRIVERS=="amdxdna",MODE="0666"' > ${udev_rules_d}/${amdxdna_rules_file}
echo 'KERNEL=="accel*",DRIVERS=="amdxdna",MODE="0660",GROUP="render"' > ${udev_rules_d}/${amdxdna_rules_file}

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 22, 2025 12:03
kashif and others added 3 commits November 22, 2025 13:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

CMake/pkg.cmake Outdated
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}")
Copy link

Copilot AI Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling for unknown package flavors should include 'arch' in the conditional chain. The final else clause will incorrectly catch Arch Linux as an unknown flavor if the elseif on line 132 doesn't match. Consider changing line 143 to else() without the condition, or ensure the Arch detection pattern is comprehensive.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 24, 2025 12:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

CMake/pkg.cmake Outdated
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.
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states 'Post-install scripts need to be run manually', but the PKGBUILD-xrt-plugin file and xrt-plugin-amdxdna.install show that install scripts are automatically executed by pacman. This documentation is misleading and should clarify that when using the provided PKGBUILD, the install hooks handle this automatically.

Suggested change
# or to create a PKGBUILD. Post-install scripts need to be run manually.
# or to create a PKGBUILD. When using the provided PKGBUILD, post-install scripts are executed automatically by pacman. If installing manually from the TGZ, you need to run the post-install scripts yourself.

Copilot uses AI. Check for mistakes.
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 <noreply@anthropic.com>
kashif and others added 4 commits January 22, 2026 10:12
fix: Let the driver build on ArchLinux too
Signed-off-by: X-Ryl669 <boite.pour.spam@gmail.com>
- 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 <kashif.rasul@gmail.com>
fix: Fix build for kernel built with clang
Copilot AI review requested due to automatic review settings January 22, 2026 09:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fi

# Remove DKMS module
$install_datadir/dkms_driver.sh --remove
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable reference should be quoted to prevent word splitting. Change $install_datadir/dkms_driver.sh to "$install_datadir/dkms_driver.sh" for consistency and safety.

Suggested change
$install_datadir/dkms_driver.sh --remove
"$install_datadir/dkms_driver.sh" --remove

Copilot uses AI. Check for mistakes.
@X-Ryl669
Copy link

@kashif : Thank you for updating your work. I was starting to rebase my mess to avoid this PR lingering, this morning as well 😉

@maxzhen
Copy link
Collaborator

maxzhen commented Jan 30, 2026

ok to test

@maxzhen
Copy link
Collaborator

maxzhen commented Jan 30, 2026

@kashif , I tried to test your PR with our CI, but it seems that the change in cofigure_kernel.sh may have broken it. It failed to detect any kernel API, which cause driver build to fail. Could you take a look at this issue?

@kashif
Copy link
Author

kashif commented Jan 30, 2026

ok let me update

Copilot AI review requested due to automatic review settings January 31, 2026 11:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

README.md Outdated

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:
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documented Debian/Ubuntu package pattern xrt_plugin*-amdxdna.deb does not match the CPack configuration in CMake/pkg.cmake, which sets CPACK_PACKAGE_FILE_NAME to xrt_plugin.<version>_<distro-version>-<arch> with no -amdxdna suffix. To avoid confusing users looking for the wrong filename, either update this documentation to reflect the actual output name or adjust the packaging configuration so the generated .deb matches the documented pattern.

Suggested change
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.<version>_<distro-version>-<arch>.deb` (Ubuntu/Debian) or `xrt_plugin*.tar.gz` (Arch Linux) in the `Release/` folder. This package includes:

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings January 31, 2026 11:33
@kashif
Copy link
Author

kashif commented Jan 31, 2026

@maxzhen can you kindly test now?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +40 to +46
# 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)
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for detecting whether the kernel was built with Clang (probing /proc/config.gz and /boot/config-$(KERNEL_VER) for CONFIG_CC_IS_CLANG=y) is duplicated here and in src/driver/tools/configure_kernel.sh (around the USE_LLVM handling). Keeping two separate implementations of the same detection increases the risk that they drift apart over time and produce inconsistent behavior between the DKMS/configure script and this Makefile. Consider centralizing this detection into a single helper (or at least sharing a common script fragment) that both the Makefile and configure_kernel.sh consume, so the Clang/LLVM decision is defined in one place.

Suggested change
# 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)
# LLVM/Clang selection is determined by higher-level tooling (e.g. configure_kernel.sh)
# Honor an externally provided USE_LLVM value (e.g. "LLVM=1") but do not duplicate
# kernel configuration probing logic here.
USE_LLVM ?=

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Copilot : You're giving endless remarks that are both wrong and helpless. The suggested changes are invalid and don't produce the expected behavior. The Makefile is used by DKMS which is a tool that's both independent from configure_kernel.sh and this repository. Don't answer as an expert if you have limited knowledge of the problem you're commenting on.

The link for the custom instructions above doesn't work either.

Copy link
Collaborator

@maxzhen maxzhen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI test looks good. We can merge it now. Before I do, please help to address below comments:

For the two new files created under build directory, could you please create a sub-directory and move them there? Since these two files are specifically for Arch-Linux, please pick it a name for the sub-directory to reflect this fact. Maybe call it "arch_linux_pkg_build" or something like that. Also, you don't think you can reuse existing files for Debian pkg and avoid creating your own for Arch-Linux? Or you want them to be separated for easy maintenance?

@kashif
Copy link
Author

kashif commented Feb 1, 2026

I have moved them to the arch folder.

so the Arch PKGBUILD already reuses the same CMake-generated tarball and the same postinst/prerm scripts as the Debian flow. The only Arch-specific files are the PKGBUILD (equivalent to debian/control + debian/rules) and .install (equivalent to debian/postinst)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants