{"thread":{"id":"66338","subject":"[PATCH] exec_cmd: RUNTIME_PREFIX on OpenBSD systems","startedAt":"2026-09-17T03:40:58Z","lastAt":"2026-09-21T16:57:45Z","messageCount":4,"participants":["Brad Smith","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"552802","messageId":"aqthQ3u4eW1wHCn7@humpty.home.comstyle.com","threadId":"66338","inReplyTo":null,"subject":"[PATCH] exec_cmd: RUNTIME_PREFIX on OpenBSD systems","fromName":"Brad Smith","fromEmail":"brad@comstyle.com","sentAt":"2026-09-17T03:40:51Z","receivedAt":"2026-09-17T03:40:58Z","isPatch":true,"body":"Enable Git to resolve its own binary location using getexecpath().\n\nSigned-off-by: Brad Smith <brad@comstyle.com>\n---\n Makefile         |  7 +++++++\n config.mak.uname |  3 +++\n exec-cmd.c       | 24 ++++++++++++++++++++++++\n 3 files changed, 34 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex d4b775953d..9e3d37b5b4 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -378,6 +378,9 @@ include shared.mak\n # Perl scripts to use a modified entry point header allowing them to resolve\n # support files at runtime.\n #\n+# When using RUNTIME_PREFIX, define HAVE_GETEXECPATH if your platform supports\n+# the getexecpath() function.\n+#\n # When using RUNTIME_PREFIX, define HAVE_BSD_KERN_PROC_SYSCTL if your platform\n # supports the KERN_PROC BSD sysctl function.\n #\n@@ -2356,6 +2359,10 @@ endif\n \n ifdef RUNTIME_PREFIX\n \n+        ifdef HAVE_GETEXECPATH\n+\t\tBASIC_CFLAGS += -DHAVE_GETEXECPATH\n+        endif\n+\n         ifdef HAVE_BSD_KERN_PROC_SYSCTL\n \t\tBASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL\n         endif\ndiff --git a/config.mak.uname b/config.mak.uname\nindex e28870434d..270aff1772 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -343,6 +343,9 @@ ifeq ($(uname_S),OpenBSD)\n \tCSPRNG_METHOD = arc4random\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n \tFILENO_IS_A_MACRO = UnfortunatelyYes\n+\tifeq ($(shell test \"`expr \"$(uname_R)\" : '\\([0-9][0-9]*\\)\\.'`\" -ge 8 && echo 1),1)\n+\t\tHAVE_GETEXECPATH = YesPlease\n+\tendif\n endif\n ifeq ($(uname_S),MirBSD)\n \tNO_STRCASESTR = YesPlease\ndiff --git a/exec-cmd.c b/exec-cmd.c\nindex 507e67d528..5251da4229 100644\n--- a/exec-cmd.c\n+++ b/exec-cmd.c\n@@ -129,6 +129,26 @@ static int git_get_exec_path_bsd_sysctl(struct strbuf *buf)\n }\n #endif /* HAVE_BSD_KERN_PROC_SYSCTL */\n \n+#ifdef HAVE_GETEXECPATH\n+/*\n+ * Resolves the executable path using getexecpath(3).\n+ *\n+ * Returns 0 on success, -1 on failure.\n+ */\n+static int git_get_exec_path_getexecpath(struct strbuf *buf)\n+{\n+\tchar path[PATH_MAX];\n+\tif (getexecpath(path, sizeof(path)) == 0) {\n+\t\ttrace_printf(\n+\t\t\t\"trace: resolved executable path from getexecpath: %s\\n\",\n+\t\t\tpath);\n+\t\tstrbuf_addstr(buf, path);\n+\t\treturn 0;\n+\t}\n+\treturn -1;\n+}\n+#endif /* HAVE_GETEXECPATH */\n+\n #ifdef HAVE_NS_GET_EXECUTABLE_PATH\n /*\n  * Resolves the executable path by querying Darwin application stack.\n@@ -209,6 +229,10 @@ static int git_get_exec_path(struct strbuf *buf, const char *argv0)\n \t * after the first successful method.\n \t */\n \tif (\n+#ifdef HAVE_GETEXECPATH\n+\t\tgit_get_exec_path_getexecpath(buf) &&\n+#endif /* HAVE_GETEXECPATH */\n+\n #ifdef HAVE_BSD_KERN_PROC_SYSCTL\n \t\tgit_get_exec_path_bsd_sysctl(buf) &&\n #endif /* HAVE_BSD_KERN_PROC_SYSCTL */\n-- \n2.55.0\n\n"},{"id":"552815","messageId":"xmqqy0d0t2j9.fsf@gitster.g","threadId":"66338","inReplyTo":"aqthQ3u4eW1wHCn7@humpty.home.comstyle.com","subject":"Re: [PATCH] exec_cmd: RUNTIME_PREFIX on OpenBSD systems","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-09-17T13:45:14Z","receivedAt":"2026-09-17T13:45:19Z","isPatch":true,"body":"Brad Smith <brad@comstyle.com> writes:\n\n> Enable Git to resolve its own binary location using getexecpath().\n\nThat may not be incorrect information per-se, but lacks critical\nbits.  Natural initial questions that come to my mind are...\n\n    Why would one want to use getexecpath() over whatever OpenBSD\n    ports of Git have been using happily?  Is the old way being\n    removed?  Is the new way being more accurate?  In what\n    situations does the difference matter?  Is everybody on OpenBSD\n    able to use this new function?  Do only certain, and/or\n    presumably later, verions of OpenBSD have it?  How widely is it\n    available?  How long has it been available?\n\nYour proposed commit log messages do not answer any of these\nquestions, but it should.  The title can also use a bit of tweak to\nidentify which versions of OpenBSD this patch is relevant.\n\n> Signed-off-by: Brad Smith <brad@comstyle.com>\n> ---\n>  Makefile         |  7 +++++++\n>  config.mak.uname |  3 +++\n>  exec-cmd.c       | 24 ++++++++++++++++++++++++\n>  3 files changed, 34 insertions(+)\n>\n> diff --git a/Makefile b/Makefile\n> index d4b775953d..9e3d37b5b4 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -378,6 +378,9 @@ include shared.mak\n>  # Perl scripts to use a modified entry point header allowing them to resolve\n>  # support files at runtime.\n>  #\n> +# When using RUNTIME_PREFIX, define HAVE_GETEXECPATH if your platform supports\n> +# the getexecpath() function.\n> +#\n>  # When using RUNTIME_PREFIX, define HAVE_BSD_KERN_PROC_SYSCTL if your platform\n>  # supports the KERN_PROC BSD sysctl function.\n>  #\n> @@ -2356,6 +2359,10 @@ endif\n>  \n>  ifdef RUNTIME_PREFIX\n>  \n> +        ifdef HAVE_GETEXECPATH\n> +\t\tBASIC_CFLAGS += -DHAVE_GETEXECPATH\n> +        endif\n> +\n>          ifdef HAVE_BSD_KERN_PROC_SYSCTL\n>  \t\tBASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL\n>          endif\n> diff --git a/config.mak.uname b/config.mak.uname\n> index e28870434d..270aff1772 100644\n> --- a/config.mak.uname\n> +++ b/config.mak.uname\n> @@ -343,6 +343,9 @@ ifeq ($(uname_S),OpenBSD)\n>  \tCSPRNG_METHOD = arc4random\n>  \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n>  \tFILENO_IS_A_MACRO = UnfortunatelyYes\n> +\tifeq ($(shell test \"`expr \"$(uname_R)\" : '\\([0-9][0-9]*\\)\\.'`\" -ge 8 && echo 1),1)\n> +\t\tHAVE_GETEXECPATH = YesPlease\n> +\tendif\n>  endif\n>  ifeq ($(uname_S),MirBSD)\n>  \tNO_STRCASESTR = YesPlease\n> diff --git a/exec-cmd.c b/exec-cmd.c\n> index 507e67d528..5251da4229 100644\n> --- a/exec-cmd.c\n> +++ b/exec-cmd.c\n> @@ -129,6 +129,26 @@ static int git_get_exec_path_bsd_sysctl(struct strbuf *buf)\n>  }\n>  #endif /* HAVE_BSD_KERN_PROC_SYSCTL */\n>  \n> +#ifdef HAVE_GETEXECPATH\n> +/*\n> + * Resolves the executable path using getexecpath(3).\n> + *\n> + * Returns 0 on success, -1 on failure.\n> + */\n> +static int git_get_exec_path_getexecpath(struct strbuf *buf)\n> +{\n> +\tchar path[PATH_MAX];\n> +\tif (getexecpath(path, sizeof(path)) == 0) {\n> +\t\ttrace_printf(\n> +\t\t\t\"trace: resolved executable path from getexecpath: %s\\n\",\n> +\t\t\tpath);\n> +\t\tstrbuf_addstr(buf, path);\n> +\t\treturn 0;\n> +\t}\n> +\treturn -1;\n> +}\n> +#endif /* HAVE_GETEXECPATH */\n> +\n>  #ifdef HAVE_NS_GET_EXECUTABLE_PATH\n>  /*\n>   * Resolves the executable path by querying Darwin application stack.\n> @@ -209,6 +229,10 @@ static int git_get_exec_path(struct strbuf *buf, const char *argv0)\n>  \t * after the first successful method.\n>  \t */\n>  \tif (\n> +#ifdef HAVE_GETEXECPATH\n> +\t\tgit_get_exec_path_getexecpath(buf) &&\n> +#endif /* HAVE_GETEXECPATH */\n> +\n>  #ifdef HAVE_BSD_KERN_PROC_SYSCTL\n>  \t\tgit_get_exec_path_bsd_sysctl(buf) &&\n>  #endif /* HAVE_BSD_KERN_PROC_SYSCTL */\n"},{"id":"552918","messageId":"de116c51-b538-44b7-87d9-653b84a55088@comstyle.com","threadId":"66338","inReplyTo":"xmqqy0d0t2j9.fsf@gitster.g","subject":"Re: [PATCH] exec_cmd: RUNTIME_PREFIX on OpenBSD systems","fromName":"Brad Smith","fromEmail":"brad@comstyle.com","sentAt":"2026-09-21T02:10:18Z","receivedAt":"2026-09-21T02:10:25Z","isPatch":true,"body":"On 2026-09-17 9:45 a.m., Junio C Hamano wrote:\n> Brad Smith <brad@comstyle.com> writes:\n>\n>> Enable Git to resolve its own binary location using getexecpath().\n> That may not be incorrect information per-se, but lacks critical\n> bits.  Natural initial questions that come to my mind are...\n>\n>      Why would one want to use getexecpath() over whatever OpenBSD\n>      ports of Git have been using happily?  Is the old way being\n>      removed?  Is the new way being more accurate?  In what\n>      situations does the difference matter?  Is everybody on OpenBSD\n>      able to use this new function?  Do only certain, and/or\n>      presumably later, verions of OpenBSD have it?  How widely is it\n>      available?  How long has it been available?\n\nIt's a long awaited API for such functionality on OpenBSD. Otherwise there\nhasn't really been a means of doing so and one which has been using happily.\nThe proper API I would say is one which works and is more accurate. One\nwhich works the same everywhere where as the pile of hacks has different\nresults and not happily either.\n\nThe API is new. The config.mak.uname check looks for 8.0 and newer.\n\n\n> Your proposed commit log messages do not answer any of these\n> questions, but it should.  The title can also use a bit of tweak to\n> identify which versions of OpenBSD this patch is relevant.\n>\n>> Signed-off-by: Brad Smith <brad@comstyle.com>\n>> ---\n>>   Makefile         |  7 +++++++\n>>   config.mak.uname |  3 +++\n>>   exec-cmd.c       | 24 ++++++++++++++++++++++++\n>>   3 files changed, 34 insertions(+)\n>>\n>> diff --git a/Makefile b/Makefile\n>> index d4b775953d..9e3d37b5b4 100644\n>> --- a/Makefile\n>> +++ b/Makefile\n>> @@ -378,6 +378,9 @@ include shared.mak\n>>   # Perl scripts to use a modified entry point header allowing them to resolve\n>>   # support files at runtime.\n>>   #\n>> +# When using RUNTIME_PREFIX, define HAVE_GETEXECPATH if your platform supports\n>> +# the getexecpath() function.\n>> +#\n>>   # When using RUNTIME_PREFIX, define HAVE_BSD_KERN_PROC_SYSCTL if your platform\n>>   # supports the KERN_PROC BSD sysctl function.\n>>   #\n>> @@ -2356,6 +2359,10 @@ endif\n>>   \n>>   ifdef RUNTIME_PREFIX\n>>   \n>> +        ifdef HAVE_GETEXECPATH\n>> +\t\tBASIC_CFLAGS += -DHAVE_GETEXECPATH\n>> +        endif\n>> +\n>>           ifdef HAVE_BSD_KERN_PROC_SYSCTL\n>>   \t\tBASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL\n>>           endif\n>> diff --git a/config.mak.uname b/config.mak.uname\n>> index e28870434d..270aff1772 100644\n>> --- a/config.mak.uname\n>> +++ b/config.mak.uname\n>> @@ -343,6 +343,9 @@ ifeq ($(uname_S),OpenBSD)\n>>   \tCSPRNG_METHOD = arc4random\n>>   \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n>>   \tFILENO_IS_A_MACRO = UnfortunatelyYes\n>> +\tifeq ($(shell test \"`expr \"$(uname_R)\" : '\\([0-9][0-9]*\\)\\.'`\" -ge 8 && echo 1),1)\n>> +\t\tHAVE_GETEXECPATH = YesPlease\n>> +\tendif\n>>   endif\n>>   ifeq ($(uname_S),MirBSD)\n>>   \tNO_STRCASESTR = YesPlease\n>> diff --git a/exec-cmd.c b/exec-cmd.c\n>> index 507e67d528..5251da4229 100644\n>> --- a/exec-cmd.c\n>> +++ b/exec-cmd.c\n>> @@ -129,6 +129,26 @@ static int git_get_exec_path_bsd_sysctl(struct strbuf *buf)\n>>   }\n>>   #endif /* HAVE_BSD_KERN_PROC_SYSCTL */\n>>   \n>> +#ifdef HAVE_GETEXECPATH\n>> +/*\n>> + * Resolves the executable path using getexecpath(3).\n>> + *\n>> + * Returns 0 on success, -1 on failure.\n>> + */\n>> +static int git_get_exec_path_getexecpath(struct strbuf *buf)\n>> +{\n>> +\tchar path[PATH_MAX];\n>> +\tif (getexecpath(path, sizeof(path)) == 0) {\n>> +\t\ttrace_printf(\n>> +\t\t\t\"trace: resolved executable path from getexecpath: %s\\n\",\n>> +\t\t\tpath);\n>> +\t\tstrbuf_addstr(buf, path);\n>> +\t\treturn 0;\n>> +\t}\n>> +\treturn -1;\n>> +}\n>> +#endif /* HAVE_GETEXECPATH */\n>> +\n>>   #ifdef HAVE_NS_GET_EXECUTABLE_PATH\n>>   /*\n>>    * Resolves the executable path by querying Darwin application stack.\n>> @@ -209,6 +229,10 @@ static int git_get_exec_path(struct strbuf *buf, const char *argv0)\n>>   \t * after the first successful method.\n>>   \t */\n>>   \tif (\n>> +#ifdef HAVE_GETEXECPATH\n>> +\t\tgit_get_exec_path_getexecpath(buf) &&\n>> +#endif /* HAVE_GETEXECPATH */\n>> +\n>>   #ifdef HAVE_BSD_KERN_PROC_SYSCTL\n>>   \t\tgit_get_exec_path_bsd_sysctl(buf) &&\n>>   #endif /* HAVE_BSD_KERN_PROC_SYSCTL */\n"},{"id":"552940","messageId":"xmqq4ifio83d.fsf@gitster.g","threadId":"66338","inReplyTo":"de116c51-b538-44b7-87d9-653b84a55088@comstyle.com","subject":"Re: [PATCH] exec_cmd: RUNTIME_PREFIX on OpenBSD systems","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-09-21T16:57:42Z","receivedAt":"2026-09-21T16:57:45Z","isPatch":true,"body":"Brad Smith <brad@comstyle.com> writes:\n\n> On 2026-09-17 9:45 a.m., Junio C Hamano wrote:\n>> Brad Smith <brad@comstyle.com> writes:\n>>\n>>> Enable Git to resolve its own binary location using getexecpath().\n>> That may not be incorrect information per-se, but lacks critical\n>> bits.  Natural initial questions that come to my mind are...\n>>\n>>      Why would one want to use getexecpath() over whatever OpenBSD\n>>      ports of Git have been using happily?  Is the old way being\n>>      removed?  Is the new way being more accurate?  In what\n>>      situations does the difference matter?  Is everybody on OpenBSD\n>>      able to use this new function?  Do only certain, and/or\n>>      presumably later, verions of OpenBSD have it?  How widely is it\n>>      available?  How long has it been available?\n>\n> It's a long awaited API for such functionality on OpenBSD. Otherwise there\n> hasn't really been a means of doing so and one which has been using happily.\n> The proper API I would say is one which works and is more accurate. One\n> which works the same everywhere where as the pile of hacks has different\n> results and not happily either.\n>\n> The API is new. The config.mak.uname check looks for 8.0 and newer.\n\nOK, all of the above were missing from the proposed log message that\nshould be placed when v2 patch is prepared.  They've happily been\nusing argv[0] as an approximate (which may be OK as long as we do\nnot lie to ourselves but not as nice), and now they are going to\nhave a proper syscall for the information, finally.  You would also\nneed to answer the last few questions I asked in the proposed log\nmessage of v2, but I thought 8.0 is not yet released?\n\nThanks.\n"}]}