Skip to content

fix(build): build with Xcode 27 / Swift 6.4 - #172

Merged
solderzzc merged 2 commits into
mainfrom
claude/mac-mini-m6-benchmarking-b1cae5
Sep 24, 2026
Merged

solderzzc merged 2 commits into
mainfrom
claude/mac-mini-m6-benchmarking-b1cae5

Conversation

@solderzzc

@solderzzc solderzzc commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Problem

./build.sh fails on a fresh macOS 27.0 machine (an M6 Mac mini) with Xcode 27 and Swift 6.4. There are two separate problems:

  1. Metal 4.1 (Xcode 27): this inside a member function no longer defaults to the thread address space. 17 of the 40 MLX kernels fail to compile, including every quantized matmul kernel, so mlx.metallib isn't built.
  2. Swift 6.4 build layout: products now go to .build/out/Products/Release/. build.sh, run_benchmark.sh, the profiling scripts and two tests all hard-code .build/arm64-apple-macosx/release/. As a result the metallib is copied to a directory the binary never looks in, and the scripts can't find the binary.

Changes

scripts/build.sh is left alone. It's an older duplicate of build.sh; tell me if it should be removed or brought in line.

Verification

  • Starting with no metallib in the bin dir, ./build.sh finishes and writes mlx.metallib and default.metallib (128 MB each) to .build/out/Products/Release/.
  • Inference smoke test on M6 (Qwen3.8-27B-4bit, running from .build/release/SwiftLM): all correct, including a code word retrieved from a 7.9K-token prompt; decode 9.0 tok/s. Merge after fix(metal): build with Xcode 27 / Metal 4.1 (explicit thread on member functions) mlx-swift#16.
  • Xcode 26.3, run by the Mac M5 session: at 5ae50ec, build + SwiftLMTests 167/167; at 8c14389 (main 318f712 merged in, mlx-swift-lm 460ff81), build + SwiftLMTests 179/179.

🤖 Generated with Claude Code

- Bump mlx-swift to SharpAI/mlx-swift#16. Metal 4.1 (Xcode 27) no longer
  treats `this` as `thread` in member functions, which broke 17 of 40 MLX
  kernels, including all quantized matmuls, so mlx.metallib failed to build.
- build.sh: Swift 6.4 builds into .build/out/Products/Release, not
  .build/arm64-apple-macosx/release. Ask SwiftPM for the bin dir with
  `--show-bin-path`, and copy the metallib there as mlx.metallib. MLX loads
  a colocated mlx.metallib first, so it takes priority over the partial
  default.metallib in mlx-swift_Cmlx.bundle. default.metallib is still
  copied for mlx-c.
- Scripts and tests: use .build/release/SwiftLM, which is a symlink to the
  real bin dir on both the old and new SwiftPM layouts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@solderzzc
solderzzc marked this pull request as ready for review September 24, 2026 03:22
@solderzzc
solderzzc merged commit d7443da into main Sep 24, 2026
14 checks passed
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.

1 participant