mirror of
https://github.com/mudler/LocalAI.git
synced 2026-07-31 10:28:43 -04:00
backend(audio-cpp): keep the build-tree rpath at $ORIGIN
Upstream sets CMAKE_BUILD_WITH_INSTALL_RPATH in its own directory scope, so CMake was appending its build-tree library dir to our target and baking an absolute build-host path into the shipped binary. Set BUILD_WITH_INSTALL_RPATH on the target so a package that forgets to bundle libggml*.so fails on the build machine too, instead of only on a user's box. Also document why EXCLUDE_FROM_ALL must stay on the add_subdirectory call, correct the claim that Ubuntu ships no gRPC CMake config, stop the pin comment from repeating the assignment token that bump_deps.sh rewrites, and make test-engine fail rather than pass when no test is registered. Assisted-by: Claude:claude-opus-5 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
@@ -33,7 +33,9 @@ if(NOT Protobuf_FOUND)
|
||||
endif()
|
||||
find_package(gRPC CONFIG QUIET)
|
||||
if(NOT gRPC_FOUND)
|
||||
# Ubuntu's apt-installed grpc++ ships no CMake config. Fall back.
|
||||
# Reached only on distros whose grpc++ packaging ships no CMake config.
|
||||
# Ubuntu's libgrpc-dev does ship one, so this is dead code on LocalAI's own
|
||||
# build distro. Kept for the distros that do not.
|
||||
find_library(GRPCPP_LIB grpc++ REQUIRED)
|
||||
find_library(GRPCPP_REFLECTION_LIB grpc++_reflection REQUIRED)
|
||||
add_library(gRPC::grpc++ INTERFACE IMPORTED)
|
||||
@@ -75,6 +77,11 @@ target_link_libraries(hw_grpc_proto PUBLIC protobuf::libprotobuf gRPC::grpc++)
|
||||
|
||||
# Upstream's global add_compile_options(-Wall -Wextra -Wpedantic -pedantic-errors)
|
||||
# is a directory property of the subdirectory and does not reach our targets.
|
||||
#
|
||||
# EXCLUDE_FROM_ALL is load-bearing, do not drop it: upstream's default target set
|
||||
# includes its CLI, server, converter and test binaries, none of which we ship.
|
||||
# Without it every build would compile all of them. The targets we do name in
|
||||
# target_link_libraries below are still built on demand, so nothing is lost.
|
||||
add_subdirectory("${AUDIO_CPP_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/audio-cpp" EXCLUDE_FROM_ALL)
|
||||
|
||||
add_executable(${TARGET}
|
||||
@@ -96,9 +103,16 @@ target_link_libraries(${TARGET} PRIVATE
|
||||
|
||||
# ENGINE_ENABLE_CPU_ALL_VARIANTS builds ggml backends as shared objects that sit
|
||||
# next to the binary in the package, so the binary must search its own directory.
|
||||
# BUILD_WITH_INSTALL_RPATH keeps the build-tree binary at exactly "$ORIGIN".
|
||||
# Upstream sets CMAKE_BUILD_WITH_INSTALL_RPATH in its own directory scope, which
|
||||
# does not reach ours, so without this CMake also appends its build-tree library
|
||||
# directory. That absolute build-host path would survive into the copied binary
|
||||
# and let a package.sh that forgot to bundle libggml*.so still pass on the build
|
||||
# machine while failing everywhere else.
|
||||
set_target_properties(${TARGET} PROPERTIES
|
||||
BUILD_RPATH "$ORIGIN"
|
||||
INSTALL_RPATH "$ORIGIN")
|
||||
INSTALL_RPATH "$ORIGIN"
|
||||
BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
|
||||
if(AUDIO_CPP_GRPC_BUILD_TESTS)
|
||||
enable_testing()
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# audio.cpp backend Makefile.
|
||||
#
|
||||
# Upstream pin lives below as AUDIO_CPP_VERSION?=<sha> so .github/bump_deps.sh
|
||||
# can find and update it, matching the llama-cpp / ds4 convention. The clone
|
||||
# Upstream pin lives below in the AUDIO_CPP_VERSION variable, so
|
||||
# .github/bump_deps.sh can find and update it, matching the llama-cpp / ds4
|
||||
# convention. That script seds every line matching the variable name followed by
|
||||
# an assignment, so this comment deliberately spells the name on its own: a
|
||||
# comment repeating the full assignment token gets rewritten and mangled by the
|
||||
# first auto-bump (backend/cpp/ds4/Makefile shows the damage). The clone
|
||||
# recipe is a make target (not a prepare.sh) so 'make purge && make' is a clean
|
||||
# rebuild and so the bump bot can see the pin.
|
||||
|
||||
@@ -69,7 +73,7 @@ test:
|
||||
test-engine: audio.cpp
|
||||
mkdir -p $(BUILD_DIR)
|
||||
cd $(BUILD_DIR) && cmake $(CMAKE_ARGS) -DAUDIO_CPP_GRPC_BUILD_TESTS=ON $(CURRENT_MAKEFILE_DIR) && \
|
||||
cmake --build . --config Release -j $(JOBS) && ctest --output-on-failure
|
||||
cmake --build . --config Release -j $(JOBS) && ctest --output-on-failure --no-tests=error
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR) grpc-server package
|
||||
|
||||
Reference in New Issue
Block a user