fix(backends): make the opus backend build and package on macOS/Darwin#10523
Merged
Conversation
The opus Go backend (WebRTC audio codec) never built on macOS, so the published master-metal-darwin-arm64-opus image shipped source only — no opus binary and no libopusshim — because every step assumed Linux. - Makefile: hardcoded libopusshim.so with no OS handling. Mirror sherpa-onnx: SHIM_EXT=so / dylib on Darwin and build libopusshim.$(SHIM_EXT). On Darwin link the shim with -undefined dynamic_lookup so it resolves opus_encoder_ctl from the already globally-loaded libopus (codec.go dlopens it RTLD_GLOBAL first) instead of baking an absolute Homebrew path into the dylib, keeping the packaged shim relocatable. - run.sh: hardcoded LD_LIBRARY_PATH + libopusshim.so even on macOS. Add a Darwin branch exporting DYLD_LIBRARY_PATH and the .dylib shim, like sherpa-onnx/run.sh. - package.sh: bundle libopusshim.$(SHIM_EXT) and libopus*.dylib (not just .so) into package/lib so the OCI image (which ships package/.) is self-contained on a runtime with no Homebrew; add a Darwin arch branch so it doesn't warn/skip. - backend_build_darwin.yml: install + link opus and pkg-config via brew so the Makefile's `pkg-config opus` resolves on the macOS runner, and cache opus' Cellar dir. Go code is unchanged; darwin build is validated in CI. Assisted-by: Claude:claude-opus-4-8 Signed-off-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.
What
Fixes the opus Go backend (realtime WebRTC audio codec) build on macOS / Apple Silicon (Metal). Today the published
master-metal-darwin-arm64-opusimage ships source only — noopusbinary and nolibopusshim— because every build/packaging step assumed Linux.Why
backend/go/opus/{Makefile,run.sh,package.sh}hardcode the Linux shim name (libopusshim.so),LD_LIBRARY_PATH, and Linux-only library bundling, somake -C backend/go/opus buildfails on Darwin andgolang-darwin.shpackages a binary-less tree (cf. the issue #10267 class of "ships sources, no binary"). The matrix entry underincludeDarwin:already exists; only the backend's build was broken.How
sherpa-onnx:SHIM_EXT=so/dylibon Darwin, buildlibopusshim.$(SHIM_EXT), and reference the variable in every target + clean. On Darwin the shim is linked with-undefined dynamic_lookupsoopus_encoder_ctlresolves from the already globally-loaded libopus (codec.godlopens libopusRTLD_GLOBALbefore the shim) — this avoids baking an absolute Homebrew install-name into the dylib and keeps the packaged shim relocatable.DYLD_LIBRARY_PATH+OPUS_SHIM_LIBRARY=…/libopusshim.dylib(Linux keepsLD_LIBRARY_PATH+.so), matchingsherpa-onnx/run.sh.$CURDIRstays quoted.libopusshim.$(SHIM_EXT)andlibopus*.dylib(in addition tolibopus.so*) intopackage/lib, and add a Darwin arch branch (system libs are linked dynamically, nold.soneeded). This makespackage/.self-contained on a runtime with no Homebrew.brew install/brew linkopus+pkg-config(the Makefile/package.sh callpkg-config opus), and cache opus' Cellar dir.Verification
bash -nclean onrun.sh+package.sh.go build ./andgo vet ./clean inbackend/go/opus/(Go code unchanged).libopusshim.so(+pkg-config --libs opus); Darwin →libopusshim.dylib -undefined dynamic_lookup.🤖 Generated with Claude Code