Skip to content

Build fails on macOS ARM when using Homebrew LLVM Clang instead of Apple Clang #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
r-huijts opened this issue Apr 14, 2025 · 1 comment

Comments

@r-huijts
Copy link

r-huijts commented Apr 14, 2025

Summary

On macOS systems (particularly Apple Silicon), the backend build fails when using the LLVM Clang compiler installed via Homebrew (/opt/homebrew/opt/llvm/bin/clang++), due to compatibility issues with Apple's system frameworks.

Problem

When compiling whisper.cpp, the build process triggers thousands of warnings and eventually fails with fatal errors, particularly in ggml-blas.cpp, related to Clang's interpretation of Apple framework headers:

warning: type nullability specifier ‘_Nullable’ is a Clang extension [-Wnullability-extension]
fatal error: too many errors emitted, stopping now [-ferror-limit=]

These warnings originate from system headers like CoreGraphics and CoreVideo, which rely on Clang extensions that Apple Clang supports, but Homebrew LLVM Clang does not.

Solution

Switching back to the default Apple Clang compiler (i.e. clang and clang++ from the Xcode toolchain) resolves the issue.

Suggestion

  • Default to Apple Clang on macOS in the build_whisper.sh script.
@ailunc
Copy link

ailunc commented Apr 16, 2025

Hi! @r-huijts
To force the use of Apple’s Xcode toolchain clang on macOS, you can add a little “OS check” at the top of your build_whisper.sh that overrides CC/CXX to point at /usr/bin/clang and /usr/bin/clang++ (or use xcrun to locate them). Here’s a concrete patch:

--- a/build_whisper.sh
+++ b/build_whisper.sh
@@ -1,6 +1,15 @@
 #!/usr/bin/env bash
 set -e
+
+# On macOS, force Apple Clang (not Homebrew LLVM)
+if [[ "$(uname)" == "Darwin" ]]; then
+  echo "macOS detected – switching to Xcode Clang"
+  # Prefer xcrun if available, fallback to /usr/bin
+  export CC="$(xcrun --find clang 2>/dev/null || echo /usr/bin/clang)"
+  export CXX="$(xcrun --find clang++ 2>/dev/null || echo /usr/bin/clang++)"
+  echo "    CC -> $CC"
+  echo "    CXX -> $CXX"
+fi
+
 # … rest of your build script …

Hope it would work!

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

No branches or pull requests

2 participants