amdxdna-git

LOW
maintainer geosam 0 votes scanned 2026-10-18 19:22:55.407248
View on AUR
Why flagged

Uploaded within the last 14 days with 2 or fewer community votes — little peer review so far.

Triggered rules

Low Few votes, recently uploaded zero_votes_recent

Uploaded within the last 14 days with 2 or fewer community votes — little peer review so far.

PKGBUILD

1# Maintainer: smesa
2# AMD XDNA NPU driver + XRT plugin (git/main)
3
4pkgname=amdxdna-git
5pkgver=$(git ls-remote https://github.com/amd/xdna-driver.git refs/heads/main 2>/dev/null | cut -f1 | cut -c1-8)
6pkgrel=1
7pkgdesc="AMD XDNA NPU driver (DKMS) and XRT plugin for Linux (git/main)"
8arch=('x86_64')
9url="https://github.com/amd/xdna-driver/"
10license=('Apache-2.0')
11options=(!strip !debug)
12
13provides=('amdxdna-driver' 'xrt-plugin-amdxdna' 'amdxdna')
14replaces=('amdxdna' 'amdxdna-driver' 'xrt-plugin-amdxdna' 'amdxdna-driver-bin')
15conflicts=('amdxdna')
16
17depends=('dkms' 'linux-headers')
18makedepends=(
19 base-devel boost cmake curl dkms elfutils gcc gdb git
20 json-glib libdrm libffi libjpeg-turbo libpng
21 libtiff libyaml lm_sensors ncurses ocl-icd opencl-headers
22 openssl pciutils perl pkgconf protobuf python python-pip
23 rapidjson strace jq
24)
25install=amdxdna.install
26
27_srcrepo='xdna-driver'
28source=("git+https://github.com/amd/xdna-driver.git#branch=main"
29 "fix-clang-sizeof-array-div.patch"
30)
31sha256sums=('SKIP' 'SKIP')
32
33prepare() {
34 local repo="${srcdir}/${_srcrepo}"
35 cd "$repo"
36
37 # git-lfs required for vtd submodule (may not be a pacman package)
38 command -v git-lfs >/dev/null || { error "git-lfs not found. Install: pacman -S git-lfs"; return 1; }
39
40 # Init submodules (use env vars for safe.directory to avoid --global)
41 export GIT_CONFIG_COUNT=1
42 export GIT_CONFIG_KEY_0=safe.directory
43 export GIT_CONFIG_VALUE_0='*'
44 git submodule update --init --recursive
45
46 # Apply Clang compat patch
47 if ! grep -qF "/(sizeof(*hipe))" "drivers/accel/amdxdna/aie4_ctx.c" 2>/dev/null; then
48 patch -p1 < "${srcdir}/fix-clang-sizeof-array-div.patch"
49 fi
50
51 # Detect Clang kernel
52 if grep -q "CONFIG_CC_IS_CLANG=y" \
53 /usr/lib/modules/$(uname -r)/build/include/config/auto.conf 2>/dev/null; then
54 export LLVM=1
55 msg "Kernel built with Clang — exporting LLVM=1"
56 fi
57}
58
59build() {
60 local repo="${srcdir}/${_srcrepo}"
61
62 # --- Build XRT (links against system boost) ---
63 msg2 "Building XRT..."
64 cd "${repo}/xrt/build"
65 bash ./build.sh -npu -opt -noctest
66
67 # --- Build XDNA driver + shim + firmware ---
68 cd "$repo"
69
70 # Sync firmware
71 if [ -f "tools/sync_from_whence.py" ] && [ -f "tools/WHENCE" ]; then
72 msg2 "Syncing NPU firmware..."
73 python3 tools/sync_from_whence.py firmware \
74 --whence tools/WHENCE \
75 --out amdxdna_bins/firmware \
76 --commit-file amdxdna_bins/firmware/.whence_commit \
77 || msg "WARNING: firmware sync failed"
78 fi
79
80 # CMake
81 local builddir="${repo}/Release"
82 mkdir -p "$builddir"
83 cd "$builddir"
84 cmake -DCMAKE_BUILD_TYPE=Release \
85 -DCMAKE_INSTALL_PREFIX=/opt/xilinx/xrt \
86 -DSKIP_KMOD=0 \
87 -DBUILD_VXDNA=1 \
88 "$repo"
89
90 make -j"$(nproc)" DESTDIR="$PWD" install
91 make package || msg "WARNING: make package failed"
92}
93
94package() {
95 local repo="${srcdir}/${_srcrepo}"
96 local builddir="${repo}/Release"
97 local xrt_built="${repo}/xrt/build/Release"
98 local share_dir="${builddir}/opt/xilinx/xrt/share/amdxdna"
99 local tarball="${builddir}/driver/amdxdna.tar.gz"
100 [ -f "$tarball" ] || tarball="${share_dir}/amdxdna.tar.gz"
101 [ -f "$tarball" ] || { error "amdxdna.tar.gz not found"; return 1; }
102
103 # XRT base (xrt-smi, libs — built against current system boost)
104 mkdir -p "$pkgdir/opt/xilinx/xrt"
105 cp -a "$xrt_built/opt/xilinx/xrt/." "$pkgdir/opt/xilinx/xrt/"
106
107 # XDNA plugin: shim libs + firmware + share data (overlays XRT)
108 local cpack
109 cpack=$(find "$builddir" -maxdepth 1 -name "xrt_plugin.*-${arch}-amdxdna.tar.gz" \
110 -printf '%T@ %p\n' 2>/dev/null | sort -rn | head -1 | cut -d' ' -f2-)
111 if [ -n "$cpack" ]; then
112 tar -xzf "$cpack" -C "$pkgdir"
113 else
114 cp -a "$builddir/opt" "$pkgdir/"
115 [ -d "$builddir/usr/lib/firmware" ] && cp -a "$builddir/usr/lib/firmware" "$pkgdir/usr/lib/"
116 fi
117
118 # DKMS source
119 local dkms_dir="$pkgdir/usr/src/amdxdna-${pkgver}"
120 install -Dm644 "${share_dir}/dkms.conf" "$dkms_dir/dkms.conf"
121 install -Dm755 "${share_dir}/configure_kernel.sh" "$dkms_dir/configure_kernel.sh"
122 tar -xzf "$tarball" -C "$dkms_dir"
123
124 # System config
125 install -Dm644 /dev/stdin "$pkgdir/etc/modules-load.d/amdxdna.conf" <<< "amdxdna"
126 install -Dm644 /dev/stdin "$pkgdir/etc/udev/rules.d/99-amdxdna.rules" \
127 <<< 'KERNEL=="accel*",DRIVERS=="amdxdna",MODE="0666"'
128 install -Dm644 /dev/stdin "$pkgdir/etc/security/limits.d/99-amdxdna.conf" \
129 <<< $'* soft memlock unlimited\n* hard memlock unlimited'
130}
131

Scan history

Scanned at (UTC)SeverityRules
2026-10-18 19:22:55 Low 1

Report a package

Reports go to the AURWatch maintainer (one person) and are read by hand. No login required.

0 / 4000
Your suggestion