From 7024d59e6a572730626cb11896829d115043a1b1 Mon Sep 17 00:00:00 2001 From: "yuri@FreeBSD" Date: Sun, 22 Dec 2024 16:20:11 -0800 Subject: [PATCH] ggml : fix run-time on FreeBSD in get_executable_path() (#10948) --- ggml/src/ggml-backend-reg.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ggml/src/ggml-backend-reg.cpp b/ggml/src/ggml-backend-reg.cpp index 66927148abcb9..31ee31e39376a 100644 --- a/ggml/src/ggml-backend-reg.cpp +++ b/ggml/src/ggml-backend-reg.cpp @@ -402,12 +402,16 @@ static std::string get_executable_path() { base_path = base_path.substr(0, last_slash); } return base_path + "/"; -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) std::string base_path = "."; std::vector path(1024); while (true) { // get executable path +# if defined(__linux__) ssize_t len = readlink("/proc/self/exe", path.data(), path.size()); +# elif defined(__FreeBSD__) + ssize_t len = readlink("/proc/curproc/file", path.data(), path.size()); +# endif if (len == -1) { break; }