char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Ed Addariorpc : fix linking when compiling with BUILD_SHARED_LIBS=OFF (#28492)f3a33dff2

char/aliceai-t5-moe
1.8 KiB51 linesraw
1message(STATUS "Using RPC backend")
2
3ggml_add_backend_library(ggml-rpc
4                         ggml-rpc.cpp
5                         transport.cpp
6                        )
7
8if (WIN32)
9    target_link_libraries(ggml-rpc PRIVATE ws2_32)
10endif()
11
12# RDMA auto-detection: Linux RoCE/IB via libibverbs, Apple RDMA-over-Thunderbolt via librdma
13if (APPLE)
14    set(RDMA_LIB_NAME rdma)
15    set(RDMA_DESC "Apple RDMA-over-Thunderbolt, UC")
16elseif (NOT WIN32)
17    set(RDMA_LIB_NAME ibverbs)
18    set(RDMA_DESC "auto-detected")
19endif()
20
21if (RDMA_LIB_NAME)
22    find_library(RDMA_LIB ${RDMA_LIB_NAME})
23    if (RDMA_LIB)
24        option(GGML_RPC_RDMA "ggml: enable RDMA transport for RPC" ON)
25    else()
26        option(GGML_RPC_RDMA "ggml: enable RDMA transport for RPC" OFF)
27    endif()
28else()
29    set(GGML_RPC_RDMA OFF CACHE BOOL "RDMA not available on this platform" FORCE)
30endif()
31
32if (GGML_RPC_RDMA)
33    if (NOT RDMA_LIB)
34        find_library(RDMA_LIB ${RDMA_LIB_NAME} REQUIRED)
35    endif()
36    target_compile_definitions(ggml-rpc PRIVATE GGML_RPC_RDMA)
37    if (APPLE)
38        # librdma.dylib only exists on macOS 26.2 and later. Link it weakly so a build made
39        # where it exists still loads where it does not; checked at runtime before use
40        # but with BUILD_SHARED_LIBS=OFF ggml-rpc is a static archive and never links
41        # so the librdma symbols used by transport-apple.cpp stay undefined.
42        target_link_options(ggml-rpc PUBLIC "LINKER:-weak_library,${RDMA_LIB}")
43        target_compile_definitions(ggml-rpc PRIVATE GGML_RPC_RDMA_APPLE)
44        target_sources(ggml-rpc PRIVATE transport-apple.cpp)
45    else()
46        target_link_libraries(ggml-rpc PRIVATE ${RDMA_LIB})
47    endif()
48    message(STATUS "  RDMA transport enabled (${RDMA_DESC})")
49else()
50    message(STATUS "  RDMA transport disabled")
51endif()