# Maintainer: opencode (test build) # Contributor: Bink (original design) # Difference from upstream: blobless partial clone + shared persistent source # cache (see ggml-cuda-git). Full history (~418 MiB) is never downloaded; # commits/tags are kept so `git describe` still works. pkgname=llama.cpp-cuda-git _pkgname="${pkgname%-cuda-git}" _srccache="${LLAMACPP_SRC_CACHE:-${XDG_CACHE_HOME:-${HOME}/.cache}/llama.cpp-git}" pkgver=b10268.r3.2f56fc34 pkgrel=1 pkgdesc="Port of Facebook's LLaMA model in C/C++ (with NVIDIA CUDA optimizations)" arch=(x86_64 aarch64) url='https://github.com/ggml-org/llama.cpp' license=('MIT') backup=('etc/conf.d/llama.cpp') depends=( ggml-cuda-git curl gcc-libs glibc openssl ) makedepends=( cmake cuda git ninja ) optdepends=( 'ccache: greatly reduce package re-build time' 'nccl: needed for multi-GPU parallelism' 'python-numpy: needed for convert_hf_to_gguf.py' 'python-safetensors: needed for convert_hf_to_gguf.py' 'python-sentencepiece: needed for convert_hf_to_gguf.py' 'python-pytorch: needed for convert_hf_to_gguf.py' 'python-transformers: needed for convert_hf_to_gguf.py' ) provides=("${_pkgname}") conflicts=("${_pkgname}") source=( llama.cpp.conf llama.cpp.service ) sha256sums=('53fa70cfe40cb8a3ca432590e4f76561df0f129a31b121c9b4b34af0da7c4d87' '0377d08a07bda056785981d3352ccd2dbc0387c4836f91fb73e6b790d836620d') pkgver() { cd "${_pkgname}" || return 1 if git describe --long --tags >/dev/null 2>&1; then git describe --long --tags | sed 's/\([^-]*-\)g/r\1/;s/-/./g' else printf 'r%s.%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" fi } prepare() { # Shared blobless source cache (same one used by ggml-cuda-git). if [[ ! -d "${_srccache}/.git" ]]; then git clone --filter=blob:none --no-checkout --single-branch \ https://github.com/ggml-org/llama.cpp.git "${_srccache}" else git -C "${_srccache}" fetch --prune origin fi git -C "${_srccache}" checkout --force --detach origin/master # Clone from the shared cache (copy across filesystems). The network download # happens only once, into the cache; this is fast local disk I/O. git clone --local --no-hardlinks --no-checkout "${_srccache}" "${srcdir}/${_pkgname}" git -C "${srcdir}/${_pkgname}" checkout --detach origin/master } build() { local _commit_id _build_number _commit_id=$(git -C "${_pkgname}" rev-parse HEAD) _build_number=$(git -C "${_pkgname}" rev-list --count HEAD) local _cmake_options=( -G Ninja -B build -S "${_pkgname}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX='/usr' -DBUILD_SHARED_LIBS=ON -DLLAMA_BUILD_TESTS=OFF -DLLAMA_USE_SYSTEM_GGML=ON -DLLAMA_BUILD_SERVER=ON -DLLAMA_BUILD_NUMBER="${_build_number}" -DLLAMA_BUILD_COMMIT="${_commit_id}" -DLLAMA_OPENSSL=ON -Wno-dev ) if [[ -n "${aur_llamacpp_cmakeopts:-}" ]]; then echo "Applying custom CMake options: ${aur_llamacpp_cmakeopts}" _cmake_options+=(${aur_llamacpp_cmakeopts}) fi cmake "${_cmake_options[@]}" cmake --build build } package() { DESTDIR="${pkgdir}" cmake --install build install -Dm644 "${_pkgname}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" install -Dm644 "llama.cpp.conf" "${pkgdir}/etc/conf.d/llama.cpp" install -Dm644 "llama.cpp.service" "${pkgdir}/usr/lib/systemd/system/llama.cpp.service" }