From c8cc197ddde1b47eb05d8cea21102f5c1895c91c Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Wed, 24 May 2023 16:42:24 +0200 Subject: [PATCH] feat: add static builds (#370) --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index aa3e02b..f63ba9b 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ CUDA_LIBPATH?=/usr/local/cuda/lib64/ STABLEDIFFUSION_VERSION?=c0748eca3642d58bcf9521108bcee46959c647dc GO_TAGS?= BUILD_ID?=git - +LD_FLAGS=?= OPTIONAL_TARGETS?= OS := $(shell uname -s) @@ -41,6 +41,11 @@ ifeq ($(BUILD_TYPE),cublas) export LLAMA_CUBLAS=1 endif +# glibc-static or glibc-devel-static required +ifeq ($(STATIC),true) + LD_FLAGS=-linkmode external -extldflags -static +endif + ifeq ($(GO_TAGS),stablediffusion) OPTIONAL_TARGETS+=go-stable-diffusion/libstablediffusion.a endif @@ -197,7 +202,7 @@ build: prepare ## Build the project $(info ${GREEN}I local-ai build info:${RESET}) $(info ${GREEN}I BUILD_TYPE: ${YELLOW}$(BUILD_TYPE)${RESET}) $(info ${GREEN}I GO_TAGS: ${YELLOW}$(GO_TAGS)${RESET}) - CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=${C_INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} $(GOCMD) build -tags "$(GO_TAGS)" -x -o $(BINARY_NAME) ./ + CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=${C_INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -x -o $(BINARY_NAME) ./ dist: build mkdir -p release