mirror of
				https://github.com/zeromq/libzmq.git
				synced 2025-10-30 05:29:43 +01:00 
			
		
		
		
	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.
This commit is contained in:
		
							
								
								
									
										19
									
								
								configure.ac
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								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 <unistd.h>]], | ||||
| 		[[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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 David Gloe
					David Gloe