From 240e36af4e0300a529c99b0a05c4bf391bbcd6f5 Mon Sep 17 00:00:00 2001 From: David Gloe Date: Tue, 23 Nov 2021 15:39:42 +0000 Subject: [PATCH] Problem: Fix fork detection on gcc 7 Solution: When compiling with gcc 7 and newer, the program produced by AC_CHECK_FUNCS(fork) produces a warning, which results in configure incorrectly disabling fork support. Fix the issue by using an AC_COMPILE_IFELSE which correctly detects fork availability. Tested by running configure and make check on a system with gcc 7 installed, and verifying that HAVE_FORK was defined correctly. See issue #3313. --- configure.ac | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 227e37b4..1a571291 100644 --- a/configure.ac +++ b/configure.ac @@ -795,9 +795,24 @@ AC_LANG_POP([C++]) # Checks for library functions. AC_TYPE_SIGNAL -AC_CHECK_FUNCS(perror gettimeofday clock_gettime memset socket getifaddrs freeifaddrs fork mkdtemp accept4) +AC_CHECK_FUNCS(perror gettimeofday clock_gettime memset socket getifaddrs freeifaddrs mkdtemp accept4) AC_CHECK_HEADERS([alloca.h]) +# AC_CHECK_FUNCS(fork) fails on gcc 7 +AC_MSG_CHECKING([whether fork is available]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[return fork();]]) + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_FORK, [1], [fork is available]) + AM_CONDITIONAL(HAVE_FORK, true) + ],[ + AC_MSG_RESULT([no]) + AM_CONDITIONAL(HAVE_FORK, false) +]) + # string.h doesn't seem to be included by default in Fedora 30 AC_MSG_CHECKING([whether strnlen is available]) AC_COMPILE_IFELSE( @@ -995,8 +1010,6 @@ LIBZMQ_CHECK_GETRANDOM([ [Whether getrandom is supported.]) ]) -AM_CONDITIONAL(HAVE_FORK, test "x$ac_cv_func_fork" = "xyes") - if test "x$cross_compiling" = "xyes"; then # Enable draft by default when cross-compiling defaultval=yes