From: Paul Smith Date: Sat, 15 Sep 2018 18:48:57 +0000 (-0400) Subject: * src/main.c (main): Set jobserver permissions before re-execing X-Git-Tag: 4.2.90~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d603b2e6ac0f4c2ae69a428e5c63349c289fe1a6;p=thirdparty%2Fmake.git * src/main.c (main): Set jobserver permissions before re-execing Fixes an issue seen in the Linux kernel build system, reported by Masahiro Yamada . Fix suggested on the bug-make mailing list by Mike Shal . * tests/scripts/features/parallelism: Add a test to verify this. --- diff --git a/src/main.c b/src/main.c index eed4e819..bcaeab76 100644 --- a/src/main.c +++ b/src/main.c @@ -2461,6 +2461,9 @@ main (int argc, char **argv, char **envp) fflush (stdout); fflush (stderr); + /* The exec'd "child" will be another make, of course. */ + jobserver_pre_child(1); + #ifdef _AMIGA exec_command (nargv); exit (0); @@ -2491,6 +2494,9 @@ main (int argc, char **argv, char **envp) #endif exec_command ((char **)nargv, environ); #endif + + /* We shouldn't get here but just in case. */ + jobserver_post_child(1); free (aargv); break; } diff --git a/tests/scripts/features/parallelism b/tests/scripts/features/parallelism index 42579473..07fb7580 100644 --- a/tests/scripts/features/parallelism +++ b/tests/scripts/features/parallelism @@ -188,6 +188,41 @@ file2: file1 ; @touch $@ rmfiles('file1', 'file2', 'file3', 'file4'); +# Ensure that the jobserver is preserved across make re-exec. + +run_make_test(q! +all: one two +one: ;@ #PERL# jhelp.pl -w TWO -f ONE +two: ;@ #PERL# jhelp.pl -f TWO +include fff1.mk +fff1.mk: ; touch $@ +!, + '-j2', "touch fff1.mk\nTWO\nONE\n"); + +unlink('fff1.mk', 'ONE', 'TWO'); + +# Test if a sub-make needs to re-exec and the makefile is built via +# sub-make. Reported by Masahiro Yamada + +run_make_test(q! +all: ; @$(MAKE) -f #MAKEFILE# recurse + +recurse: one two ; @echo $@ +one: ;@ #PERL# jhelp.pl -w TWO -f ONE +two: ;@ #PERL# jhelp.pl -f TWO + +mkinclude: ; touch fff1.mk + +ifeq ($(MAKECMDGOALS),recurse) +include fff1.mk +fff1.mk: ; @$(MAKE) -f #MAKEFILE# mkinclude +endif +!, + '--no-print-directory -j2', "touch fff1.mk\nTWO\nONE\nrecurse\n"); + +unlink('fff1.mk', 'ONE', 'TWO'); + + # Make sure that all jobserver FDs are closed if we need to re-exec the # master copy. #