From 8745edc204bd89f68d90a80d703f7fc01eaf766a Mon Sep 17 00:00:00 2001 From: Vitaly Chikunov Date: Sat, 8 Mar 2025 22:29:52 +0300 Subject: [PATCH] ALT: Get backends dir relative from executable name To be runnable without `/proc` mounted. So this is not really `get_executable_path` anymore but more like `get_executables_path` now. Signed-off-by: Vitaly Chikunov --- ggml/src/ggml-backend-reg.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ggml/src/ggml-backend-reg.cpp b/ggml/src/ggml-backend-reg.cpp index 6379479aa..a7d504a3b 100644 --- a/ggml/src/ggml-backend-reg.cpp +++ b/ggml/src/ggml-backend-reg.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #ifdef _WIN32 # define WIN32_LEAN_AND_MEAN @@ -418,6 +419,11 @@ static fs::path get_executable_path() { base_path = base_path.substr(0, last_slash); } return base_path + "/"; +#elif defined(__gnu_linux__) + std::string executable_path(reinterpret_cast(getauxval(AT_EXECFN))); + fs::path bindir = fs::path(executable_path.data()).parent_path(); + fs::path libdir = bindir.parent_path() / "lib" / "llama"; + return fs::is_directory(libdir) ? libdir : bindir; #elif defined(__linux__) || defined(__FreeBSD__) std::string base_path = "."; std::vector path(1024);