Skip to content

Commit 91ea5d6

Browse files
authored
build : fix libtool call in build-xcframework.sh (ggml-org#19605)
Run libtool via xcrun like strip and dsymutil, to have proper tool resolution. Signed-off-by: Adrien Gallouët <angt@huggingface.co>
1 parent dbb0233 commit 91ea5d6

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

build-xcframework.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ COMMON_CMAKE_ARGS=(
4343
-DGGML_OPENMP=${GGML_OPENMP}
4444
)
4545

46-
XCODE_VERSION=$(xcodebuild -version 2>/dev/null | head -n1 | awk '{ print $2 }')
47-
MAJOR_VERSION=$(echo $XCODE_VERSION | cut -d. -f1)
48-
MINOR_VERSION=$(echo $XCODE_VERSION | cut -d. -f2)
49-
echo "Detected Xcode version: $XCODE_VERSION"
50-
5146
check_required_tool() {
5247
local tool=$1
5348
local install_message=$2
@@ -60,9 +55,12 @@ check_required_tool() {
6055
}
6156
echo "Checking for required tools..."
6257
check_required_tool "cmake" "Please install CMake 3.28.0 or later (brew install cmake)"
63-
check_required_tool "xcodebuild" "Please install Xcode and Xcode Command Line Tools (xcode-select --install)"
64-
check_required_tool "libtool" "Please install libtool which should be available with Xcode Command Line Tools (CLT). Make sure Xcode CLT is installed (xcode-select --install)"
65-
check_required_tool "dsymutil" "Please install Xcode and Xcode Command Line Tools (xcode-select --install)"
58+
check_required_tool "xcrun" "Please install Xcode and Xcode Command Line Tools (xcode-select --install)"
59+
60+
XCODE_VERSION=$(xcrun xcodebuild -version 2>/dev/null | head -n1 | awk '{ print $2 }')
61+
MAJOR_VERSION=$(echo $XCODE_VERSION | cut -d. -f1)
62+
MINOR_VERSION=$(echo $XCODE_VERSION | cut -d. -f2)
63+
echo "Detected Xcode version: $XCODE_VERSION"
6664

6765
set -e
6866

@@ -260,7 +258,7 @@ combine_static_libraries() {
260258

261259
# Since we have multiple architectures libtool will find object files that do not
262260
# match the target architecture. We suppress these warnings.
263-
libtool -static -o "${temp_dir}/combined.a" "${libs[@]}" 2> /dev/null
261+
xcrun libtool -static -o "${temp_dir}/combined.a" "${libs[@]}" 2> /dev/null
264262

265263
# Determine SDK, architectures, and install_name based on platform and simulator flag.
266264
local sdk=""
@@ -333,7 +331,7 @@ combine_static_libraries() {
333331

334332
# Platform-specific post-processing for device builds
335333
if [[ "$is_simulator" == "false" ]]; then
336-
if command -v xcrun vtool &>/dev/null; then
334+
if xcrun -f vtool &>/dev/null; then
337335
case "$platform" in
338336
"ios")
339337
echo "Marking binary as a framework binary for iOS..."
@@ -528,7 +526,7 @@ combine_static_libraries "build-tvos-device" "Release-appletvos" "tvos" "false"
528526

529527
# Create XCFramework with correct debug symbols paths
530528
echo "Creating XCFramework..."
531-
xcodebuild -create-xcframework \
529+
xcrun xcodebuild -create-xcframework \
532530
-framework $(pwd)/build-ios-sim/framework/llama.framework \
533531
-debug-symbols $(pwd)/build-ios-sim/dSYMs/llama.dSYM \
534532
-framework $(pwd)/build-ios-device/framework/llama.framework \

0 commit comments

Comments
 (0)