]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
ggml : fix run-time on FreeBSD in get_executable_path() (llama/10948)
authoryuri@FreeBSD <redacted>
Mon, 23 Dec 2024 00:20:11 +0000 (16:20 -0800)
committerGeorgi Gerganov <redacted>
Sat, 4 Jan 2025 08:45:01 +0000 (10:45 +0200)
ggml/src/ggml-backend-reg.cpp

index 66927148abcb91ed146f1f9beed47bee4c923f50..31ee31e39376a2748eee97723544bc0adada2019 100644 (file)
@@ -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<char> 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;
         }