From 8c1aa807946684832052da85fbead1a9a9bf022e Mon Sep 17 00:00:00 2001 From: Shaw Date: Tue, 19 May 2026 02:59:15 -0700 Subject: [PATCH 1/3] fix(adapter): cast ab_map.size() to uint32_t in get_n_nodes() GCC 13+ with -Werror=conversion flags the implicit size_t -> uint32_t narrowing in llama_adapter_lora::get_n_nodes(). LoRA adapter weight maps never exceed 2^32 entries in practice (typical count is dozens), so an explicit static_cast is safe. Unblocks all 6 Ubuntu/Linux LLAMA_FATAL_WARNINGS builds: arm64-kleidiai, x64-high-perf, x64-low-perf, ubuntu-cpu-22.04, llguidance, sanitizer-THREAD. --- src/llama-adapter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llama-adapter.h b/src/llama-adapter.h index f0b1e50f8..5c500f278 100644 --- a/src/llama-adapter.h +++ b/src/llama-adapter.h @@ -83,7 +83,7 @@ struct llama_adapter_lora { llama_adapter_lora_weight * get_weight(ggml_tensor * w); uint32_t get_n_nodes() const { - return ab_map.size() * 6u; // a, b, scale, add, 2 x mul_mat + return static_cast(ab_map.size()) * 6u; // a, b, scale, add, 2 x mul_mat } }; From c95a925424a27c2b2c979ba6f4185c2bd3784a64 Mon Sep 17 00:00:00 2001 From: Shaw Date: Tue, 19 May 2026 02:59:27 -0700 Subject: [PATCH 2/3] fix(debug): widen src1_str buffer to 256 to avoid format-truncation GCC 13+ with -Werror=format-truncation flags the snprintf at debug.cpp:167 because src1->name (up to GGML_MAX_NAME = 64) plus the '{' + common_ggml_ne_string + '}' wrapper can exceed the 128-byte buffer in the worst case. Doubling the buffer to 256 satisfies the static analysis without changing observable behavior. Unblocks the same 6 Ubuntu/Linux LLAMA_FATAL_WARNINGS builds as the adapter conversion fix. --- common/debug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/debug.cpp b/common/debug.cpp index 102c6924d..fff040c06 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -162,7 +162,7 @@ bool common_debug_cb_eval(struct ggml_tensor * t, bool ask, void * user_data) { } } - char src1_str[128] = { 0 }; + char src1_str[256] = { 0 }; if (src1) { snprintf(src1_str, sizeof(src1_str), "%s{%s}", src1->name, common_ggml_ne_string(src1).c_str()); } From b12f29b66b8264e5ba7cf784a3fbbcdbc0728892 Mon Sep 17 00:00:00 2001 From: Shaw Date: Tue, 19 May 2026 02:59:37 -0700 Subject: [PATCH 3/3] fix(vulkan): undef windows.h MemoryBarrier macro to fix MSVC C2146 MSVC's (included via ) defines MemoryBarrier as a macro that expands to an intrinsic (__faststorefence on x64, __dmb(_ARM_BARRIER_SY) on ARM). That collides with vk::MemoryBarrier at ggml-vulkan.cpp:7078, producing C2146 'missing ;' on the next identifier ('barrier'). #undef MemoryBarrier immediately after #include in the _MSC_VER branch. Nothing else in this TU uses the Win32 intrinsic. Unblocks windows-latest (vulkan-x64) CI. --- ggml/src/ggml-vulkan/ggml-vulkan.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp index b2acb7f98..77334b353 100644 --- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp +++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp @@ -58,6 +58,11 @@ DispatchLoaderDynamic & ggml_vk_default_dispatcher(); #if defined(_MSC_VER) # define NOMINMAX 1 # include +// windows.h (winnt.h) defines MemoryBarrier as a macro that expands to an +// intrinsic call (e.g. __faststorefence()). That collides with vk::MemoryBarrier +// and causes MSVC C2146 syntax errors. Undefine it; nothing in this TU needs +// the Win32 MemoryBarrier intrinsic. +# undef MemoryBarrier # define YIELD() YieldProcessor() #elif defined(__clang__) || defined(__GNUC__) # if defined(__x86_64__) ||defined(__i386__)