Keep gguflib input-validation asserts active in release builds (#3436)

This commit is contained in:
Kimon N.
2026-04-27 08:46:57 +09:00
committed by GitHub
parent 894c948773
commit bdb6ff8881
+5
View File
@@ -17,6 +17,11 @@ if(MLX_BUILD_GGUF)
PRIVATE $<BUILD_INTERFACE:${gguflib_SOURCE_DIR}>)
add_library(gguflib STATIC ${gguflib_SOURCE_DIR}/fp16.c
${gguflib_SOURCE_DIR}/gguflib.c)
# gguflib uses assert() to reject malformed tensor headers (e.g. ndim > 8).
# Those checks are otherwise compiled out by -DNDEBUG in release builds, which
# leaves out-of-bounds reads/writes unguarded when loading untrusted GGUF
# files. Force NDEBUG off for this target so the asserts stay live.
target_compile_options(gguflib PRIVATE -UNDEBUG)
target_link_libraries(mlx PRIVATE $<BUILD_INTERFACE:gguflib>)
target_sources(mlx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/gguf.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gguf_quants.cpp)