From 7da249fcc12adf158343b902d054e1b141316ea7 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Mon, 31 Jul 2023 20:50:30 -0400 Subject: [PATCH] only build metal for `darwin,arm` target --- llama/llama.go | 3 ++- scripts/build_darwin.sh | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/llama/llama.go b/llama/llama.go index 3b95cfab..fe09c717 100644 --- a/llama/llama.go +++ b/llama/llama.go @@ -3,7 +3,8 @@ package llama /* #cgo CPPFLAGS: -O3 -Wall -Wextra -Werror -Wno-unused-function -Wno-unused-variable -DNDEBUG -DGGML_USE_K_QUANTS #cgo CXXFLAGS: -std=gnu++11 -#cgo darwin CPPFLAGS: -DGGML_USE_ACCELERATE -DGGML_USE_METAL -DGGML_METAL_NDEBUG +#cgo darwin CPPFLAGS: -DGGML_USE_ACCELERATE +#cgo darwin,arm64 CPPFLAGS: -DGGML_USE_METAL -DGGML_METAL_NDEBUG #cgo darwin LDFLAGS: -framework Accelerate -framework Foundation -framework Metal -framework MetalKit -framework MetalPerformanceShaders #include #include "llama.h" diff --git a/scripts/build_darwin.sh b/scripts/build_darwin.sh index 5e0daa38..3de715a4 100755 --- a/scripts/build_darwin.sh +++ b/scripts/build_darwin.sh @@ -3,10 +3,10 @@ mkdir -p dist # build universal binary -CGO_ENABLED=1 GOARCH=arm64 go build -o dist/ollama_arm64 -CGO_ENABLED=1 GOARCH=amd64 go build -o dist/ollama_amd64 -lipo -create -output dist/ollama dist/ollama_arm64 dist/ollama_amd64 -rm dist/ollama_amd64 dist/ollama_arm64 +CGO_ENABLED=1 GOARCH=arm64 go build -o dist/ollama-darwin-arm64 +CGO_ENABLED=1 GOARCH=amd64 go build -o dist/ollama-darwin-amd64 +lipo -create -output dist/ollama dist/ollama-darwin-arm64 dist/ollama-darwin-amd64 +rm dist/ollama-darwin-amd64 dist/ollama-darwin-arm64 codesign --deep --force --options=runtime --sign "$APPLE_IDENTITY" --timestamp dist/ollama # build and sign the mac app