unix: include <libutil.h> for openpty() on FreeBSD - #1
Open
neilpang wants to merge 1 commit into
Open
Conversation
FreeBSD has no <util.h>; openpty(3) is declared in <libutil.h> there. The
include guard listed FreeBSD alongside the other BSDs, so every FreeBSD
build of this branch stopped at
src/unix/process.c:45:10: fatal error: 'util.h' file not found
Verified on FreeBSD 13.5, 14.3 and 15.1: with this change MoarVM builds
against this libuv and the NQP test suite passes (145 files, 13476 tests).
This was referenced Jul 28, 2026
This was referenced Jul 28, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes FreeBSD builds by using the correct header for openpty(3)—<libutil.h>—instead of <util.h>, aligning with FreeBSD’s documented synopsis for PTY support in src/unix/process.c.
Changes:
- Remove
__FreeBSD__from the<util.h>include guard used for other BSDs. - Add a FreeBSD-specific branch to include
<libutil.h>.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
41
to
47
| #if defined(__DragonFly__) || \ | ||
| defined(__FreeBSD__) || \ | ||
| defined(__NetBSD__) || \ | ||
| defined(__OpenBSD__) | ||
| #include <util.h> | ||
| #elif defined(__FreeBSD__) | ||
| #include <libutil.h> | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FreeBSD has no
<util.h>. Itsopenpty(3)manual page gives the synopsis as#include <libutil.h>, linked with "System Utilities Library (libutil, -lutil)".The include guard here listed FreeBSD alongside the other BSDs, so every FreeBSD
build of this branch stopped at:
/usr/include/util.his absent on FreeBSD 13.5, 14.3 and 15.1;/usr/include/libutil.his present on all three.
This branch is what MoarVM pins as its
3rdparty/libuvsubmodule, so the effect isthat MoarVM cannot be built on any current FreeBSD. With this change it builds and
the NQP test suite passes (145 files, 13476 tests) on all three releases:
https://github.com/neilpang/MoarVM/actions/runs/30350124514
Note for the MoarVM side:
openptylives inlibutil, notlibc, on every FreeBSDrelease checked, so
MoarVM/build/setup.pmalso needsutiladded to the FreeBSDsyslibs-- otherwiselibmoar.solinks withopenptyunresolved and a pty spawnfails at runtime. That is a separate change in the MoarVM repo.