| # Build the immutable upstream llama.cpp candidate used by GGUF fallbacks. | |
| set -euo pipefail | |
| readonly REPO="https://github.com/ggml-org/llama.cpp.git" | |
| readonly TAG="b9637" | |
| readonly COMMIT="aedb2a5e9ca3d4064148bbb919e0ddc0c1b70ab3" | |
| SRC_DIR="${SRC_DIR:-$HOME/src/llama.cpp-qwen3-next-$TAG}" | |
| BUILD_JOBS="${BUILD_JOBS:-$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 8)}" | |
| command -v git >/dev/null 2>&1 || { echo "git is required" >&2; exit 2; } | |
| command -v cmake >/dev/null 2>&1 || { echo "cmake is required" >&2; exit 2; } | |
| if [[ ! -d "$SRC_DIR/.git" ]]; then | |
| git clone --filter=blob:none "$REPO" "$SRC_DIR" | |
| fi | |
| git -C "$SRC_DIR" fetch --depth 1 origin "refs/tags/$TAG:refs/tags/$TAG" | |
| git -C "$SRC_DIR" checkout --detach "$COMMIT" | |
| actual_commit="$(git -C "$SRC_DIR" rev-parse HEAD)" | |
| [[ "$actual_commit" == "$COMMIT" ]] || { | |
| echo "runtime pin mismatch: expected $COMMIT, got $actual_commit" >&2 | |
| exit 3 | |
| } | |
| cmake -S "$SRC_DIR" -B "$SRC_DIR/build" \ | |
| -DGGML_CUDA=ON \ | |
| -DCMAKE_BUILD_TYPE=Release | |
| cmake --build "$SRC_DIR/build" --config Release --parallel "$BUILD_JOBS" | |
| "$SRC_DIR/build/bin/llama-server" --version | |