Skip to content

Commit 16343d3

Browse files
committed
fix(darwin): make sure to bundle libutf8_validity
Plus some refactoring, use makefile Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent b52bfaf commit 16343d3

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

.github/workflows/backend.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -969,10 +969,7 @@ jobs:
969969
- name: Build llama-cpp-darwin
970970
run: |
971971
make protogen-go
972-
make build
973-
bash scripts/build-llama-cpp-darwin.sh
974-
ls -la build/darwin.tar
975-
mv build/darwin.tar build/llama-cpp.tar
972+
make backends/llama-cpp-darwin
976973
- name: Upload llama-cpp.tar
977974
uses: actions/upload-artifact@v4
978975
with:
@@ -1060,9 +1057,7 @@ jobs:
10601057
make protogen-go
10611058
make build
10621059
export PLATFORMARCH=darwin/amd64
1063-
bash scripts/build-llama-cpp-darwin.sh
1064-
ls -la build/darwin.tar
1065-
mv build/darwin.tar build/llama-cpp.tar
1060+
make backends/llama-cpp-darwin
10661061
- name: Upload llama-cpp.tar
10671062
uses: actions/upload-artifact@v4
10681063
with:

.github/workflows/test.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,7 @@ jobs:
214214
- name: Build llama-cpp-darwin
215215
run: |
216216
make protogen-go
217-
make build
218-
bash scripts/build-llama-cpp-darwin.sh
219-
ls -la build/darwin.tar
220-
mv build/darwin.tar build/llama-cpp.tar
221-
./local-ai backends install "ocifile://$PWD/build/llama-cpp.tar"
217+
make backends/llama-cpp-darwin
222218
- name: Test
223219
run: |
224220
export C_INCLUDE_PATH=/usr/local/include

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ backends/kitten-tts: docker-build-kitten-tts docker-save-kitten-tts build
165165
backends/kokoro: docker-build-kokoro docker-save-kokoro build
166166
./local-ai backends install "ocifile://$(abspath ./backend-images/kokoro.tar)"
167167

168+
backends/llama-cpp-darwin: build
169+
bash ./scripts/build-llama-cpp-darwin.sh
170+
mv build/darwin.tar build/llama-cpp.tar
171+
./local-ai backends install "ocifile://$(abspath ./build/llama-cpp.tar)"
172+
168173
########################################################
169174
## AIO tests
170175
########################################################

backend/cpp/llama-cpp/run.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ fi
4242

4343
# Extend ld library path with the dir where this script is located/lib
4444
if [ "$(uname)" == "Darwin" ]; then
45-
DYLD_FALLBACK_LIBRARY_PATH=$CURDIR/lib:$DYLD_FALLBACK_LIBRARY_PATH
45+
export DYLD_LIBRARY_PATH=$CURDIR/lib:$DYLD_LIBRARY_PATH
46+
#export DYLD_FALLBACK_LIBRARY_PATH=$CURDIR/lib:$DYLD_FALLBACK_LIBRARY_PATH
4647
else
4748
export LD_LIBRARY_PATH=$CURDIR/lib:$LD_LIBRARY_PATH
4849
fi
@@ -57,5 +58,5 @@ fi
5758
echo "Using binary: $BINARY"
5859
exec $CURDIR/$BINARY "$@"
5960

60-
# In case we fail execing, just run fallback
61+
# We should never reach this point, however just in case we do, run fallback
6162
exec $CURDIR/llama-cpp-fallback "$@"

scripts/build-llama-cpp-darwin.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ cp -rf backend/cpp/llama-cpp/llama-cpp-fallback build/darwin/
2424
cp -rf backend/cpp/llama-cpp/llama-cpp-grpc build/darwin/
2525
cp -rf backend/cpp/llama-cpp/llama-cpp-rpc-server build/darwin/
2626

27+
ADDITIONAL_LIBS=${ADDITIONAL_LIBS:-$(ls /opt/homebrew/Cellar/protobuf/**/lib/libutf8_validity.dylib)}
28+
29+
for file in $ADDITIONAL_LIBS; do
30+
cp -rfv $file build/darwin/lib
31+
done
32+
2733
for file in build/darwin/*; do
2834
LIBS="$(otool -L $file | awk 'NR > 1 { system("echo " $1) } ' | xargs echo)"
2935

@@ -38,6 +44,14 @@ for file in build/darwin/*; do
3844
done
3945
done
4046

47+
echo "--------------------------------"
48+
echo "ADDITIONAL_LIBS: $ADDITIONAL_LIBS"
49+
echo "--------------------------------"
50+
51+
echo "Bundled libraries:"
52+
ls -la build/darwin/lib
53+
54+
4155
cp -rf backend/cpp/llama-cpp/run.sh build/darwin/
4256

4357
PLATFORMARCH="${PLATFORMARCH:-darwin/arm64}"

0 commit comments

Comments
 (0)