Repository navigation
ggml-hrx: keep GCC 15 diagnostic false positives out of the deps -Werror - #237
Conversation
Building ggml-hrx from source (-DHRX_SOURCE_DIR, which is how this box builds it now that no hrx package is installed)
fails on gcc 15.2.0 inside the ggml-hrx-deps ExternalProject, three times over, each in code we do not ship and none of it
in HRX inference:
1. runtime/src/iree/async/util/continuation.h:75 -Werror=array-bounds. `values[iterator->next_head_index - 1]` indexes an
unsigned iree_host_size_t that is pre-incremented in the loop body before the subscript, behind an early return that
keeps it < count, so the index is 0..count-1 whenever it is evaluated. GCC 15 loses the ">= 1 after the pre-increment"
fact across the do-while and warns about a hypothetical -1. False positive.
2. loom/.../aie2p/lower/transpose.c:366 -Werror=stringop-overflow ("writing 16 bytes into a region of size 15"). The
power-of-two fill writes source_lanes[lane_count .. padded_lane_count-1] into a 128-byte array, and lane_count is
bounded by 128 for every type the carrier table admits (vector_carrier.c: I1 <= 128, accumulator <= 2048/bit_count,
ordinary <= 1024/bit_count), so padded_lane_count <= 128. GCC vectorises the fill and cannot see that cross-TU
invariant. False positive.
3. loom/tooling/testbench/expectation.c:1112 -Werror=format-overflow ("%.*s directive argument is null"). This one is not a
false positive: an empty iree_string_view can carry data == NULL, and that reaches %s. It is latent UB in an
error-message path of a testbench tool, in AMD tree that this fork must not modify - so demoting the promotion here is
the only place we can act on it, and it cannot affect a shipped path.
The suppression is scoped as tightly as the problem allows: only the deps build (the outer build and everything llama.cpp
compiles keep -Werror), only when the compiler is GNU and version >= 15, and -Wno-error= rather than -Wno- so every
diagnostic still prints in the log.
Proven: three errors reproduced first against the unmodified tree with hrx-system source at the pin; then a clean
from-source configure+build (IREE, loom, libhrx built from source in a fresh directory) completes with llama-cli and
test-backend-ops, and test-backend-ops -o MUL_MAT on HRX0 passes against the CPU reference.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 5ec9d7c43014a41a157d56703737ebfdda2e8c3d
The scoping claims are what matter here — a demoted warning that leaks into the outer build would be a way to hide real out-of-bounds bugs — and all three hold:
- only the deps build: the flags are appended to
GGML_HRX_CMAKE_ARGS, which is passed solely toExternalProject_Add(ggml-hrx-deps … CMAKE_ARGS ${GGML_HRX_CMAKE_ARGS}). The outer llama.cpp build keeps-Werrorfor these three diagnostics, so a real out-of-bounds in this tree still fails. - only GCC ≥ 15:
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15), so an older compiler keeps the promotion. -Wno-error=, not-Wno-: every diagnostic stays in the log, only the promotion goes. The three flags parse on this box's gcc 15.2.0 — the version the comment says they reproduced the warnings on, which I confirmed (gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0), and a compile with all three is clean.
The disclosure is the part that makes this reviewable. Two of the three are argued as false positives with the reasoning that proves it in the comment (IREE's next_head_index is pre-incremented inside the do-while and bounded before it, so the subscript is in 0..count-1; loom's lane_count is bounded by 128 for every carrier the table admits, so padded_lane_count ≤ 128) — that is the shape a suppression needs. The third is called out as not a false positive: loom/tooling/testbench/expectation.c:1112 formats with %.*s and an empty string view can carry a NULL data pointer, so NULL can reach %s — latent UB, in an error-message path of a testbench tool, in AMD's tree which this fork must not modify. Demoting it in the deps build is the only place the fork can act, and it cannot change a shipped code path. Naming that instead of filing it under "GCC 15 noise" is the difference between a documented workaround and a hidden bug.
Not checked: the two source lines themselves (continuation.h:75, transpose.c:366, expectation.c:1112) — they live in the fetched IREE/loom trees, not in this repository, and the HRX deps build is the hour-long ExternalProject I have not spent for a warning-policy change. The upstream fix would be to send the %.*s/NULL case to AMD; until then this is the right seam.
Building
ggml-hrxfrom source (-DHRX_SOURCE_DIR=…, which is how this box builds it now that nohrxpackage is installed) fails on gcc 15.2.0, inside theggml-hrx-depsExternalProject. It fails three times over, each in code that is not HRX inference and not ours to rewrite (the AMD tree), so the fix belongs in our build glue.Who this blocks: every lane that builds HRX from source rather than against a prebuilt package — on this box that is the
-DHRX_SOURCE_DIR=…/third_party/hrx-systemform used by~/lb/dsv41-{lid,merged,stack}-build.shand the~/wt/315-*scripts (checked, not assumed). It is the same failure the kernel lane hit and worked around per-build; this puts the fix in
one place.
The three, classified honestly rather than lumped together
runtime/src/iree/async/util/continuation.h:75—-Werror=array-bounds, FALSE POSITIVE. Iniree_async_continuation_chain_iterator_next,values[iterator->next_head_index - 1]indexes an unsignediree_host_size_tthat is pre-incremented in the loop body before the subscript, behind an early return that guarantees it is< count. So the index is0..count-1whenever it is evaluated: no negative index exists, and the increment cannot overflow. GCC's message shows the mechanism — it specialised the pointee toiree_async_operation_t *[1]at acount == 1call site and warns about a hypothetical-1; it loses the pre-increment fact across the do-while when inlining.loom/.../aie2p/lower/transpose.c:366—-Werror=stringop-overflow, FALSE POSITIVE. "writing 16 bytes into a region of size 15" at offset[113,128]of the 128-bytesource_lanes. The fill writessource_lanes[lane_count .. padded_lane_count-1], andlane_countis bounded by 128 for every type the carrier table admits (vector_carrier.c:I1 ≤ 128, accumulator≤ 2048/bit_count, ordinary≤ 1024/bit_count), so the power-of-twopadded_lane_countis≤ 128too. GCC vectorises the fill and cannot see an invariant established in another translation unit.loom/tooling/testbench/expectation.c:1112—-Werror=format-overflow, NOT a false positive. It formats(int)name.size, name.datawith%.*s, and an emptyiree_string_view_tcan carrydata == NULL, so a NULL can reach%s. That is latent UB — in an error-message path of a testbench tool, in AMD's tree, which this fork must not modify. Demoting the promotion is the only place we can act on it, and it cannot affect a shipped path.Change
ggml/src/ggml-hrx/CMakeLists.txt: whenCMAKE_C_COMPILER_IDis GNU andVERSION_GREATER_EQUAL 15, append-Wno-error=array-bounds -Wno-error=stringop-overflow -Wno-error=format-overflow(to bothCMAKE_C_FLAGSandCMAKE_CXX_FLAGS, preserving whatever the outer configure set) to theggml-hrx-depsExternalProject arguments.Scope, verified in the generated
build.ninja: the flags appear only in theggml-hrx-depsconfigure command; the outerbuild and every llama.cpp target keep
-Werror. It is-Wno-error=, not-Wno-, so all three diagnostics still print. NoAMD tree is touched.
Proven
82804197b, gcc 15.2.0:continuation.h:75:38: error: array subscript -1 is outside array bounds of 'iree_async_operation_t *[1]' [-Werror=array-bounds=](3 occurrences, rc=1) — then, with that demoted, the loom pair above, each from a fresh configure.
with
llama-cliandtest-backend-ops. Reconfigured once more without the outer probe flag and rebuilt, so theproof is the committed patch alone: rc=0, no errors.
test-backend-ops -b HRX0 -o MUL_MATon that build: FILL_TEST.