forked from kherud/java-llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild_opencl_android.sh
More file actions
executable file
·52 lines (45 loc) · 1.9 KB
/
Copy pathbuild_opencl_android.sh
File metadata and controls
executable file
·52 lines (45 loc) · 1.9 KB
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
#!/bin/bash
# SPDX-FileCopyrightText: 2026 Bernard Ladenthin <bernard.ladenthin@gmail.com>
#
# SPDX-License-Identifier: MIT
#
# Android arm64 build with the OpenCL backend enabled and Adreno-tuned
# kernels embedded. Runs inside the dockcross/android-arm64 container.
#
# The dockcross image does not ship OpenCL headers or a libOpenCL.so stub,
# so this script first stages Khronos OpenCL-Headers and cross-builds
# OpenCL-ICD-Loader to satisfy `find_package(OpenCL REQUIRED)` at link
# time. At runtime the device's vendor ICD (e.g. Qualcomm Adreno driver)
# provides the actual OpenCL symbols.
set -eu
OPENCL_STAGE=/tmp/opencl-stage
HEADERS_DIR="$OPENCL_STAGE/OpenCL-Headers"
LOADER_DIR="$OPENCL_STAGE/OpenCL-ICD-Loader"
LOADER_BUILD="$LOADER_DIR/build"
# Pinned tags for reproducibility (OpenCL 3.1.1 spec release).
HEADERS_TAG=v2026.05.29
LOADER_TAG=v2026.05.29
if [ ! -d "$HEADERS_DIR" ]; then
mkdir -p "$OPENCL_STAGE"
git clone --depth 1 --branch "$HEADERS_TAG" \
https://github.com/KhronosGroup/OpenCL-Headers.git "$HEADERS_DIR"
fi
if [ ! -f "$LOADER_BUILD/libOpenCL.so" ]; then
if [ ! -d "$LOADER_DIR" ]; then
git clone --depth 1 --branch "$LOADER_TAG" \
https://github.com/KhronosGroup/OpenCL-ICD-Loader.git "$LOADER_DIR"
fi
cmake -B "$LOADER_BUILD" -S "$LOADER_DIR" \
-DCMAKE_BUILD_TYPE=Release \
-DOPENCL_ICD_LOADER_HEADERS_DIR="$HEADERS_DIR" \
-DBUILD_TESTING=OFF
cmake --build "$LOADER_BUILD" --config Release -j"$(nproc)"
fi
# Delegate the jllama cmake configure + build to build.sh so it inherits the
# sccache probe, Depot cache launcher, and --show-stats output automatically —
# same as build_cuda_linux.sh. Pass $@ unquoted so the CI's single-string
# argument is word-split into individual -D flags for cmake.
exec .github/build.sh \
-DOpenCL_INCLUDE_DIR="$HEADERS_DIR" \
-DOpenCL_LIBRARY="$LOADER_BUILD/libOpenCL.so" \
$@