From 1e351b8e2a4af7f1726c9ce8b54cda08ee14edee Mon Sep 17 00:00:00 2001 From: o7si Date: Wed, 26 Nov 2025 01:27:33 +0800 Subject: [PATCH] feat: support GGML_BACKEND_DIR environment variable --- ggml/src/ggml-backend-reg.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ggml/src/ggml-backend-reg.cpp b/ggml/src/ggml-backend-reg.cpp index e96b5c403d..34db663706 100644 --- a/ggml/src/ggml-backend-reg.cpp +++ b/ggml/src/ggml-backend-reg.cpp @@ -523,6 +523,11 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent, #ifdef GGML_BACKEND_DIR search_paths.push_back(fs::u8path(GGML_BACKEND_DIR)); #endif + const char * backend_dir = getenv("GGML_BACKEND_DIR"); + if (backend_dir) { + search_paths.push_back(fs::u8path(backend_dir)); + } + // default search paths: executable directory, current directory search_paths.push_back(get_executable_path()); search_paths.push_back(fs::current_path());