Skip to content

fix(backends): set rpath on the piper darwin binary so it can load its bundled libs#10525

Merged
mudler merged 1 commit into
masterfrom
fix/piper-darwin-rpath
Jun 26, 2026
Merged

fix(backends): set rpath on the piper darwin binary so it can load its bundled libs#10525
mudler merged 1 commit into
masterfrom
fix/piper-darwin-rpath

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

Problem

The metal-darwin-arm64-piper backend crashes at launch on macOS (Apple Silicon). The crash report is unambiguous:

termination: DYLD "Library missing"
  Library not loaded: @rpath/libucd.dylib
  Referenced from: .../piper
  Reason: no LC_RPATH's found

The piper binary links libucd.dylib (and libespeak-ng, libpiper_phonemize, libonnxruntime) via @rpath, but the binary ships with no LC_RPATH, so dyld cannot expand @rpath and aborts before piper runs. The libraries themselves are already bundled correctly in package/lib/ by package.sh (it copies sources/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 hit echo "Error: Could not detect architecture"; exit 1. On macOS that else fires, so packaging fails outright.

Fix

In backend/go/piper/package.sh, add a Darwin branch before the Linux checks that:

  • skips the glibc/ld.so bundling (macOS has no glibc loader), and
  • runs install_name_tool -add_rpath @loader_path/lib on the piper binary, so @rpath resolves to the bundled package/lib/ directory (which sits next to the binary).

Also mirror the sibling sherpa-onnx/opus darwin fix (#10523) in run.sh: export DYLD_LIBRARY_PATH on Darwin (LD_LIBRARY_PATH is Linux-only and ignored by macOS) as a defensive fallback. The rpath in package.sh is the actual validated fix.

Validation

  • Validated by hand on Apple Silicon: with the @loader_path/lib rpath added to the piper binary, piper synthesized a real WAV.
  • The darwin build is validated in CI.
  • On Linux (where this PR was authored): bash -n passes 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

…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
mudler merged commit 068d397 into master Jun 26, 2026
60 of 61 checks passed
@mudler
mudler deleted the fix/piper-darwin-rpath branch June 26, 2026 13:10
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants