diff --git a/Makefile b/Makefile index 193510fc..6c6accd1 100644 --- a/Makefile +++ b/Makefile @@ -68,12 +68,19 @@ ifndef UNAME_S UNAME_S := $(shell uname -s) endif -ifeq ($(UNAME_S),Darwin) +ifeq ($(OS),Darwin) CGO_LDFLAGS += -lcblas -framework Accelerate -ifneq ($(BUILD_TYPE),metal) - # explicit disable metal if on Darwin and metal is disabled - CMAKE_ARGS+=-DLLAMA_METAL=OFF -endif + ifeq ($(OSX_SIGNING_IDENTITY),) + OSX_SIGNING_IDENTITY := $(shell security find-identity -v -p codesigning | grep '"' | head -n 1 | sed -E 's/.*"(.*)"/\1/') + endif + + # on OSX, if BUILD_TYPE is blank, we should default to use Metal + ifeq ($(BUILD_TYPE),) + BUILD_TYPE=metal + # disable metal if on Darwin and any other value is explicitly passed. + else ifneq ($(BUILD_TYPE),metal) + CMAKE_ARGS+=-DLLAMA_METAL=OFF + endif endif ifeq ($(BUILD_TYPE),openblas) @@ -106,12 +113,6 @@ ifeq ($(BUILD_TYPE),clblas) CGO_LDFLAGS+=-lOpenCL -lclblast endif -ifeq ($(OS),Darwin) - ifeq ($(OSX_SIGNING_IDENTITY),) - OSX_SIGNING_IDENTITY := $(shell security find-identity -v -p codesigning | grep '"' | head -n 1 | sed -E 's/.*"(.*)"/\1/') - endif -endif - # glibc-static or glibc-devel-static required ifeq ($(STATIC),true) LD_FLAGS=-linkmode external -extldflags -static @@ -411,9 +412,9 @@ backend-assets/grpc/llama: backend-assets/grpc sources/go-llama/libbinding.a $(GOCMD) mod edit -replace github.com/go-skynet/go-llama.cpp=$(shell pwd)/sources/go-llama CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/sources/go-llama LIBRARY_PATH=$(shell pwd)/sources/go-llama \ $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/llama ./backend/go/llm/llama/ -# TODO: every binary should have its own folder instead, so can have different metal implementations +# TODO: every binary should have its own folder instead, so can have different implementations ifeq ($(BUILD_TYPE),metal) - cp go-llama/build/bin/ggml-metal.metal backend-assets/grpc/ + cp backend/cpp/llama/llama.cpp/ggml-metal.metal backend-assets/grpc/ endif ## BACKEND CPP LLAMA START