diff --git a/backend/cpp/audio-cpp/CMakeLists.txt b/backend/cpp/audio-cpp/CMakeLists.txt index 1e784cde8..3b5f36278 100644 --- a/backend/cpp/audio-cpp/CMakeLists.txt +++ b/backend/cpp/audio-cpp/CMakeLists.txt @@ -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() diff --git a/backend/cpp/audio-cpp/Makefile b/backend/cpp/audio-cpp/Makefile index 4adf0228f..c32d34a2f 100644 --- a/backend/cpp/audio-cpp/Makefile +++ b/backend/cpp/audio-cpp/Makefile @@ -1,7 +1,11 @@ # audio.cpp backend Makefile. # -# Upstream pin lives below as AUDIO_CPP_VERSION?= 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