Skip to content

Commit

Permalink
Fix run-time on FreeBSD in get_executable_path()
Browse files Browse the repository at this point in the history
Corrected the path to the currently running executable.
  • Loading branch information
yurivict committed Dec 22, 2024
1 parent 7c0e285 commit a68c7ee
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ggml/src/ggml-backend-reg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a68c7ee

Please sign in to comment.