Skip to content

fix(backends): darwin/metal support for supertonic#10488

Merged
mudler merged 1 commit into
masterfrom
feat/darwin-supertonic
Jun 24, 2026
Merged

fix(backends): darwin/metal support for supertonic#10488
mudler merged 1 commit into
masterfrom
feat/darwin-supertonic

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

What

Adds macOS (darwin-arm64 / Metal) build and runtime support to the supertonic Go TTS backend, which dlopens ONNX Runtime via purego (yalue/onnxruntime_go).

The backend's runtime/packaging scripts were Linux-only. This applies the same purego .dylib / DYLD_LIBRARY_PATH fix that PR #10481 landed for 15 other ONNX/purego backends (sherpa-onnx, silero-vad, etc.) - supertonic was omitted from that PR - and wires the darwin CI build, resolving the inconsistency where backend/index.yaml advertised metal for supertonic but no includeDarwin matrix entry actually built the image.

The 4-layer dylib fix (mirroring sherpa-onnx)

  • run.sh: on darwin export DYLD_LIBRARY_PATH (keep LD_LIBRARY_PATH for Linux), point ONNXRUNTIME_LIB_PATH at libonnxruntime.dylib, and guard the ld.so exec path to Linux only (macOS has no ld.so loader).
  • package.sh: recognize Darwin (elif [ $(uname -s) = "Darwin" ]) instead of erroring out; the bundled .dylib is resolved via DYLD_LIBRARY_PATH, with no glibc/ld.so to bundle.
  • helper.go: platform-native default library extension (.dylib on runtime.GOOS == "darwin", .so elsewhere) for the last-resort dlopen fallback. Build-tag-free, compiles on both OSes.
  • Makefile: no change needed - it already detects Darwin/osx/arm64 and stages the per-OS ONNX Runtime tarball (backend-assets/lib copies sources/onnxruntime/lib/*, which is .dylib on macOS), exactly like sherpa-onnx.

CI / gallery wiring

  • .github/backend-matrix.yml: add the -metal-darwin-arm64-supertonic entry to includeDarwin (lang: "go", build-type: "metal").
  • backend/index.yaml: declare metal capabilities on the supertonic and supertonic-development entries, and add the concrete metal-supertonic / metal-supertonic-development child entries (mirroring metal-sherpa-onnx).

Verification

  • python3 -c "import yaml; yaml.safe_load(...)" passes for both backend/index.yaml and .github/backend-matrix.yml.
  • The Go package still compiles on Linux (go build ./... after make protogen-go); go vet is clean.
  • The darwin CI build (this matrix entry) validates the image builds on Apple Silicon. Runtime TTS inference on Apple Silicon is pending (no local M-series hardware available to the author).

Assisted-by: Claude:opus-4.8 [Claude Code]

The supertonic Go TTS backend dlopens ONNX Runtime, but its runtime and
packaging scripts were Linux-only: run.sh exported LD_LIBRARY_PATH, pointed
ONNXRUNTIME_LIB_PATH at libonnxruntime.so, and always tried the ld.so exec
path, while package.sh hard-failed on any non-Linux host. On macOS dyld has
no ld.so loader, uses DYLD_LIBRARY_PATH, and ONNX Runtime ships as a .dylib.

This applies the same purego .dylib/DYLD_LIBRARY_PATH fix that PR #10481
landed for 15 other ONNX/purego backends (sherpa-onnx, silero-vad, etc.) but
which omitted supertonic:

- run.sh: on darwin export DYLD_LIBRARY_PATH and point ONNXRUNTIME_LIB_PATH
  at libonnxruntime.dylib; guard the ld.so exec path to Linux only.
- package.sh: recognize Darwin instead of erroring out; the bundled .dylib is
  resolved via DYLD_LIBRARY_PATH, no glibc/ld.so to bundle.
- helper.go: platform-native default library extension (dylib on darwin) for
  the last-resort dlopen fallback.

It also wires the darwin CI build and gallery entries, resolving the
inconsistency where backend/index.yaml advertised metal for supertonic but no
includeDarwin matrix entry built the image:

- .github/backend-matrix.yml: add the -metal-darwin-arm64-supertonic Go entry.
- backend/index.yaml: declare metal capabilities and add the concrete
  metal-supertonic / metal-supertonic-development child entries.

The Makefile already detects Darwin/osx/arm64 and stages the per-OS ONNX
Runtime tarball, mirroring sherpa-onnx, so no Makefile change is required.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:opus-4.8 [Claude Code]
@mudler mudler merged commit 193d0e6 into master Jun 24, 2026
61 checks passed
@mudler mudler deleted the feat/darwin-supertonic branch June 24, 2026 20:19
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