Skip to content

FreeBSD: CMake system test for libutil is broken #999

@herrhotzenplotz

Description

@herrhotzenplotz

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions