Would it be possible to add execvpe() that is found on Linux/glibc systems? Currently I have to do the following: environ = args->envp; execvp(args->program, args->argv); However this workaround will not even compile for shared libraries (one of my scenarios) because of another FreeBSD bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263265 execvpe() would solve my problem.
execvpe() is not a kernel syscall, it is libc wrapper for execve() syscall.
> execvpe() is not a kernel syscall, it is libc wrapper for execve() syscall. That sounds about right. libc performs PATH-resolution and then calls execve(). Still, would it be possible to add execvpe()? The problem I face still stands.
It appears to already be implemented at _execvpe() and not made public. It looks trivial enough I'll take a shot at exposing it.
As always it's more complicated than expected. Some software (e.g., openzfs) blindly added execvpe shims so an exp-run will be required. https://reviews.freebsd.org/D42846
Created attachment 246678 [details] patch see also https://github.com/brooksdavis/freebsd/tree/execvpe
New failure logs: https://pkg-status.freebsd.org/gohan04/data/mainamd64PR275370-default-foo/2023-12-05_08h00m19s/logs/errors/scheme48-1.9.2.log https://pkg-status.freebsd.org/gohan04/data/mainamd64PR275370-default-foo/2023-12-05_08h00m19s/logs/errors/deco-misc-3.9_5.log https://pkg-status.freebsd.org/gohan04/data/mainamd64PR275370-default-foo/2023-12-05_08h00m19s/logs/errors/screen-4.9.1.log
> New failure logs > checking for execvpe... no These projects use autotools to check for execvpe(), but for some reason they're failing to detect FreeBSD's execvpe(). That's how they use autotools: > AC_CHECK_FUNCS(execvpe) If execvpe() is found, then HAVE_EXECVPE is defined. One workaround should be to explicitly define HAVE_EXECVPE and bypass the internal definition. However I think it's better to understand why autotools didn't find FreeBSD's execvpe().
Created attachment 246807 [details] second attempt to add patch Sigh, some how exposing the symbol didn't make it into the initial patch. I've fixed that and now scheme48 builds fine. I didn't test the others because I expect different failure modes across the ports tree. :(
Exp-run looks fine.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=8ccd0b876e67fda6249f294ff484798cc1e1569f commit 8ccd0b876e67fda6249f294ff484798cc1e1569f Author: Brooks Davis <brooks@FreeBSD.org> AuthorDate: 2023-12-11 19:24:53 +0000 Commit: Brooks Davis <brooks@FreeBSD.org> CommitDate: 2023-12-11 19:24:53 +0000 libc: expose execvpe for Linux compat We already implemented execvpe internally with an _ prefix in libc so go ahead and expose it for compatibility with Linux. This reverts c605eea952146348e5e1ad5cab6c127d7a1bd164. Bump __FreeBSD_version for the addition and add definitions to supress compat shims in libzfs (zfs changes were merged from upstream). PR: 275370 (request and exp-run (thanks antoine!)) Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D42846 cddl/lib/libzfs/Makefile | 1 + cddl/usr.sbin/zfsd/Makefile.common | 2 +- include/unistd.h | 1 + lib/libc/gen/Symbol.map | 4 ++++ lib/libc/gen/exec.3 | 24 ++++++++++++++++++++---- lib/libc/gen/exec.c | 4 ++-- lib/libc/gen/posix_spawn.c | 4 ++-- lib/libc/include/libc_private.h | 3 --- sys/sys/param.h | 2 +- 9 files changed, 32 insertions(+), 13 deletions(-)
I might yet MFC this, but don't need a PR to track that.
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=0667d0e0e3658128098ff4d672f5c2ce8aa9068e commit 0667d0e0e3658128098ff4d672f5c2ce8aa9068e Author: Brooks Davis <brooks@FreeBSD.org> AuthorDate: 2023-12-11 19:24:53 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-02-18 10:01:46 +0000 libc: expose execvpe for Linux compat PR: 275370 (cherry picked from commit 8ccd0b876e67fda6249f294ff484798cc1e1569f) cddl/lib/libzfs/Makefile | 1 + cddl/usr.sbin/zfsd/Makefile.common | 2 +- include/unistd.h | 1 + lib/libc/gen/Symbol.map | 4 ++++ lib/libc/gen/exec.3 | 26 ++++++++++++++++++++------ lib/libc/gen/exec.c | 4 ++-- lib/libc/gen/posix_spawn.c | 4 ++-- lib/libc/include/libc_private.h | 3 --- 8 files changed, 31 insertions(+), 14 deletions(-)
(In reply to commit-hook from comment #12) FreeBSD-14/STABLE build is broken. In file included from /usr/src/cddl/usr.sbin/zfsd/zfsd_main.cc:44: In file included from /usr/src/sys/contrib/openzfs/lib/libspl/include/unistd.h:27: /tmp/make_world.IDxEs5PH5i/obj.oXuTuncfnb/usr/src/amd64.amd64/tmp/usr/include/unistd.h:507:6: error: declaration of 'execvpe' has a different language linkage 507 | int execvpe(const char *, char * const *, char * const *); | ^ /usr/src/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/param.h:60:12: note: previous declaration is here 60 | extern int execvpe(const char *name, char * const argv[], char * const envp[]); | ^ 1 error generated.
(In reply to Dmitry Wagin from comment #13) Fixed in https://cgit.freebsd.org/src/commit/?h=stable/14&id=bda0c0dc87c54b611d96b6d0dc1947819ffec083 Thanx @kib