@@ -105,12 +105,20 @@ ifneq ($(WHISPER_COREML_LIB),)
105105 COREML_FRAMEWORK := -framework CoreML
106106endif
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) )
111113ifneq ($(GGML_BLAS_LIB ) ,)
112114 LLAMA_LIBS += $(GGML_BLAS_LIB )
113115endif
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
209217endif
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
213232all : adam.$(EXT )
0 commit comments