summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5686d97694a1d0777f88763534a739832387240a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Maintainer: cantosun99 <privat at cantosun dot de>
pkgname=llama.cpp-sycl
pkgver=v1.0.0
pkgrel=1
pkgdesc="llama.cpp with Intel Arc GPU acceleration via SYCL/oneAPI. Please read the README on Codeberg before use."
arch=('x86_64')
url="https://github.com/ggml-org/llama.cpp"
license=('MIT')
install="${pkgname}.install"
provides=('llama.cpp')
conflicts=(
    'llama.cpp'
    'llama.cpp-git'
    'llama.cpp-bin'
    'llama.cpp-cuda'
    'llama.cpp-cuda-git'
    'llama.cpp-cuda-essentials-only'
    'llama.cpp-vulkan'
    'llama.cpp-vulkan-git'
    'llama.cpp-vulkan-bin'
    'llama.cpp-vulkan-gemma4'
    'llama.cpp-cublas-git'
    'llama.cpp-hip'
    'llama.cpp-hip-gfx1151'
    'llama.cpp-hipblas-git'
    'llama.cpp-gfx1151'
    'llama.cpp-openvino'
    'llama.cpp-clblast'
    'llama.cpp-clblas-git'
    'llama.cpp-opencl'
    'llama.cpp-sycl-f16'
    'llama.cpp-sycl-f16-git'
    'llama.cpp-sycl-f32'
    'llama.cpp-sycl-f32-git'
    'llama.cpp-bin-noavx'
    'intel-oneapi-toolkit'
    'intel-oneapi-basekit-2025'
)
depends=(
    'intel-compute-runtime'
    'level-zero-loader'
    'level-zero-headers'
    'gcc-libs'
    'intel-deep-learning-essentials'
)
makedepends=(
    'git'
    'cmake'
    'make'
)
options=(!strip !buildflags)
source=(
    "llama.cpp-${pkgver}.tar.gz::https://github.com/ggml-org/llama.cpp/archive/refs/tags/${pkgver}.tar.gz"
)
sha256sums=('3f5f750e36326aea4d65c7623e7d597a33e395d65f4d76e5e0532171f252532b')

prepare() {
    # GitHub tarballs extract to <repo>-<sanitized ref>, and the leading 'v' is
    # stripped (tag v0.7.0 -> llama.cpp-0.7.0, tag b11707 -> llama.cpp-b11707),
    # so the directory name does not always match pkgver. Symlink whatever was
    # extracted to a stable name that build()/package() can use.
    local extracted
    extracted="$(find . -mindepth 1 -maxdepth 1 -type d -name 'llama.cpp-*' | head -n1)"
    if [[ -z "${extracted}" ]]; then
        echo "Error: no extracted llama.cpp-* directory found in ${srcdir}" >&2
        return 1
    fi
    ln -snf "$(basename "${extracted}")" llama.cpp
}

build() {
    # Show warning during makepkg build time
    echo "============================================================================"
    echo " NOTE: The installer may output a few error messages during installation."
    echo " This is because Intel intended the oneAPI packages for Windows and Ubuntu,"
    echo " not Arch Linux. Please just let it run and ignore these non-fatal errors."
    echo "============================================================================"

    # Source oneAPI environment (provided by intel-deep-learning-essentials)
    set +u
    source /opt/intel/oneapi/setvars.sh --force
    set -u

    cd "${srcdir}/llama.cpp"
    cmake -B build \
        -DGGML_SYCL=ON \
        -DGGML_SYCL_F16=ON \
        -DCMAKE_C_COMPILER=icx \
        -DCMAKE_CXX_COMPILER=icpx \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/opt/llama.cpp-sycl \
        -DCMAKE_INSTALL_RPATH=/opt/llama.cpp-sycl/lib
    cmake --build build --config Release -j$(nproc)
}

package() {
    # Install llama.cpp to /opt/llama.cpp-sycl
    DESTDIR="${pkgdir}" cmake --install "${srcdir}/llama.cpp/build"

    # Symlink binaries into /usr/bin so they are accessible system-wide
    mkdir -p "${pkgdir}/usr/bin"
    for bin in "${pkgdir}/opt/llama.cpp-sycl/bin/"*; do
        ln -s "/opt/llama.cpp-sycl/bin/$(basename "$bin")" "${pkgdir}/usr/bin/$(basename "$bin")"
    done

    # Install license
    install -Dm644 "${srcdir}/llama.cpp/LICENSE" \
        "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}