Skip to content

Commit 409805e

Browse files
author
seydx
committed
Enhance ARM64 cross-compilation support and update Vulkan library handling in build script
1 parent ff9b663 commit 409805e

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

build-whisper.sh

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ WHISPER_CMAKE_ARGS=(
4444
-DWHISPER_USE_SYSTEM_GGML=OFF
4545
)
4646

47+
# For ARM64 cross-compilation, tell CMake we're cross-compiling
48+
# This triggers the automatic host compiler detection for vulkan-shaders-gen
49+
if [ "$BUILD_ARCH" == "arm64" ]; then
50+
WHISPER_CMAKE_ARGS+=(
51+
-DCMAKE_SYSTEM_NAME=Windows
52+
-DCMAKE_SYSTEM_PROCESSOR=ARM64
53+
)
54+
fi
55+
4756
# GGML options
4857
GGML_ARGS=(
4958
-DGGML_CCACHE=OFF
@@ -87,8 +96,22 @@ mkdir -p "$INSTALL_PREFIX/lib/pkgconfig"
8796
GGML_LIBS="-lggml -lggml-base -lggml-cpu -lggml-opencl"
8897

8998
# Add Vulkan if enabled
99+
VULKAN_REQUIRES=""
90100
if [ -n "$VULKAN_SDK" ] && [ -d "$VULKAN_SDK" ]; then
91101
GGML_LIBS="$GGML_LIBS -lggml-vulkan"
102+
# Add Vulkan library path directly instead of pkg-config (vulkan.pc not always available)
103+
# Convert path using cygpath for proper Windows path handling (same as build-ffmpeg.sh)
104+
VULKAN_PATH_SHORT=$(cygpath -sw "$VULKAN_SDK")
105+
VULKAN_PATH_FIXED=$(cygpath -m "$VULKAN_PATH_SHORT")
106+
107+
# Use architecture-specific lib directory (Lib-ARM64 for ARM64, Lib for x64)
108+
if [ "$BUILD_ARCH" == "arm64" ]; then
109+
VULKAN_LIBS="-L\"${VULKAN_PATH_FIXED}/Lib-ARM64\" -lvulkan-1"
110+
else
111+
VULKAN_LIBS="-L\"${VULKAN_PATH_FIXED}/Lib\" -lvulkan-1"
112+
fi
113+
else
114+
VULKAN_LIBS=""
92115
fi
93116

94117
cat > "$INSTALL_PREFIX/lib/pkgconfig/whisper.pc" << EOF
@@ -101,14 +124,8 @@ Name: whisper
101124
Description: OpenAI Whisper speech recognition library
102125
Version: 1.7.6
103126
Cflags: -I\${includedir}
104-
Libs: -L\${libdir} -lwhisper
105-
Libs.private: $GGML_LIBS
106-
Requires: OpenCL
127+
Libs: -L\${libdir} -lwhisper $VULKAN_LIBS
128+
Libs.private: $GGML_LIBS -lOpenCL
107129
EOF
108130

109-
# If Vulkan is enabled, add it to pkg-config
110-
if [ -n "$VULKAN_SDK" ] && [ -d "$VULKAN_SDK" ]; then
111-
echo "Requires: OpenCL vulkan" >> "$INSTALL_PREFIX/lib/pkgconfig/whisper.pc"
112-
fi
113-
114131
echo "whisper.cpp built successfully"

0 commit comments

Comments
 (0)