diff --git a/backend/cpp/llama-cpp/Makefile b/backend/cpp/llama-cpp/Makefile index b1f34d9852ac..e78be7b0d15c 100644 --- a/backend/cpp/llama-cpp/Makefile +++ b/backend/cpp/llama-cpp/Makefile @@ -1,5 +1,5 @@ -LLAMA_VERSION?=d7bd3bfcad3e29c7e49fd26f38c79ee3e9a3fd6b +LLAMA_VERSION?=3466812d1f06728effe7c0f3c0671117f461672d LLAMA_REPO?=https://github.com/ggerganov/llama.cpp CMAKE_ARGS?= diff --git a/backend/cpp/llama-cpp/prepare.sh b/backend/cpp/llama-cpp/prepare.sh index e00b139cb1c6..c76d15bb79a2 100644 --- a/backend/cpp/llama-cpp/prepare.sh +++ b/backend/cpp/llama-cpp/prepare.sh @@ -15,6 +15,30 @@ if [ -d "patches" ]; then done fi +## Apple RDMA link fixup. + +## ggml-rpc hands Apple's librdma to the linker with +## target_link_options(ggml-rpc PRIVATE "LINKER:-weak_library,..."). Link options are not +## a usage requirement of a static library, so in our BUILD_SHARED_LIBS=OFF build the flag +## dies with libggml-rpc.a and every ibv_* symbol transport-apple.cpp reaches for comes out +## undefined when grpc-server and ggml-rpc-server link. Re-declare the same weak link as +## INTERFACE so it travels to whoever links the static library. +## +## Guarded on the marker so a second prepare.sh over the same checkout is a no-op, and on +## GGML_RPC_RDMA_APPLE so forks that branched before the Apple RDMA transport (turboquant, +## bonsai) are left alone. +RPC_CMAKE=llama.cpp/ggml/src/ggml-rpc/CMakeLists.txt +if [ -f "$RPC_CMAKE" ] && grep -q "GGML_RPC_RDMA_APPLE" "$RPC_CMAKE" && ! grep -q "LOCALAI_RDMA_IFACE" "$RPC_CMAKE"; then + echo "==> ggml-rpc carries the Apple RDMA transport, re-declaring its weak librdma link as INTERFACE" + cat >> "$RPC_CMAKE" <<'EOF' + +# LOCALAI_RDMA_IFACE: added by backend/cpp/llama-cpp/prepare.sh +if (GGML_RPC_RDMA AND APPLE AND NOT BUILD_SHARED_LIBS) + target_link_options(ggml-rpc INTERFACE "LINKER:-weak_library,${RDMA_LIB}") +endif() +EOF +fi + for file in $(ls llama.cpp/tools/server/); do cp -rfv llama.cpp/tools/server/$file llama.cpp/tools/grpc-server/ done