Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD: CMake system test for libutil is broken #999

Closed
herrhotzenplotz opened this issue Apr 30, 2023 · 3 comments
Closed

FreeBSD: CMake system test for libutil is broken #999

herrhotzenplotz opened this issue Apr 30, 2023 · 3 comments
Assignees

Comments

@herrhotzenplotz
Copy link
Contributor

With the latest release (2.13.0) and the current master branch I see that the CMake system tests for libutil are broken:

$ uname -a
FreeBSD triton 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 TRITON-LEAN amd64
$ cmake -GNinja -Bbuild -S. -DCMAKE_BUILD_TYPE=Debug
...
-- Performing Test QUICK_LINT_JS_HAVE_LIBUTIL
-- Performing Test QUICK_LINT_JS_HAVE_LIBUTIL - Failed

This test result is incorrect. FreeBSD comes with libutil which is needed for forkpty().

The CMakeError.log reveals:

Performing C++ SOURCE FILE Test QUICK_LINT_JS_HAVE_LIBUTIL failed with the following output:
Change Dir: /usr/home/nico/src/quick-lint-js/build/CMakeFiles/CMakeScratch/TryCompile-LiS8kZ

Run Build Command(s):/usr/local/bin/ninja cmTC_01b34 && [1/2] Building CXX object CMakeFiles/cmTC_01b34.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_01b34.dir/src.cxx.o 
/usr/bin/c++ -DQUICK_LINT_JS_HAVE_LIBUTIL  -std=gnu++20 -MD -MT CMakeFiles/cmTC_01b34.dir/src.cxx.o -MF CMakeFiles/cmTC_01b34.dir/src.cxx.o.d -o CMakeFiles/cmTC_01b34.dir/src.cxx.o -c /usr/home/nico/src/quick-l
int-js/build/CMakeFiles/CMakeScratch/TryCompile-LiS8kZ/src.cxx
/usr/home/nico/src/quick-lint-js/build/CMakeFiles/CMakeScratch/TryCompile-LiS8kZ/src.cxx:1:10: fatal error: 'pty.h' file not found
#include <pty.h>
         ^~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.


Source file was:
#include <pty.h>
  int main() {
    pid_t rc = ::forkpty(nullptr, nullptr, nullptr, nullptr);
    return (int)rc;
  }

The manual page for forkpty requires the following includes:

     #include <sys/types.h>
     #include <sys/ioctl.h>
     #include <termios.h>
     #include <libutil.h>

Also, I don't know why but the __has_include checks for a different header libutil.h than the actual include directive in the tests which then includes util.h:

It seems like those includes are merely copy-pasta mistakes.

Furthermore I see the following error:

src/quick-lint-js/port/child-process.cpp:132:36: error: use of undeclared identifier 'environ'
                          /*envp=*/environ);

The BSDs require the environ symbol to be manually declared in the code: https://man.freebsd.org/cgi/man.cgi?query=environ&apropos=0&sektion=0&manpath=FreeBSD+13.2-RELEASE+and+Ports&arch=default&format=html

A crude patch to make things compile (and pass the tests) is here:

https://gist.githubusercontent.com/herrhotzenplotz/ae6decd42d932feea384a31d4a023bc4/raw/167f9cafd33f102bbe9819c2bccd308a6bd63153/qljs-patch-crude

@strager strager self-assigned this May 1, 2023
@strager
Copy link
Collaborator

strager commented May 1, 2023

Thanks for sharing your patch! I massaged it for production use (not breaking the Linux build, for example) and will land it soon.

@strager
Copy link
Collaborator

strager commented May 2, 2023

Landed fixes in commits b463623, 7abcf4c, 3d3d894.

@strager strager closed this as completed May 2, 2023
@herrhotzenplotz
Copy link
Contributor Author

Nice! Thank you. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants