fix(build): build with Xcode 27 / Swift 6.4 - #172
Merged
Merged
Conversation
- 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
marked this pull request as ready for review
September 24, 2026 03:22
5 tasks
…nchmarking-b1cae5
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.
Problem
./build.shfails on a fresh macOS 27.0 machine (an M6 Mac mini) with Xcode 27 and Swift 6.4. There are two separate problems:thisinside a member function no longer defaults to thethreadaddress space. 17 of the 40 MLX kernels fail to compile, including every quantized matmul kernel, somlx.metallibisn't built..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
mlx-swiftto fix(metal): build with Xcode 27 / Metal 4.1 (explicit thread on member functions) mlx-swift#16. It backports Fix implicitthreadaddress space qualifier becoming explicit in metal 4.1 ml-explore/mlx#3963 and applies the same fix to the older NAX tile structs. See that PR for the details.build.sh: get the bin dir fromswift build -c release --show-bin-path, and copy the metallib there asmlx.metallib. MLX loads a colocatedmlx.metallibbefore anything else, so the full 128 MB kernel set always takes priority over the 3.8 MB partialdefault.metallibthat SwiftPM puts inmlx-swift_Cmlx.bundle.default.metallibis still copied for mlx-c..build/release/SwiftLM, which is a symlink to the real bin dir on both the old and new SwiftPM layouts.run_benchmark.shnow resolvesMETAL_LIBRARY_PATHthrough the same symlink.scripts/build.shis left alone. It's an older duplicate ofbuild.sh; tell me if it should be removed or brought in line.Verification
./build.shfinishes and writesmlx.metallibanddefault.metallib(128 MB each) to.build/out/Products/Release/.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.🤖 Generated with Claude Code