← All tasks
cppikawrakow/ik_llama.cpp #2050Not a task: already works

Ik llama cpp termux build issue

envgap__ikawrakow__ik_llama.cpp-2050

01 / FAILURE SIGNATURE

As reported upstream

error: unknown type name 'ggml_half'
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
6c5f047a7c5e38c27377e945cf107e045b34682b
Manifest
ggml/src/CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

ikawrakow/ik_llama.cpp #2050 · read the original issue
Build failure on Android/Termux (ARM64, clang): missing includes in iqk/ + unresolved v_silu undeclared identifier
Environment
Device: Android tablet, ARM64 (aarch64), MediaTek Helio G99 / Mali-G57
OS: Android 15
Build environment: Termux (clang toolchain, not GCC)
Compiler: clang/clang++ 21.1.8 (Termux clang package)
Build system: CMake (default generator via Termux cmake + ninja)
Build command used:
  cmake -B build -DGGML_NATIVE=ON
  cmake --build build --config Release -j4
Motivating model: attempting to run microsoft/bitnet-b1.58-2B-4T-gguf (i2_s quant), which mainline llama.cpp cannot load (see ggml-org/llama.cpp#12997) — came to this fork for its documented BitNet + Android/Termux support.
Issue 1 (resolved) — ggml/src/iqk/iqk_common.h: missing <cstdint>
Fails with error: unknown type name 'uint8_t' (and uint16_t/uint32_t/uint64_t) around the popcount() overloads (~lines 953–956). The file uses these types without including <cstdint>. Apparently relies on transitive inclusion that doesn't happen on this toolchain.

Fix: add #include <cstdint> near the top of the file.

Issue 2 (resolved) — ggml/src/iqk/iqk_cpu_ops.cpp: missing/misconfigured ggml headers
Fails with:

error: unknown type name 'ggml_half'
error: use of undeclared identifier 'GGML_BF16_TO_FP32'
error: use of undeclared identifier 'MIN'
Root cause: the file doesn't include ggml-impl.h / ggml.h / ggml-common.h at all. Once added, a second issue surfaces — ggml-common.h's definition of ggml_half is itself conditionally compiled behind one of several mutually exclusive macros (GGML_COMMON_DECL_C, _METAL, _CUDA, _SYCL, etc. — see lines ~13–57 of that header), and nothing in this translation unit was defining any of them.

Fix: add, before any other code in the file:

cpp
#define GGML_COMMON_DECL_C
#include "ggml-common.h"
#include "ggml.h"
#include "ggml-impl.h"
Issue 3 (unresolved) — v_silu undeclared despite confirmed-present NEON macros
After fixes 1–2, the same file still fails with use of undeclared identifier 'v_silu' at several call sites (~lines 781–826, inside rms_rms_add-related code).

v_silu is defined for ARM at ggml/src/iqk/iqk_utils.h:56 (static inline float32x4_t v_silu(float32x4_t x)), inside #if defined(__ARM_NEON) && defined(__aarch64__), itself nested inside a file-wide #if defined IQK_IMPLEMENT (lines 5–246 of that header).

Diagnostics performed, all of which suggest the guard should be active:

IQK_IMPLEMENT is #define'd in iqk_cpu_ops.cpp before any inclusion of iqk_utils.h, whether direct or via iqk_cpu_ops.h.
clang++ -dM -E -x c++ - confirms __ARM_NEON and __aarch64__ are defined by default on this toolchain with no special flags required.
The actual verbose compile invocation (cmake --build ... --verbose) for this specific file shows no -march/-mcpu override or anything else that would suppress NEON codegen.
Despite all of the above, the symbol is still undeclared at the call sites. Did not get to the root cause — ran out of time to trace actual preprocessor output (clang++ -E) for the full translation unit to see directly whether iqk_utils.h's #pragma once guard is being tripped by an earlier, differently-gated inclusion somewhere in the chain. Reporting the dead ends here in case they save someone else the rounds it took to rule them out.

Workaround used: abandoned this build for the session; ran a standard (non-BitNet) small GGUF model on mainline llama.cpp instead, which built and ran without any of the above issues.

Happy to test further, or open a PR for fixes 1 and 2 if that's useful — wanted to get these documented either way in case others hit the same wall on Termux/clang specifically.
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]