Skip to content

Commit 19180ce

Browse files
committed
feat: enhance Makefile to support GPU backends with Vulkan and OpenCL libraries
1 parent f503674 commit 19180ce

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

extensions/sqlite/Makefile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,20 @@ ifneq ($(WHISPER_COREML_LIB),)
105105
COREML_FRAMEWORK := -framework CoreML
106106
endif
107107

108-
# Pick up ggml-blas if llama.cpp was configured with -DGGML_BLAS=ON.
108+
# Pick up GPU backends if llama.cpp was configured with the matching flag.
109109
# Check both naming conventions (lib prefix may be stripped on Windows MinGW).
110-
GGML_BLAS_LIB := $(firstword $(wildcard $(LLAMA_BUILD)/ggml/src/ggml-blas/libggml-blas.a $(LLAMA_BUILD)/ggml/src/ggml-blas/ggml-blas.a))
110+
GGML_BLAS_LIB := $(firstword $(wildcard $(LLAMA_BUILD)/ggml/src/ggml-blas/libggml-blas.a $(LLAMA_BUILD)/ggml/src/ggml-blas/ggml-blas.a))
111+
GGML_VULKAN_LIB := $(firstword $(wildcard $(LLAMA_BUILD)/ggml/src/ggml-vulkan/libggml-vulkan.a $(LLAMA_BUILD)/ggml/src/ggml-vulkan/ggml-vulkan.a))
112+
GGML_OPENCL_LIB := $(firstword $(wildcard $(LLAMA_BUILD)/ggml/src/ggml-opencl/libggml-opencl.a $(LLAMA_BUILD)/ggml/src/ggml-opencl/ggml-opencl.a))
111113
ifneq ($(GGML_BLAS_LIB),)
112114
LLAMA_LIBS += $(GGML_BLAS_LIB)
113115
endif
116+
ifneq ($(GGML_VULKAN_LIB),)
117+
LLAMA_LIBS += $(GGML_VULKAN_LIB)
118+
endif
119+
ifneq ($(GGML_OPENCL_LIB),)
120+
LLAMA_LIBS += $(GGML_OPENCL_LIB)
121+
endif
114122

115123
# Default link libs. Windows is fully overridden in its branch below
116124
# because -lpthread doesn't exist on MinGW (we use -lwinpthread instead)
@@ -208,6 +216,17 @@ else
208216
LIBS += $(MBEDTLS_BUILD)/library/libmbedcrypto.a
209217
endif
210218

219+
# Vulkan / OpenCL runtime loaders. Must come AFTER the ggml-vulkan/-opencl
220+
# static libs in LIBS (single-pass GNU ld). Only added when the matching
221+
# backend was built (wildcard above resolved); Apple's Metal path skips
222+
# these — neither GGML_VULKAN_LIB nor GGML_OPENCL_LIB is set on Apple.
223+
ifneq ($(GGML_VULKAN_LIB),)
224+
LIBS += -lvulkan
225+
endif
226+
ifneq ($(GGML_OPENCL_LIB),)
227+
LIBS += -lOpenCL
228+
endif
229+
211230
.PHONY: all clean test
212231

213232
all: adam.$(EXT)

0 commit comments

Comments
 (0)