From fe6a9882acf5c02f96624ed8f80144100d7006cb Mon Sep 17 00:00:00 2001 From: Prajwal B Mehendarkar Date: Thu, 23 Oct 2025 17:07:31 +0530 Subject: [PATCH] Manually link -lbsd to resolve flock symbol on AIX (#16610) --- tools/imatrix/CMakeLists.txt | 5 +++++ tools/run/CMakeLists.txt | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/tools/imatrix/CMakeLists.txt b/tools/imatrix/CMakeLists.txt index 22f2fe5fdb..5af6263f98 100644 --- a/tools/imatrix/CMakeLists.txt +++ b/tools/imatrix/CMakeLists.txt @@ -6,3 +6,8 @@ target_compile_features(${TARGET} PRIVATE cxx_std_17) if(LLAMA_TOOLS_INSTALL) install(TARGETS ${TARGET} RUNTIME) endif() + +if (CMAKE_SYSTEM_NAME MATCHES "AIX") + # AIX's flock() function comes from libbsd.a + target_link_libraries(${TARGET} PRIVATE -lbsd) +endif() diff --git a/tools/run/CMakeLists.txt b/tools/run/CMakeLists.txt index e52294ccc0..6ad7534e29 100644 --- a/tools/run/CMakeLists.txt +++ b/tools/run/CMakeLists.txt @@ -13,5 +13,11 @@ endif () if(LLAMA_TOOLS_INSTALL) install(TARGETS ${TARGET} RUNTIME) endif() + +if (CMAKE_SYSTEM_NAME MATCHES "AIX") + # AIX's flock() function comes from libbsd.a + target_link_libraries(${TARGET} PRIVATE -lbsd) +endif() + target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT} ${LLAMA_RUN_EXTRA_LIBS}) target_compile_features(${TARGET} PRIVATE cxx_std_17)