sign dylibs on macOS (#2101)

This commit is contained in:
Jeffrey Morgan 2024-01-19 19:24:11 -05:00 committed by GitHub
parent 3b76e736ae
commit 4c54f0ddeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 2 deletions

View file

@ -83,8 +83,9 @@ build() {
compress_libs() { compress_libs() {
echo "Compressing payloads to reduce overall binary size..." echo "Compressing payloads to reduce overall binary size..."
pids="" pids=""
rm -rf ${BUILD_DIR}/lib/*.${LIB_EXT}*.gz
for lib in ${BUILD_DIR}/lib/*.${LIB_EXT}* ; do for lib in ${BUILD_DIR}/lib/*.${LIB_EXT}* ; do
gzip --best ${lib} & gzip --best -f ${lib} &
pids+=" $!" pids+=" $!"
done done
echo echo

View file

@ -12,6 +12,12 @@ init_vars
git_module_setup git_module_setup
apply_patches apply_patches
sign() {
if [ -n "$APPLE_IDENTITY" ]; then
codesign -f --timestamp --deep --options=runtime --sign "$APPLE_IDENTITY" --identifier ai.ollama.ollama $1
fi
}
COMMON_DARWIN_DEFS="-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DCMAKE_SYSTEM_NAME=Darwin -DLLAMA_ACCELERATE=off" COMMON_DARWIN_DEFS="-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -DCMAKE_SYSTEM_NAME=Darwin -DLLAMA_ACCELERATE=off"
case "${GOARCH}" in case "${GOARCH}" in
@ -25,6 +31,7 @@ case "${GOARCH}" in
BUILD_DIR="${LLAMACPP_DIR}/build/darwin/${ARCH}/cpu" BUILD_DIR="${LLAMACPP_DIR}/build/darwin/${ARCH}/cpu"
echo "Building LCD CPU" echo "Building LCD CPU"
build build
sign ${LLAMACPP_DIR}/build/darwin/${ARCH}/cpu/lib/libext_server.dylib
compress_libs compress_libs
# #
@ -36,6 +43,7 @@ case "${GOARCH}" in
BUILD_DIR="${LLAMACPP_DIR}/build/darwin/${ARCH}/cpu_avx" BUILD_DIR="${LLAMACPP_DIR}/build/darwin/${ARCH}/cpu_avx"
echo "Building AVX CPU" echo "Building AVX CPU"
build build
sign ${LLAMACPP_DIR}/build/darwin/${ARCH}/cpu_avx/lib/libext_server.dylib
compress_libs compress_libs
# #
@ -47,6 +55,7 @@ case "${GOARCH}" in
BUILD_DIR="${LLAMACPP_DIR}/build/darwin/${ARCH}/cpu_avx2" BUILD_DIR="${LLAMACPP_DIR}/build/darwin/${ARCH}/cpu_avx2"
echo "Building AVX2 CPU" echo "Building AVX2 CPU"
build build
sign ${LLAMACPP_DIR}/build/darwin/${ARCH}/cpu_avx2/lib/libext_server.dylib
compress_libs compress_libs
;; ;;
"arm64") "arm64")
@ -54,6 +63,7 @@ case "${GOARCH}" in
BUILD_DIR="${LLAMACPP_DIR}/build/darwin/${ARCH}/metal" BUILD_DIR="${LLAMACPP_DIR}/build/darwin/${ARCH}/metal"
EXTRA_LIBS="${EXTRA_LIBS} -framework Accelerate -framework Foundation -framework Metal -framework MetalKit -framework MetalPerformanceShaders" EXTRA_LIBS="${EXTRA_LIBS} -framework Accelerate -framework Foundation -framework Metal -framework MetalKit -framework MetalPerformanceShaders"
build build
sign ${LLAMACPP_DIR}/build/darwin/${ARCH}/metal/lib/libext_server.dylib
compress_libs compress_libs
;; ;;
*) *)

View file

@ -76,7 +76,7 @@ function compress_libs {
write-host "Compressing dlls..." write-host "Compressing dlls..."
$libs = dir "${script:buildDir}/lib/*.dll" $libs = dir "${script:buildDir}/lib/*.dll"
foreach ($file in $libs) { foreach ($file in $libs) {
& "$script:GZIP" --best $file & "$script:GZIP" --best -f $file
} }
} }