]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* src/main.c (main): Set jobserver permissions before re-execing
authorPaul Smith <psmith@gnu.org>
Sat, 15 Sep 2018 18:48:57 +0000 (14:48 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 15 Sep 2018 19:08:47 +0000 (15:08 -0400)
Fixes an issue seen in the Linux kernel build system, reported by
Masahiro Yamada <yamada.masahiro@socionext.com>.  Fix suggested
on the bug-make mailing list by Mike Shal <marfey@gmail.com>.
* tests/scripts/features/parallelism: Add a test to verify this.

src/main.c
tests/scripts/features/parallelism

index eed4e8193a2dee6c178fadeb9e2f994c20eae277..bcaeab76336fc18ee9bc1f3ef7bc74aeb20472da 100644 (file)
@@ -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;
         }
index 42579473fa71c33b878861d2112c0f708f2e55b2..07fb7580799c3fd76d4a1758c4af9f6676121c7b 100644 (file)
@@ -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 <yamada.masahiro@socionext.com>
+
+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.
 #