fix(backends): set rpath on the piper darwin binary so it can load its bundled libs#10525
Merged
Conversation
…s bundled libs
The metal-darwin-arm64-piper backend crashed at launch on macOS:
DYLD "Library missing"
Library not loaded: @rpath/libucd.dylib
Referenced from: .../piper
Reason: no LC_RPATH's found
The piper binary links libucd, libespeak-ng, libpiper_phonemize and
libonnxruntime via @rpath, but ships with no LC_RPATH, so dyld cannot
expand @rpath and aborts before piper runs. The libraries themselves are
already bundled in package/lib/ by package.sh.
Additionally, package.sh's architecture detection only handled the Linux
glibc loaders (/lib64/ld-linux-x86-64.so.2, /lib/ld-linux-aarch64.so.1)
and otherwise hit `echo "Error: Could not detect architecture"; exit 1`,
so on macOS packaging failed outright.
Add a Darwin branch (before the Linux checks) that skips the glibc/ld.so
bundling macOS has no use for and instead runs
`install_name_tool -add_rpath @loader_path/lib` on the piper binary, so
@rpath resolves to the bundled package/lib/ directory.
Also mirror sherpa-onnx/opus in run.sh: export DYLD_LIBRARY_PATH on
Darwin (LD_LIBRARY_PATH is Linux-only) as a defensive fallback.
Validated by hand on Apple Silicon: with the rpath added, piper
synthesized a real WAV. The darwin build is validated in CI.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
mudler
added a commit
that referenced
this pull request
Jun 26, 2026
…ckend) (#10528) fix(backends): darwin packaging for silero-vad silero-vad was the last Go backend with Linux-only darwin packaging: - package.sh fell through to "Could not detect architecture" -> exit 1 on macOS (no Darwin branch), so its darwin image never packaged. - run.sh exported LD_LIBRARY_PATH, which macOS dyld ignores, so the bundled libonnxruntime.dylib couldn't be found at runtime. Add a Darwin branch to package.sh (skip the glibc/ld.so bundling; add an @loader_path/lib rpath so @rpath resolves to package/lib/) and a DYLD_LIBRARY_PATH branch to run.sh — mirroring the piper darwin fix (#10525). Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
metal-darwin-arm64-piperbackend crashes at launch on macOS (Apple Silicon). The crash report is unambiguous:The
piperbinary linkslibucd.dylib(andlibespeak-ng,libpiper_phonemize,libonnxruntime) via@rpath, but the binary ships with noLC_RPATH, so dyld cannot expand@rpathand aborts before piper runs. The libraries themselves are already bundled correctly inpackage/lib/bypackage.sh(it copiessources/go-piper/piper-phonemize/pi/lib/*). The only missing piece is an rpath.There is a second, related bug in the same file:
package.sh's architecture detection only handled the Linux glibc loaders (/lib64/ld-linux-x86-64.so.2,/lib/ld-linux-aarch64.so.1) and otherwise hitecho "Error: Could not detect architecture"; exit 1. On macOS thatelsefires, so packaging fails outright.Fix
In
backend/go/piper/package.sh, add aDarwinbranch before the Linux checks that:ld.sobundling (macOS has no glibc loader), andinstall_name_tool -add_rpath @loader_path/libon the piper binary, so@rpathresolves to the bundledpackage/lib/directory (which sits next to the binary).Also mirror the sibling
sherpa-onnx/opusdarwin fix (#10523) inrun.sh: exportDYLD_LIBRARY_PATHon Darwin (LD_LIBRARY_PATHis Linux-only and ignored by macOS) as a defensive fallback. The rpath inpackage.shis the actual validated fix.Validation
@loader_path/librpath added to the piper binary, piper synthesized a real WAV.bash -npasses on both scripts; the new Darwin branch precedes the Linux checks and the Linux packaging paths are unchanged.Assisted-by: Claude:claude-opus-4-8