From 276092987c9af41ae4027b459fca4316c4e00d52 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Mon, 16 Nov 2026 01:17:13 -0400 Subject: [PATCH] hrx: tensor_is_host_resident has external linkage again -- #403 defined it in an anonymous namespace #403 (0a4126f87) declares ggml::hrx::tensor_is_host_resident in host-weight-placement.h and calls it from ggml-hrx.cpp, but defines it inside `namespace {` in host-weight-placement.cpp. The definition therefore has internal linkage: libggml-hrx.so links with the symbol undefined (shared libraries resolve lazily), and the first graph that reaches ggml-hrx.cpp:672 dies with symbol lookup error: libggml-hrx.so.0: undefined symbol: _ZN4ggml3hrx23tensor_is_host_residentEPK11ggml_tensor (seen loading Qwen3.8-Flash-Next with llama-completion on the branch tip). The function moves above the anonymous namespace, unchanged; host_resident_weight() in the anonymous namespace still sees it. Before: `ldd -r llama-completion` reports 1 undefined symbol, `nm -D libggml-hrx.so` defines 0 tensor_is_host_resident. After: 0 undefined symbols (llama-completion, llama-server, libggml-hrx.so), 1 defined. Co-Authored-By: Claude Opus 5.5 --- ggml/src/ggml-hrx/host-weight-placement.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ggml/src/ggml-hrx/host-weight-placement.cpp b/ggml/src/ggml-hrx/host-weight-placement.cpp index a92cc7ad919..df886e59c16 100644 --- a/ggml/src/ggml-hrx/host-weight-placement.cpp +++ b/ggml/src/ggml-hrx/host-weight-placement.cpp @@ -32,8 +32,9 @@ namespace ggml::hrx { -namespace { - +// engine (fork #403 follow-up): defined OUTSIDE the anonymous namespace. host-weight-placement.h declares it as +// ggml::hrx::tensor_is_host_resident and ggml-hrx.cpp calls it; inside `namespace {` it had internal linkage, so +// libggml-hrx.so linked with the symbol undefined and the first call died with a symbol lookup error. // True for a model weight that is NOT in an HRX-allocated buffer, i.e. a tensor the executor would have to copy // into device memory before it could bind it. // engine#2494: residence and usage are two different questions and only the pair answers "is this a host weight". @@ -54,6 +55,8 @@ bool tensor_is_host_resident(const ggml_tensor * tensor) { return ggml_backend_buffer_is_host(buffer); } +namespace { + bool host_resident_weight(const ggml_tensor * tensor) { if (!tensor_is_host_resident(tensor)) { return false;