From c85f68c4e952294304e5938acb601e66f5df71a0 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sat, 18 Feb 2023 13:20:00 -0500 Subject: [PATCH] Allow jobserver style to be forced to "pipe" Some systems that support mkfifo() don't support the usage that GNU make wants. Provide a way to force using "pipe" jobserver mode even when mkfifo() is available. * src/makeint.h (MK_OS_HURD): Define if we're on Hurd. (JOBSERVER_USE_FIFO): Define if we have mkfifo() and we're NOT on Hurd. * src/main.c (main): Test JOBSERVER_USE_FIFO not HAVE_MKFIFO. * src/posixos.c (jobserver_setup): Ditto. * maintMakefile: Create a config check test for forcing "pipe" mode. * tests/run_make_tests.pl: Show discovered FEATURES in verbose mode. --- maintMakefile | 2 ++ src/main.c | 3 ++- src/makeint.h | 11 +++++++++++ src/posixos.c | 4 ++-- tests/run_make_tests.pl | 1 + 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/maintMakefile b/maintMakefile index 2747aad6..ae25ee75 100644 --- a/maintMakefile +++ b/maintMakefile @@ -274,6 +274,7 @@ CFGCHECK_MAKEFLAGS = # CFLAGS='$(AM_CFLAGS)' checkcfg.strict-c90: CFGCHECK_CONFIGFLAGS = CFLAGS='-std=c90 -pedantic' checkcfg.strict-c90: CFGCHECK_MAKEFLAGS = +checkcfg.job-pipe: CFGCHECK_CONFIGFLAGS = CPPFLAGS=-DJOBSERVER_USE_FIFO=0 checkcfg.no-jobserver:CFGCHECK_CONFIGFLAGS = --disable-job-server checkcfg.no-load: CFGCHECK_CONFIGFLAGS = --disable-load checkcfg.no-guile: CFGCHECK_CONFIGFLAGS = --without-guile @@ -289,6 +290,7 @@ checkcfg.no-archives: CFGCHECK_CONFIGFLAGS = CPPFLAGS=-DNO_ARCHIVES CONFIG_CHECKS := \ checkcfg.strict-c90 \ + checkcfg.job-pipe \ checkcfg.no-jobserver \ checkcfg.no-load \ checkcfg.no-guile \ diff --git a/src/main.c b/src/main.c index 8ad750b8..dde0d77d 100644 --- a/src/main.c +++ b/src/main.c @@ -234,6 +234,7 @@ static const int inf_jobs = 0; char *jobserver_auth = NULL; /* Style for the jobserver. */ + static char *jobserver_style = NULL; /* Shuffle mode for goals and prerequisites. */ @@ -1447,7 +1448,7 @@ main (int argc, char **argv, char **envp) #endif #ifdef MAKE_JOBSERVER " jobserver" -# ifdef HAVE_MKFIFO +# if JOBSERVER_USE_FIFO " jobserver-fifo" # endif #endif diff --git a/src/makeint.h b/src/makeint.h index 187974e4..1e1596d2 100644 --- a/src/makeint.h +++ b/src/makeint.h @@ -83,6 +83,9 @@ extern int errno; #endif /* Define macros specifying which OS we are building for. */ +#if __gnu_hurd__ +# define MK_OS_HURD 1 +#endif #if defined(__MVS__) # define MK_OS_ZOS 1 #endif @@ -742,6 +745,14 @@ extern char cmd_prefix; extern unsigned int no_intermediates; +#if HAVE_MKFIFO +# if !defined(JOBSERVER_USE_FIFO) && !MK_OS_HURD +/* It seems that mkfifo() is not working correctly, or at least not the way + GNU make wants it to work, on GNU/Hurd so don't use it there. */ +# define JOBSERVER_USE_FIFO 1 +# endif +#endif + #define JOBSERVER_AUTH_OPT "jobserver-auth" extern char *jobserver_auth; diff --git a/src/posixos.c b/src/posixos.c index 0fe0948a..0cc0a585 100644 --- a/src/posixos.c +++ b/src/posixos.c @@ -147,8 +147,8 @@ jobserver_setup (int slots, const char *style) { int r; -#if HAVE_MKFIFO - if (style == NULL || strcmp (style, "fifo") == 0) +#if JOBSERVER_USE_FIFO + if (!style || strcmp (style, "fifo") == 0) { /* Unfortunately glibc warns about uses of mktemp even though we aren't using it in dangerous way here. So avoid this by generating our own diff --git a/tests/run_make_tests.pl b/tests/run_make_tests.pl index a5d9b807..012bd66d 100644 --- a/tests/run_make_tests.pl +++ b/tests/run_make_tests.pl @@ -671,6 +671,7 @@ sub set_more_defaults create_file('features.mk', 'all:;$(info $(.FEATURES))'); %FEATURES = map { $_ => 1 } split /\s+/, `$make_path -sf features.mk`; + print "$make_path FEATURES: @{[%FEATURES]}\n" if $verbose; unlink('features.mk'); # Find the default values for different built-in variables