[PATCH] D159168: [Support] Implement getMainExecutable for OpenBSD

Brad Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 29 23:02:25 PDT 2023


brad created this revision.
brad added a reviewer: MaskRay.
brad added a project: LLVM.
Herald added subscribers: hiraditya, krytarowski.
Herald added a project: All.
brad requested review of this revision.

This uses just argv[0] on OpenBSD. OpenBSD does not support the /proc filesystem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159168

Files:
  llvm/lib/Support/Unix/Path.inc


Index: llvm/lib/Support/Unix/Path.inc
===================================================================
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -233,8 +233,8 @@
   // Fall back to argv[0] if auxiliary vectors are not available.
   if (getprogpath(exe_path, argv0) != NULL)
     return exe_path;
-#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || \
-    defined(__FreeBSD_kernel__) || defined(_AIX)
+#elif defined(_AIX) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) || \
+    defined(__NetBSD__)
   const char *curproc = "/proc/curproc/file";
   char exe_path[PATH_MAX];
   if (sys::fs::exists(curproc)) {
@@ -283,6 +283,11 @@
   // Fall back to the classical detection.
   if (getprogpath(exe_path, argv0))
     return exe_path;
+#elif defined(__OpenBSD__)
+  char exe_path[PATH_MAX];
+  // argv[0] only
+  if (getprogpath(exe_path, argv0) != NULL)
+    return exe_path;
 #elif defined(__sun__) && defined(__svr4__)
   char exe_path[PATH_MAX];
   const char *aPath = "/proc/self/execname";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159168.554576.patch
Type: text/x-patch
Size: 1065 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230830/c0126a7f/attachment.bin>


More information about the llvm-commits mailing list