Skip to content

Commit d7443da

Browse files
authored
Merge pull request #172 from SharpAI/claude/mac-mini-m6-benchmarking-b1cae5
fix(build): build with Xcode 27 / Swift 6.4
2 parents 318f712 + 8c14389 commit d7443da

8 files changed

Lines changed: 24 additions & 29 deletions

File tree

‎build.sh‎

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ else
5151
exit 1
5252
fi
5353
METALLIB_BUILD_DIR=".build/metallib_build"
54-
METALLIB_DEST=".build/arm64-apple-macosx/release"
54+
# Ask SwiftPM for the real bin dir: Swift 6.4+ builds into .build/out/Products/Release
55+
# instead of .build/arm64-apple-macosx/release.
56+
METALLIB_DEST="$(swift build -c release --show-bin-path)"
5557

5658
rm -rf "$METALLIB_BUILD_DIR"
5759
mkdir -p "$METALLIB_BUILD_DIR"
@@ -77,25 +79,19 @@ fi
7779

7880
popd > /dev/null
7981

80-
# Copy the freshly built metallib next to the binary, explicitly naming it default.metallib for mlx-c
82+
# Copy the freshly built metallib next to the binary. MLX loads a colocated
83+
# mlx.metallib before anything else, so that name guarantees the full kernel set
84+
# wins over the partial default.metallib SwiftPM puts in mlx-swift_Cmlx.bundle.
85+
# default.metallib is kept for mlx-c.
8186
mkdir -p "$METALLIB_DEST"
82-
if [ -f "$METALLIB_BUILD_DIR/lib/mlx.metallib" ]; then
83-
cp "$METALLIB_BUILD_DIR/lib/mlx.metallib" "$METALLIB_DEST/default.metallib"
84-
echo "✅ Built and copied default.metallib to $METALLIB_DEST/"
85-
elif [ -f "$METALLIB_BUILD_DIR/mlx.metallib" ]; then
86-
cp "$METALLIB_BUILD_DIR/mlx.metallib" "$METALLIB_DEST/default.metallib"
87-
echo "✅ Built and copied default.metallib to $METALLIB_DEST/"
88-
else
89-
# Search for it anywhere in the build dir
90-
BUILT=$(find "$METALLIB_BUILD_DIR" -name "mlx.metallib" | head -1)
91-
if [ -n "$BUILT" ]; then
92-
cp "$BUILT" "$METALLIB_DEST/default.metallib"
93-
echo "✅ Built and copied default.metallib to $METALLIB_DEST/"
94-
else
95-
echo "❌ Failed to build mlx.metallib. Check cmake output above."
96-
exit 1
97-
fi
87+
BUILT=$(find "$METALLIB_BUILD_DIR" -name "mlx.metallib" | head -1)
88+
if [ -z "$BUILT" ]; then
89+
echo "❌ Failed to build mlx.metallib. Check cmake output above."
90+
exit 1
9891
fi
92+
cp "$BUILT" "$METALLIB_DEST/mlx.metallib"
93+
cp "$BUILT" "$METALLIB_DEST/default.metallib"
94+
echo "✅ Built and copied mlx.metallib + default.metallib to $METALLIB_DEST/"
9995

10096
# --- 4. Build SwiftLM ---
10197
echo ""
@@ -105,6 +101,6 @@ swift build -c release
105101
echo ""
106102
echo "=============================================="
107103
echo "✅ Build complete!"
108-
echo " Binary: .build/release/SwiftLM"
104+
echo " Binary: $METALLIB_DEST/SwiftLM"
109105
echo " Metallib: $METALLIB_DEST/mlx.metallib"
110106
echo "=============================================="

‎mlx-swift‎

Submodule mlx-swift updated 86 files

‎run_benchmark.sh‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ print_server_log() {
8686
fi
8787
}
8888

89-
export METAL_LIBRARY_PATH="$(pwd)/.build/arm64-apple-macosx/release"
89+
export METAL_LIBRARY_PATH="$(cd .build/release 2>/dev/null && pwd -P)"
9090

9191
if [ -n "${SUITE_OPT:-}" ]; then
9292
# Sub-process invocation from automated matrix — skip interactive menu
@@ -302,9 +302,8 @@ if { [ "$suite_opt" == "5" ] || [ "$suite_opt" == "6" ]; } && [[ "$FULL_MODEL" =
302302
fi
303303

304304
# Quick sanity check
305-
if [ -f ".build/arm64-apple-macosx/release/SwiftLM" ]; then
306-
BIN=".build/arm64-apple-macosx/release/SwiftLM"
307-
elif [ -f ".build/release/SwiftLM" ]; then
305+
# .build/release is a symlink to the real bin dir on every SwiftPM layout
306+
if [ -f ".build/release/SwiftLM" ]; then
308307
BIN=".build/release/SwiftLM"
309308
else
310309
echo "⚠️ SwiftLM release binary not found! Please compile the project by running ./build.sh first."

‎scripts/profiling/mtp_bench.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import urllib.request
3131
import urllib.error
3232

33-
SWIFTLM_PATH = ".build/arm64-apple-macosx/release/SwiftLM"
33+
SWIFTLM_PATH = ".build/release/SwiftLM"
3434
PORT = 5430
3535

3636
CONFIGS = [

‎scripts/profiling/profile_runner.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{"name": "MTP + TurboQuant", "flags": ["--stream-experts", "--mtp", "--num-mtp-tokens", "4", "--turbo-kv"]},
1717
]
1818

19-
SWIFTLM_PATH = ".build/arm64-apple-macosx/release/SwiftLM"
19+
SWIFTLM_PATH = ".build/release/SwiftLM"
2020

2121
def get_physical_ram_gb():
2222
try:

‎scripts/profiling/profile_speculative.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import subprocess, time, json, urllib.request, os, signal
22

3-
SWIFTLM_PATH = ".build/arm64-apple-macosx/release/SwiftLM"
3+
SWIFTLM_PATH = ".build/release/SwiftLM"
44
MAIN_MODEL = "mlx-community/gemma-4-26b-a4b-it-4bit"
55
DRAFT_MODEL = "mlx-community/gemma-4-e4b-it-4bit"
66

‎tests/SwiftBuddyTests/AudioTests.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class AudioTests: XCTestCase {
1212
.deletingLastPathComponent() // SwiftLM
1313

1414
let debugExecutableURL = projectRoot.appendingPathComponent(".build/arm64-apple-macosx/debug/SwiftLM")
15-
let releaseExecutableURL = projectRoot.appendingPathComponent(".build/arm64-apple-macosx/release/SwiftLM")
15+
let releaseExecutableURL = projectRoot.appendingPathComponent(".build/release/SwiftLM")
1616

1717
let executableURL = FileManager.default.fileExists(atPath: debugExecutableURL.path)
1818
? debugExecutableURL

‎tests/SwiftBuddyTests/VLMTests.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class VLMTests: XCTestCase {
4343
.deletingLastPathComponent()
4444

4545
let debugExecutableURL = projectRoot.appendingPathComponent(".build/arm64-apple-macosx/debug/SwiftLM")
46-
let releaseExecutableURL = projectRoot.appendingPathComponent(".build/arm64-apple-macosx/release/SwiftLM")
46+
let releaseExecutableURL = projectRoot.appendingPathComponent(".build/release/SwiftLM")
4747
let executableURL = FileManager.default.fileExists(atPath: debugExecutableURL.path)
4848
? debugExecutableURL
4949
: releaseExecutableURL

0 commit comments

Comments
 (0)