Skip to content

fix(fish-speech): allow invalid_reference_casting so tokenizers builds on darwin#10573

Merged
mudler merged 1 commit into
masterfrom
fix/fish-speech-darwin-tokenizers-rust
Jun 28, 2026
Merged

fix(fish-speech): allow invalid_reference_casting so tokenizers builds on darwin#10573
mudler merged 1 commit into
masterfrom
fix/fish-speech-darwin-tokenizers-rust

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

Failure

In the v4.5.5 release CI, the fish-speech backend image build job FAILED on darwin/metal arm64 (mps profile). All Linux variants (cpu/cublas/etc) built fine.

The failure happens during the editable install of fish-speech source (pip install --no-build-isolation -e ... in backend/python/fish-speech/install.sh):

error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
error: could not compile `tokenizers` (lib) due to 1 previous error; 8 warnings emitted
error: `cargo rustc ... --crate-type cdylib ...` failed with code 101
ERROR: Failed building wheel for tokenizers
Failed to build tokenizers
make[1]: *** [fish-speech] Error 1

Root cause

On darwin arm64 the transitive tokenizers Python package compiles its Rust extension from source, because there is no prebuilt manylinux wheel for that platform. (On Linux the prebuilt wheel is used, so the Rust code never compiles there - which is why only the darwin job broke.)

The pinned tokenizers crate that fish-speech's dependency stack resolves to contains a &T -> &mut T cast. That pattern is flagged by the invalid_reference_casting lint, which is deny-by-default in the macOS CI runner's newer Rust toolchain. It compiled under the older toolchain but is now rejected.

Fix

Export RUSTFLAGS with -A invalid_reference_casting before installRequirements in backend/python/fish-speech/install.sh, so the unchanged third-party crate compiles as it did before the toolchain bump. The flag is appended to any existing RUSTFLAGS rather than clobbering it.

This is version-agnostic (no risky dependency repin) and harmless on Linux, where no Rust compile happens.

…s on darwin

On darwin arm64 the fish-speech editable install (pip install
--no-build-isolation -e) compiles the transitive `tokenizers` Python
package's Rust extension from source, because there is no prebuilt
manylinux wheel for that platform (Linux builds never compile it, so this
only breaks on macOS). The pinned tokenizers crate fish-speech's stack
resolves to contains a `&T` -> `&mut T` cast that the macOS CI runner's
newer Rust toolchain rejects via the now-deny-by-default
`invalid_reference_casting` lint:

    error: casting `&T` to `&mut T` is undefined behavior ...
    error: could not compile `tokenizers` (lib) due to 1 previous error
    ERROR: Failed building wheel for tokenizers

This failed the fish-speech darwin/metal (mps) backend image build in the
v4.5.5 release CI while all Linux variants built fine.

Fix: export RUSTFLAGS with `-A invalid_reference_casting` (appended to any
existing value, not clobbering) before installRequirements so the
unchanged third-party crate compiles as it did under the older toolchain.
Version-agnostic and harmless on Linux, where no Rust compile happens.

Assisted-by: Claude:claude-opus-4-8 [Claude Code]
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler mudler merged commit 3d2f639 into master Jun 28, 2026
66 checks passed
@mudler mudler deleted the fix/fish-speech-darwin-tokenizers-rust branch June 28, 2026 17:10
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