From ddf62b8d4e85494e6594ab3ce7524d4bec443837 Mon Sep 17 00:00:00 2001 From: LoganDark <4723091+LoganDark@users.noreply.github.com> Date: Mon, 9 Mar 2026 06:51:22 -0700 Subject: [PATCH] fix build on macOS when Metal is disabled ggml-blas was only linked and had PIC set inside the GGML_METAL condition, but on macOS, ggml enables the BLAS backend by default (via Accelerate) regardless of whether Metal is enabled. This caused an undefined symbol error for ggml_backend_blas_reg at link time. Decouple ggml-blas from the Metal condition by using `if (TARGET ggml-blas)` instead, which correctly handles all cases: macOS with or without Metal, Linux with OpenBLAS, and platforms without BLAS. Co-authored-by: Claude Signed-off-by: LoganDark <4723091+LoganDark@users.noreply.github.com> --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11384de..8f50a8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,7 +269,10 @@ target_include_directories(rwkv PRIVATE ggml/include ggml/src) target_compile_features(rwkv PUBLIC cxx_std_11) if (GGML_METAL) - set(RWKV_EXTRA_LIBS ${RWKV_EXTRA_LIBS} $ $) + set(RWKV_EXTRA_LIBS ${RWKV_EXTRA_LIBS} $) +endif() +if (TARGET ggml-blas) + set(RWKV_EXTRA_LIBS ${RWKV_EXTRA_LIBS} $) endif() if (GGML_CUDA) set(RWKV_EXTRA_LIBS ${RWKV_EXTRA_LIBS} $) @@ -289,6 +292,8 @@ if (RWKV_BUILD_SHARED_LIBRARY) set_target_properties(ggml-cpu PROPERTIES POSITION_INDEPENDENT_CODE ON) if (GGML_METAL) set_target_properties(ggml-metal PROPERTIES POSITION_INDEPENDENT_CODE ON) + endif() + if (TARGET ggml-blas) set_target_properties(ggml-blas PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() if (GGML_CUDA)