From 434a0d323fd52dd175f90e3f65717495f4a3ca62 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Tue, 10 Nov 2026 20:10:46 -0400 Subject: [PATCH 1/2] hrx: compile the fork's HRX test targets, so a break in them is seen (engine#2068) tests/hrx-backend-test.cpp in 1bit-MONSTER/llama.cpp stopped compiling at llama.cpp#262 and nobody saw it, because nothing automated builds it: the target is registered under `if (TARGET ggml-hrx)` in the fork's tests/CMakeLists.txt, so a build without the HRX backend skips it, no build asks for tests, and nothing in engine watches it either. Three host rows then failed in a binary nobody ran. A compile break in a 654 KB test file is the one thing a BUILD catches for free and a RUN never gets to. scripts/hrx-test-compile.sh configures a fork checkout with -DLLAMA_BUILD_TESTS=ON -DGGML_HRX=ON and builds only the HRX test targets. Compile gate only: it never runs a test and needs no device. It asks CMake which of the targets the tree actually declares rather than grepping the CMakeLists, so a target that disappears is reported instead of silently dropped -- and if no HRX target exists at all it exits 77, "SKIP, not PASS", because proving nothing must not look like proving something. Nine arms in tests/hrx_test_compile_test.sh drive the real script against stub trees: a clean tree exits 0; a tree with a #262-shaped error exits 1, names the target and surfaces the compiler's error line; a tree with no HRX targets exits 77 and says "SKIP, not PASS" in those words; and the usage contract (missing tree, unknown flag, non-existent tree all exit 2). Two bugs the arms caught during development, both mine: `${1:?}` exits 1 rather than the documented 2, and a stub with a .cpp in a C-only project cannot determine a link language -- both fixed before this commit. The workflow step that would call this needs `workflow` scope, which this lane's token lacks (the #1817/#2045 wall); the exact line is in the PR body for whoever has it. Refs #2068. --- CMakeLists.txt | 1 + scripts/hrx-test-compile.sh | 77 ++++++++++++++++++++++++++++++++ tests/hrx_test_compile_test.sh | 80 ++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) create mode 100755 scripts/hrx-test-compile.sh create mode 100755 tests/hrx_test_compile_test.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 16cbce9bc..b4a8b2580 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,6 +200,7 @@ add_test(NAME serve_hangup COMMAND ${CMAKE_SOURCE_DIR}/tests/serve_hangup_test.s # engine#1945: scripts/bump-hrx-sync.sh tells AMD's own commit from a line AMD rebased apart from a commit that # is not AMD's. Local git repositories only: no network, no GPU. add_test(NAME bump_hrx_sync COMMAND bash ${CMAKE_SOURCE_DIR}/tests/bump_hrx_sync_test.sh ${CMAKE_SOURCE_DIR}/scripts/bump-hrx-sync.sh) +add_test(NAME hrx_test_compile COMMAND bash ${CMAKE_SOURCE_DIR}/tests/hrx_test_compile_test.sh ${CMAKE_SOURCE_DIR}/scripts/hrx-test-compile.sh) add_test(NAME metrics_serve COMMAND ${CMAKE_SOURCE_DIR}/tests/metrics_serve.sh $) # serve --print-backend: the llama-server Lemonade starts itself, one hop (docs/serve.md): no GPU. add_test(NAME print_backend COMMAND ${CMAKE_SOURCE_DIR}/tests/print_backend.sh $) diff --git a/scripts/hrx-test-compile.sh b/scripts/hrx-test-compile.sh new file mode 100755 index 000000000..8a3dc1d26 --- /dev/null +++ b/scripts/hrx-test-compile.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# Copyright 2026 bong-water-water-bong +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# hrx-test-compile.sh -- compile the fork's HRX test targets, and nothing else. +# +# Why this exists (engine#2068): `tests/hrx-backend-test.cpp` in 1bit-MONSTER/llama.cpp stopped compiling at +# llama.cpp#262 and NOBODY SAW IT, because no automated job builds that file -- it is registered under +# `if (TARGET ggml-hrx)` in the fork's tests/CMakeLists.txt, so a build without the HRX backend skips it, and no +# build asks for tests. Three host rows then failed in a binary nothing ran. A compile break in a 654 KB test +# file is the one thing a *build* catches for free and a *run* never gets the chance to. +# +# This is a compile gate only: it never runs the tests and needs no device. +# +# usage: hrx-test-compile.sh [--build-dir DIR] +# exit: 0 all HRX test targets built; 1 a target failed to build; 2 usage; 77 the tree has no HRX backend +set -uo pipefail + +if [ $# -lt 1 ]; then + echo "usage: hrx-test-compile.sh [--build-dir DIR]" >&2 + exit 2 +fi +tree=$1 +shift || true +build_dir="" +while [ $# -gt 0 ]; do + case "$1" in + --build-dir) build_dir=${2:?--build-dir needs a path}; shift 2 ;; + *) echo "hrx-test-compile: unknown argument: $1" >&2; exit 2 ;; + esac +done +[ -d "$tree" ] || { echo "hrx-test-compile: not a directory: $tree" >&2; exit 2; } +[ -d "$tree/tests" ] || { echo "hrx-test-compile: no tests/ in $tree" >&2; exit 2; } +[ -n "$build_dir" ] || build_dir="$tree/build-hrx-test-compile" + +# Configure with the HRX backend and the tests on: those two switches are what make the file part of the build. +# GGM L_HRX's own option name is the fork's; if it is renamed, this configure fails loudly rather than skipping. +if ! cmake -S "$tree" -B "$build_dir" -DLLAMA_BUILD_TESTS=ON -DGGML_HRX=ON -DCMAKE_BUILD_TYPE=Release >"$build_dir.configure.log" 2>&1; then + echo "hrx-test-compile: configure FAILED (see $build_dir.configure.log)" >&2 + tail -5 "$build_dir.configure.log" >&2 + exit 1 +fi + +# Which of the HRX test targets this tree actually declares. Asking CMake rather than grepping the CMakeLists keeps +# the gate honest when the target list changes: a target that disappears is reported, not silently dropped. +have=$(cmake --build "$build_dir" --target help 2>/dev/null | sed -n 's/^\.\.\. \([A-Za-z0-9_.-]*\)$/\1/p' | grep -x 'test-hrx-backend\|test-hrx-rope-claim-params' | sort -u) + +if [ -z "$have" ]; then + # Not "passed": no HRX target exists in this tree, so this gate proved nothing about the file it exists for. + echo "hrx-test-compile: no HRX test targets in $tree (GGML_HRX=ON did not produce them) -- SKIP, not PASS" >&2 + exit 77 +fi + +rc=0 +for t in $have; do + if cmake --build "$build_dir" --target "$t" >>"$build_dir.build.log" 2>&1; then + echo "ok built $t" + else + echo "FAIL build $t (see $build_dir.build.log)" >&2 + grep -E "error:" "$build_dir.build.log" | head -3 >&2 + rc=1 + fi +done +[ "$rc" = 0 ] && echo "ok HRX test targets compile ($(echo $have | wc -w) target(s))" +exit "$rc" diff --git a/tests/hrx_test_compile_test.sh b/tests/hrx_test_compile_test.sh new file mode 100755 index 000000000..f2ec1ca3c --- /dev/null +++ b/tests/hrx_test_compile_test.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# Copyright 2026 bong-water-water-bong +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# hrx_test_compile_test.sh -- arms for scripts/hrx-test-compile.sh (engine#2068). +# +# The gate's whole value is that it fails on the source that did not compile (#262) and does not report a pass when +# it never built the file. So the arms are: a tree that builds, a tree whose test source has the #262-shaped error, +# and a tree with no HRX targets at all -- the last one must exit 77, because "not built" and "built fine" are the +# two states this gate exists to keep apart. +# +# usage: hrx_test_compile_test.sh +set -uo pipefail + +S=${1:?usage: hrx_test_compile_test.sh } +[ -x "$S" ] || { echo "not executable: $S"; exit 1; } +command -v cmake >/dev/null 2>&1 || { echo "skip: no cmake (exit 77)"; exit 77; } +work=$(mktemp -d "${TMPDIR:-/tmp}/hrxtc.XXXXXX") # scratch, removed below +trap 'rm -rf "$work"' EXIT +fail=0 +ok() { echo "ok $1"; } +bad() { echo "FAIL $1"; fail=1; } + +# A stub "fork": the smallest tree whose CMakeLists declares the HRX test target the gate looks for, so the gate's +# own logic (configure, ask for the target, build it) is exercised without the real 654 KB source or the HRX toolchain. +mktree() { # mktree [declare-hrx] + local d=$1 body=$2 hrx=${3:-yes} + mkdir -p "$d/tests" + cat > "$d/CMakeLists.txt" < "$d/tests/CMakeLists.txt" <<'EOF' +add_executable(test-hrx-backend hrx-backend-test.cpp) +EOF + printf '%s\n' "$body" > "$d/tests/hrx-backend-test.cpp" +} + +# 1. Compiles cleanly -> 0. +mktree "$work/good" 'int main(void) { return 0; }' +"$S" "$work/good" --build-dir "$work/b-good" >/dev/null 2>&1 +[ $? = 0 ] && ok "a tree whose HRX test compiles exits 0" || bad "a tree whose HRX test compiles exits 0" + +# 2. The #262 shape: an error in the test source -> non-zero, and the error text is surfaced. +mktree "$work/bad" 'int main(void) { const int x = "not an int"; return x; }' +out=$("$S" "$work/bad" --build-dir "$work/b-bad" 2>&1); rc=$? +[ "$rc" = 1 ] && ok "a tree with a broken HRX test exits 1" || bad "a tree with a broken HRX test exits 1 (got $rc)" +[[ $out == *test-hrx-backend* ]] && ok "and names the target that failed" || bad "and names the target that failed" +[[ $out == *error:* ]] && ok "and surfaces the compiler's error line" || bad "and surfaces the compiler's error line" + +# 3. No HRX targets at all -> 77, never 0. This is the arm that keeps the gate from being vacuous. +mktree "$work/nohrx" 'int main(void) { return 0; }' no +out=$("$S" "$work/nohrx" --build-dir "$work/b-nohrx" 2>&1); rc=$? +[ "$rc" = 77 ] && ok "a tree without HRX targets exits 77 (skip, not pass)" || bad "a tree without HRX targets exits 77 (got $rc)" +[[ $out == *"SKIP, not PASS"* ]] && ok "and says so in those words" || bad "and says so in those words" + +# 4. Usage contract. +"$S" >/dev/null 2>&1; [ $? = 2 ] && ok "a missing tree exits 2" || bad "a missing tree exits 2" +"$S" "$work/good" --nope >/dev/null 2>&1; [ $? = 2 ] && ok "an unknown argument exits 2" || bad "an unknown argument exits 2" +"$S" "$work/absent" >/dev/null 2>&1; [ $? = 2 ] && ok "a non-existent tree exits 2" || bad "a non-existent tree exits 2" + +[ $fail = 0 ] && echo "all hrx-test-compile arms passed" +exit $fail From 73e3f042031c12e6689be214f1506aa978bdf4a5 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Tue, 10 Nov 2026 20:41:05 -0400 Subject: [PATCH 2/2] hrx_test_compile_test: resolve the compiler CI actually has, and print the gate's output when an arm fails --- tests/hrx_test_compile_test.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/hrx_test_compile_test.sh b/tests/hrx_test_compile_test.sh index f2ec1ca3c..e9d01619c 100755 --- a/tests/hrx_test_compile_test.sh +++ b/tests/hrx_test_compile_test.sh @@ -27,6 +27,14 @@ set -uo pipefail S=${1:?usage: hrx_test_compile_test.sh } [ -x "$S" ] || { echo "not executable: $S"; exit 1; } command -v cmake >/dev/null 2>&1 || { echo "skip: no cmake (exit 77)"; exit 77; } + +# The stub trees need a real C and C++ compiler, and they must be found the way this box names them: CI configures the +# engine build with gcc-16/g++-16 and may have no plain `cc`/`c++` on PATH at all, which is how this test failed its +# first CI run while passing locally. CMake honours CC/CXX on a first configure, so the arms hand it what exists. +pick() { for c in "$@"; do command -v "$c" >/dev/null 2>&1 && { command -v "$c"; return 0; }; done; return 1; } +CC=$(pick "${CC:-}" cc gcc gcc-16 gcc-15 gcc-14) || { echo "skip: no C compiler (exit 77)"; exit 77; } +CXX=$(pick "${CXX:-}" c++ g++ g++-16 g++-15 g++-14) || { echo "skip: no C++ compiler (exit 77)"; exit 77; } +export CC CXX work=$(mktemp -d "${TMPDIR:-/tmp}/hrxtc.XXXXXX") # scratch, removed below trap 'rm -rf "$work"' EXIT fail=0 @@ -55,8 +63,18 @@ EOF # 1. Compiles cleanly -> 0. mktree "$work/good" 'int main(void) { return 0; }' -"$S" "$work/good" --build-dir "$work/b-good" >/dev/null 2>&1 -[ $? = 0 ] && ok "a tree whose HRX test compiles exits 0" || bad "a tree whose HRX test compiles exits 0" +# On failure, print what the gate itself said: an arm that reports only "exits 0" fails the first CI run with no cause, +# which is what happened here (the real reason was a missing compiler, and the arm said nothing about it). +run_arm() { # run_arm