On Mon, 2024-06-10 at 22:14 +0100, Richard Copley wrote:
> What is the correct way to cause jobserver information to be passed
> to
> child processes? I tried this Makefile:
> 
> all:
>     @echo Jobserver present? $(filter jobserver,$(.FEATURES))
>     +@sh -c "echo \"make toplevel MAKEFLAGS=${MAKEFLAGS}\""
>     +@sh -c "echo \"child toplevel MAKEFLAGS=$${MAKEFLAGS}\""
>     +$(MAKE) recursive
> 
> recursive:
>     +@sh -c "echo \"make recursive MAKEFLAGS=${MAKEFLAGS}\""
>     +@sh -c "echo \"child recursive MAKEFLAGS=$${MAKEFLAGS}\""
> 
> # Makefile ends
> 
> The actual output is:
> 
> make -j

This is your problem.

When you run "make -j" with no limit, then make doesn't ever create a
jobserver.  Why create a jobserver when you have an unlimited number of
jobs to run?

In this case the "-j" flag just tells make to run everything it
possibly can with no limits.

If you provide a limit you'll see different behavior, e.g.:

  make -j5

Reply via email to