diff --git a/.github/local/Makefile.local b/.github/local/Makefile.local index 10a62b7..8c153b7 100644 --- a/.github/local/Makefile.local +++ b/.github/local/Makefile.local @@ -2,38 +2,46 @@ SRC_DIR := src debuild: build -.PHONY: pre_build_dep -pre_build_dep: - sudo apt-get update - sudo apt-get install -y --no-install-recommends docker.io - .PHONY: main_build -main_build: build-qcom +main_build: build-midstream + +# ===== Radxa Q6A/Q8B (OpenCL GPU, mainline kernel) ===== +PKG_MIDSTREAM := llama.cpp-qcom-midstream +BUILD_MIDSTREAM := $(SRC_DIR)/build-midstream-cross +INSTALL_MIDSTREAM := $(SRC_DIR)/install-midstream-cross +OPENCL_TARBALL := qcom-adreno_1.838.3_qcm6490.tar.gz +OPENCL_URL := https://softwarecenter.qualcomm.com/nexus/generic/software/chip/qualcomm_linux-spf-1-0/qualcomm-linux-spf-1-0_test_device_public/r1.0_00114.0/le-qclinux-1-0-r1/apps_proc/prebuilt_HY22/qcom-adreno/251215/$(OPENCL_TARBALL) +OPENCL_DIR := _opencl -# ===== Qualcomm Snapdragon (Hexagon DSP) ===== -PKG_QCOM := llama.cpp-qcom -BUILD_QCOM := $(SRC_DIR)/build-qcom -INSTALL_QCOM := $(SRC_DIR)/install-qcom -DOCKER_QCOM := ghcr.io/snapdragon-toolchain/arm64-linux:v0.1 +$(OPENCL_TARBALL): + wget -q --tries=5 --timeout=60 --retry-connrefused \ + "$(OPENCL_URL)" -O $@.tmp + mv $@.tmp $@ -.PHONY: build-qcom -build-qcom: - cp $(SRC_DIR)/docs/backend/snapdragon/CMakeUserPresets.json $(SRC_DIR)/ - sed -i 's/"version": 5/"version": 4/' $(SRC_DIR)/CMakeUserPresets.json - # Create container and copy source (docker cp avoids Docker-in-Docker volume mount issue) - docker create --name qcom-build --platform linux/amd64 $(DOCKER_QCOM) \ - /bin/bash -c ' \ - set -euo pipefail; \ - cd /workspace; \ - cmake --preset arm64-linux-snapdragon-release -B build-qcom; \ - cmake --build build-qcom -j $$(nproc); \ - cmake --install build-qcom --prefix install-qcom \ - ' - docker cp $(SRC_DIR)/. qcom-build:/workspace/ - docker start -a qcom-build - rm -rf $(INSTALL_QCOM) - docker cp qcom-build:/workspace/install-qcom/. $(INSTALL_QCOM)/ - docker rm qcom-build - rm -rf $(PKG_QCOM) - mkdir -p $(PKG_QCOM)/usr - cp -a $(INSTALL_QCOM)/* $(PKG_QCOM)/usr/ +.PHONY: build-midstream +build-midstream: $(OPENCL_TARBALL) + rm -rf $(OPENCL_DIR) + mkdir -p $(OPENCL_DIR) + tar xzf "$(OPENCL_TARBALL)" -C $(OPENCL_DIR) + ln -sf usr/lib/libOpenCL.so.1 $(OPENCL_DIR)/libOpenCL.so + cmake -S $(SRC_DIR) -B $(BUILD_MIDSTREAM) -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_SYSTEM_NAME=Linux \ + -DCMAKE_SYSTEM_PROCESSOR=aarch64 \ + -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \ + -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \ + -DBUILD_SHARED_LIBS=OFF \ + -DGGML_NATIVE=OFF \ + -DGGML_OPENCL=ON \ + -DGGML_OPENCL_USE_ADRENO_KERNELS=ON \ + -DGGML_OPENCL_EMBED_KERNELS=ON \ + -DGGML_HEXAGON=OFF \ + -DGGML_OPENCL_TARGET_VERSION=200 \ + -DOpenCL_LIBRARY=$(abspath $(OPENCL_DIR))/libOpenCL.so \ + -DOpenCL_INCLUDE_DIR=/usr/include + cmake --build $(BUILD_MIDSTREAM) -j $$(nproc) + rm -rf $(INSTALL_MIDSTREAM) + cmake --install $(BUILD_MIDSTREAM) --prefix $(abspath $(INSTALL_MIDSTREAM)) + rm -rf $(PKG_MIDSTREAM) + mkdir -p $(PKG_MIDSTREAM)/usr + cp -a $(INSTALL_MIDSTREAM)/* $(PKG_MIDSTREAM)/usr/ diff --git a/.gitignore b/.gitignore index f79d5a8..79f0d01 100644 --- a/.gitignore +++ b/.gitignore @@ -17,9 +17,16 @@ /*.changes /.pc -# Output folder -/out +/llama.cpp-qcom-midstream + +# Build artifacts in src/ +/src/build-midstream-cross/ +/src/install-midstream-cross/ + +# Cached OpenCL tarball +/qcom-adreno_*.tar.gz +/qcom-adreno_*.tar.gz.tmp +/_opencl/ # Logs /*.log - diff --git a/debian/.gitignore b/debian/.gitignore index bf730eb..4fe9f58 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -8,3 +8,4 @@ /*.substvars /tmp +/llama.cpp-qcom-midstream diff --git a/debian/changelog b/debian/changelog index 528949a..b6ae4d1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +llama.cpp-qcom-midstream (0.0.7992-1) UNRELEASED; urgency=medium + + * Initial packaging for Qualcomm mainline-kernel devices + * OpenCL GPU backend with Adreno optimized kernels + * Based on upstream tag b7992 + + -- "Radxa Computer Co., Ltd" Mon, 20 Jul 2026 08:00:00 +0800 + llama.cpp (0.0.10034-1) unstable; urgency=medium [ Chongbiao Chen ] diff --git a/debian/control b/debian/control index 80a6584..987cbc8 100644 --- a/debian/control +++ b/debian/control @@ -1,4 +1,4 @@ -Source: llama.cpp +Source: llama.cpp-qcom-midstream Maintainer: "Radxa Computer Co., Ltd" Section: admin Priority: standard @@ -9,13 +9,20 @@ Build-Depends: debhelper-compat (= 13), lintian, dh-exec, pandoc, + ca-certificates, + cmake, + crossbuild-essential-arm64, + ninja-build, + opencl-headers, + python3, + wget, -Package: llama.cpp-qcom +Package: llama.cpp-qcom-midstream Architecture: all Section: admin Priority: optional Depends: ${misc:Depends}, - fastrpc, -Description: llama.cpp for Qualcomm Snapdragon - llama.cpp with Hexagon DSP backend for Qualcomm Snapdragon devices. - + qcom-adreno-opencl-midstream, + python3, +Description: llama.cpp for Qualcomm mainline (OpenCL GPU) + llama.cpp with OpenCL GPU backend for Qualcomm mainline-kernel devices. diff --git a/debian/llama.cpp-qcom-midstream.install b/debian/llama.cpp-qcom-midstream.install new file mode 100644 index 0000000..cc41244 --- /dev/null +++ b/debian/llama.cpp-qcom-midstream.install @@ -0,0 +1 @@ +llama.cpp-qcom-midstream/usr / diff --git a/debian/llama.cpp-qcom-midstream.lintian-overrides b/debian/llama.cpp-qcom-midstream.lintian-overrides new file mode 100644 index 0000000..82f7775 --- /dev/null +++ b/debian/llama.cpp-qcom-midstream.lintian-overrides @@ -0,0 +1,7 @@ +# Prebuilt cross-compiled binaries in Architecture: all package +arch-independent-package-contains-binary-or-object +missing-dependency-on-libc +unstripped-binary-or-object +no-manual-page +pkg-config-unavailable-for-cross-compilation +script-with-language-extension diff --git a/debian/llama.cpp-qcom.install b/debian/llama.cpp-qcom.install deleted file mode 100644 index 4cd0e16..0000000 --- a/debian/llama.cpp-qcom.install +++ /dev/null @@ -1 +0,0 @@ -llama.cpp-qcom/usr / diff --git a/debian/llama.cpp-qcom.lintian-overrides b/debian/llama.cpp-qcom.lintian-overrides deleted file mode 100644 index 0c10234..0000000 --- a/debian/llama.cpp-qcom.lintian-overrides +++ /dev/null @@ -1,13 +0,0 @@ -undeclared-elf-prerequisites -pkg-config-unavailable-for-cross-compilation -shared-library-lacks-version -link-to-shared-library-in-wrong-package -no-manual-page -arch-independent-package-contains-binary-or-object -lacks-ldconfig-trigger -library-not-linked-against-libc -no-shlibs -shared-library-lacks-stack-section -unstripped-binary-or-object -package-name-doesnt-match-sonames -missing-dependency-on-libc diff --git a/pkg.conf.template b/pkg.conf.template index 4fda94b..2e682d0 100644 --- a/pkg.conf.template +++ b/pkg.conf.template @@ -1,9 +1,18 @@ { "*": { "Releases": [ - "qcs9075-noble", - "qcs9075-noble-test" + "qcs6490-noble", + "qcs6490-noble-test", + "qcs6490-trixie", + "qcs6490-trixie-test", + "qcs6490-resolute", + "qcs6490-resolute-test", + "sc8280xp-noble", + "sc8280xp-noble-test", + "sc8280xp-trixie", + "sc8280xp-trixie-test", + "sc8280xp-resolute", + "sc8280xp-resolute-test" ] } } - diff --git a/src b/src index 505b1ed..612db61 160000 --- a/src +++ b/src @@ -1 +1 @@ -Subproject commit 505b1ed15ca80e2a19f12ff4ac365e40fb374053 +Subproject commit 612db61886e0fd523f89a0f93be0ef19d450b7d7