mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-14 19:58:44 -04:00
* fix(darwin): never package a go backend build tree as a working image
The darwin/arm64 vibevoice-cpp image shipped the source tree with a
half-built CMake directory (build-libgovibevoicecpp-fallback.so/) and no
backend binary, so the backend could never start: run.sh exec'd a
vibevoice-cpp binary that was not in the package and LocalAI timed out
waiting for the gRPC service.
Two durable, backend-agnostic defenses:
- backend/go/vibevoice-cpp/Makefile: mirror whisper's cleanup discipline so a
partial CMake tree cannot survive into packaging. Run `make purge` before
each variant build and `rm -rfv build*` after. The old recipe only removed
its build dir after a successful `mv`, so a failed build left the half-built
tree behind.
- scripts/build/golang-darwin.sh: before creating the OCI image, remove any
stray build-* directory and assert that the binary run.sh launches actually
exists. A build that produced no binary now fails the job loudly instead of
publishing a source tree as a working backend. The binary name is derived
from run.sh's `exec $CURDIR/<binary>` line (parakeet-cpp launches
parakeet-cpp-grpc, so it is not always ${BACKEND}) with a ${BACKEND}
fallback.
The underlying native build failure that left vibevoice-cpp half-built still
needs to be reproduced and fixed on Apple Silicon; this change ensures such a
failure can never again be published as a working image.
Refs #10267
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-8 [Claude Code]
* fix(vibevoice-cpp): build libvibevoice.a on darwin (link target, not path)
The darwin build failed with:
No rule to make target 'vibevoice/libvibevoice.a', needed by
'libgovibevoicecpp.so'. Stop.
The upstream vibevoice project is added with add_subdirectory(... EXCLUDE_FROM_ALL),
so its `vibevoice` static-library target is only built when something links it
as a target. The Apple branch linked only `$<TARGET_FILE:vibevoice>` - a bare
archive path with no target reference - so CMake never emitted a rule to build
libvibevoice.a, while the Linux branch worked because it passes the `vibevoice`
target name inside the --whole-archive flags.
Link the `vibevoice` target on Apple (establishing the build dependency) and
apply -force_load as a separate link option to keep whole-archive semantics so
purego can dlsym the vv_capi_* symbols.
Refs #10267
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-8 [Claude Code]
---------
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
80 lines
3.5 KiB
CMake
80 lines
3.5 KiB
CMake
cmake_minimum_required(VERSION 3.18)
|
|
project(govibevoicecpp LANGUAGES C CXX)
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
set(VIBEVOICE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sources/vibevoice.cpp)
|
|
|
|
# Override upstream's CMAKE_CUDA_ARCHITECTURES before add_subdirectory.
|
|
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
|
|
set(CMAKE_CUDA_ARCHITECTURES "75-virtual;80-virtual;86-real;89-real")
|
|
endif()
|
|
|
|
# Force-disable upstream tests/examples — we only need libvibevoice.
|
|
set(VIBEVOICE_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|
set(VIBEVOICE_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
|
set(VIBEVOICE_BUILD_SERVER OFF CACHE BOOL "" FORCE)
|
|
|
|
# vibevoice.cpp's top-level CMakeLists already adds third_party/ggml as a
|
|
# subdirectory — no need to add it explicitly here, just include the
|
|
# whole project.
|
|
add_subdirectory(${VIBEVOICE_DIR} vibevoice EXCLUDE_FROM_ALL)
|
|
|
|
add_library(govibevoicecpp MODULE cpp/govibevoicecpp.cpp)
|
|
|
|
# libvibevoice is STATIC; without --whole-archive the linker GCs the
|
|
# vv_capi_* symbols (purego dlopens them by name, nothing in our
|
|
# translation unit references them). Force the static archive's
|
|
# entire contents into the MODULE so dlsym finds vv_capi_load etc.
|
|
#
|
|
# Link the `vibevoice` TARGET (not a bare archive path) so CMake builds
|
|
# libvibevoice.a first and tracks the dependency: the upstream project is added
|
|
# with EXCLUDE_FROM_ALL, so without a target-level link there is no rule to
|
|
# build it. Passing only $<TARGET_FILE:vibevoice> as a path on Apple left the
|
|
# build with "No rule to make target 'vibevoice/libvibevoice.a'" (issue #10267).
|
|
# force_load is then applied as a separate link option.
|
|
if(APPLE)
|
|
target_link_libraries(govibevoicecpp PRIVATE vibevoice)
|
|
target_link_options(govibevoicecpp PRIVATE "-Wl,-force_load,$<TARGET_FILE:vibevoice>")
|
|
elseif(MSVC)
|
|
target_link_libraries(govibevoicecpp PRIVATE vibevoice)
|
|
set_property(TARGET govibevoicecpp APPEND PROPERTY LINK_FLAGS "/WHOLEARCHIVE:vibevoice")
|
|
else()
|
|
target_link_libraries(govibevoicecpp PRIVATE
|
|
-Wl,--whole-archive vibevoice -Wl,--no-whole-archive)
|
|
endif()
|
|
|
|
target_include_directories(govibevoicecpp PRIVATE ${VIBEVOICE_DIR}/include)
|
|
target_include_directories(govibevoicecpp SYSTEM PRIVATE ${VIBEVOICE_DIR}/third_party/ggml/include)
|
|
|
|
# Link GPU backends if available — vibevoice's own CMake already links
|
|
# these to the libvibevoice STATIC library, but we re-link them on the
|
|
# MODULE so resolved symbols include all backend kernels.
|
|
foreach(backend blas cuda metal vulkan)
|
|
if(TARGET ggml-${backend})
|
|
target_link_libraries(govibevoicecpp PRIVATE ggml-${backend})
|
|
string(TOUPPER ${backend} BACKEND_UPPER)
|
|
target_compile_definitions(govibevoicecpp PRIVATE VIBEVOICE_HAVE_${BACKEND_UPPER})
|
|
if(backend STREQUAL "cuda")
|
|
find_package(CUDAToolkit QUIET)
|
|
if(CUDAToolkit_FOUND)
|
|
target_link_libraries(govibevoicecpp PRIVATE CUDA::cudart)
|
|
endif()
|
|
endif()
|
|
endif()
|
|
endforeach()
|
|
|
|
if(MSVC)
|
|
target_compile_options(govibevoicecpp PRIVATE /W4 /wd4100 /wd4505)
|
|
else()
|
|
target_compile_options(govibevoicecpp PRIVATE -Wall -Wextra -Wshadow
|
|
-Wno-unused-parameter -Wno-unused-function -Wno-sign-conversion)
|
|
endif()
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
|
|
target_link_libraries(govibevoicecpp PRIVATE stdc++fs)
|
|
endif()
|
|
|
|
set_property(TARGET govibevoicecpp PROPERTY CXX_STANDARD 17)
|
|
set_target_properties(govibevoicecpp PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|