Skip to content

Commit fe3e1c2

Browse files
committed
fix(build): update iOS build configuration for universal binary support
1 parent 3acfe3e commit fe3e1c2

2 files changed

Lines changed: 15 additions & 25 deletions

File tree

.github/workflows/main.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ permissions:
99
jobs:
1010
build:
1111
runs-on: ${{ matrix.os }}
12-
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'isim' && matrix.name != 'ios' && ' + test' || ''}}
12+
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'ios' && ' + test' || ''}}
1313
timeout-minutes: 120
1414
strategy:
1515
fail-fast: false
@@ -26,12 +26,11 @@ jobs:
2626
- os: macos-latest
2727
name: macos
2828
make: LLAMA="-DGGML_NATIVE=ON -DGGML_METAL=ON -DGGML_ACCELERATE=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=Apple -DGGML_LLAMAFILE=ON" WHISPER="-DGGML_METAL=ON -DGGML_ACCELERATE=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=Apple -DWHISPER_COREML=ON -DWHISPER_COREML_ALLOW_FALLBACK=ON"
29-
30-
# Windows builds
3129
- os: windows-latest
3230
arch: x86_64
3331
name: windows
3432
make: LLAMA="-DGGML_NATIVE=OFF -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DGGML_VULKAN=ON -DGGML_OPENCL=ON -DGGML_LLAMAFILE=ON"
33+
3534
- os: windows-latest
3635
arch: x86_64
3736
name: windows-gpu
@@ -50,14 +49,10 @@ jobs:
5049
name: android
5150
make: PLATFORM=android ARCH=x86_64
5251
sqlite-amalgamation-zip: https://sqlite.org/2025/sqlite-amalgamation-3490100.zip
53-
54-
# iOS builds
52+
5553
- os: macos-latest
5654
name: ios
57-
make: PLATFORM=ios
58-
- os: macos-latest
59-
name: isim
60-
make: PLATFORM=isim
55+
make: PLATFORM=ios LLAMA="-DGGML_METAL=ON -DGGML_ACCELERATE=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=Apple" WHISPER="-DGGML_METAL=ON -DGGML_ACCELERATE=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=Apple -DWHISPER_COREML=ON -DWHISPER_COREML_ALLOW_FALLBACK=ON"
6156

6257
defaults:
6358
run:

Makefile

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -226,23 +226,19 @@ else ifeq ($(PLATFORM),android)
226226
STRIP = $(BIN)/llvm-strip --strip-unneeded $@
227227
else ifeq ($(PLATFORM),ios)
228228
TARGET := $(DIST_DIR)/ai.dylib
229-
SDK := -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=14.0
229+
# Build universal binary for both device (arm64) and simulator (x86_64+arm64)
230+
DEVICE_SDK := $(shell xcrun --sdk iphoneos --show-sdk-path)
231+
SIMULATOR_SDK := $(shell xcrun --sdk iphonesimulator --show-sdk-path)
230232
LLAMA_LIBS += $(BUILD_LLAMA)/ggml/src/ggml-metal/libggml-metal.a $(BUILD_LLAMA)/ggml/src/ggml-blas/libggml-blas.a
231233
WHISPER_LDFLAGS += -lwhisper.coreml
232-
LDFLAGS += -L./$(BUILD_LLAMA)/ggml/src/ggml-metal -lggml-metal -L./$(BUILD_LLAMA)/ggml/src/ggml-blas -lggml-blas -framework Accelerate -framework Metal -framework Foundation -framework CoreML -framework AVFoundation -framework AudioToolbox -framework CoreAudio -framework Security -ldl -dynamiclib $(SDK)
233-
CFLAGS += -arch arm64 -x objective-c $(SDK)
234-
LLAMA_OPTIONS += -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0
235-
WHISPER_OPTIONS += -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 -DWHISPER_COREML=ON
234+
# Universal binary supporting both device and simulator
235+
LDFLAGS += -arch arm64 -arch x86_64 -L./$(BUILD_LLAMA)/ggml/src/ggml-metal -lggml-metal -L./$(BUILD_LLAMA)/ggml/src/ggml-blas -lggml-blas -framework Accelerate -framework Metal -framework Foundation -framework CoreML -framework AVFoundation -framework AudioToolbox -framework CoreAudio -framework Security -ldl -dynamiclib -miphoneos-version-min=14.0 -miphonesimulator-version-min=14.0
236+
CFLAGS += -arch arm64 -arch x86_64 -x objective-c -miphoneos-version-min=14.0 -miphonesimulator-version-min=14.0
237+
# Configure for universal iOS build (device + simulator)
238+
LLAMA_OPTIONS += -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS="iphoneos iphonesimulator"
239+
WHISPER_OPTIONS += -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS="iphoneos iphonesimulator" -DWHISPER_COREML=ON
240+
MINIAUDIO_OPTIONS += -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS="iphoneos iphonesimulator"
236241
STRIP = strip -x -S $@
237-
else ifeq ($(PLATFORM),isim)
238-
TARGET := $(DIST_DIR)/ai.dylib
239-
SDK := -isysroot $(shell xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=14.0
240-
LLAMA_LIBS += $(BUILD_LLAMA)/ggml/src/ggml-metal/libggml-metal.a $(BUILD_LLAMA)/ggml/src/ggml-blas/libggml-blas.a
241-
WHISPER_LDFLAGS += -lwhisper.coreml
242-
LDFLAGS += -arch x86_64 -arch arm64 -L./$(BUILD_LLAMA)/ggml/src/ggml-metal -lggml-metal -L./$(BUILD_LLAMA)/ggml/src/ggml-blas -lggml-blas -framework Accelerate -framework Metal -framework Foundation -framework CoreML -framework AVFoundation -framework AudioToolbox -framework CoreAudio -framework Security -ldl -dynamiclib $(SDK)
243-
CFLAGS += -arch x86_64 -arch arm64 -x objective-c $(SDK)
244-
LLAMA_OPTIONS += -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
245-
WHISPER_OPTIONS += -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DWHISPER_COREML=ON
246242
else # linux
247243
TARGET := $(DIST_DIR)/ai.so
248244
LDFLAGS += -shared
@@ -448,8 +444,7 @@ help:
448444
@echo " macos (default on macOS)"
449445
@echo " windows (default on Windows)"
450446
@echo " android (needs ARCH to be set to x86_64 or arm64-v8a and ANDROID_NDK to be set)"
451-
@echo " ios (only on macOS)"
452-
@echo " isim (only on macOS)"
447+
@echo " ios (universal binary for device and simulator, only on macOS)"
453448
@echo ""
454449
@echo "Targets:"
455450
@echo " all - Build the extension (default)"

0 commit comments

Comments
 (0)