bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regression caused by Commit: 5bd7ad2b225b ("Preserve the real value


From: Tim Murphy
Subject: Re: Regression caused by Commit: 5bd7ad2b225b ("Preserve the real value of -jN in MAKEFLAGS using jobserver.")
Date: Mon, 30 Oct 2017 07:33:47 +0000

For my money -j is always a top-level setting.   To have it per makefile and then let makefiles depend on that behaviour would open the door to lots of scary bugs.

Regards,

Tim

On 29 October 2017 at 18:57, Paul Smith <address@hidden> wrote:
On Thu, 2017-09-28 at 16:28 +1000, NeilBrown wrote:
> One of my Makefiles contains
>   MAKEFLAGS += -j
>
> Prior to the above commit, this would cause make to run as if I had
> run
>    make -j
>
> Since that commit, it appears to be ignored.

This is a bug clearly.  I've been thinking about it today and I wonder
what behavior people would expect to see if there are mismatches
between the various ways -j can be specified.

If it's a top-level make (not a sub-make in a jobserver grouping) then
I think the behavior is pretty straightforward based on normal make
priorities: if there's a command line -j setting use that; if not and
there's a MAKEFLAGS -j set in the makefile use that; if not and there's
a MAKEFLAGS -j set in the environment use that.

I don't think make should warn if the different sources have different
-j values.  You might set MAKEFLAGS=-j5 in your environment or makefile
but have "make -j1" to explicitly turn it off--you wouldn't want a
message about that IMO.

More interesting: what about a sub-make which is part of an existing
jobserver group?  Consider a sub-make invoked with -jN on the command
line; you have a makefile like this:

  $ cat cmd.mk
  subdir: ; $(MAKE) -C $@ -j2

If someone runs a simple "make -f cmd.mk", then you'd want the sub-make
to be run with -j2 of course.  But what if you do this:

  $ make -f cmd.mk -j4

What happens today is that a _new_ jobserver instance with -j2 is
started for the sub-make.  This could mean we have 5 total jobs
running, even though we specified -j4 on the command line.

That seems defensible, although I don't know that it's correct.

Now... what about if a sub-make has a MAKEFLAGS variable assignment?
Does that override an existing jobserver and cause the current make
instance to be the master of a new jobserver group, as if it were set
on the command line?

For example:

  $ cat sub.mk
  MAKEFLAGS += -j3
  all: ...

  $ cat cmd.mk
  MAKEFLAGS += -j2
  subdir: ; $(MAKE) -f sub.mk

  $ make -f cmd.mk -j4

Here we have a top-level make running the "cmd.mk" file, and a sub-make
running the "sub.mk" file.

The top make runs with -j4, because the command line overrides the
MAKEFLAGS += -j2 in cmd.mk.

What about the MAKEFLAGS setting in the sub.mk sub-make?  Does it force
a new top-level jobserver with jobs set to 3, as if we ran $(MAKE) -j3
in the subdir rule?  Or is it ignored (with a warning) if the sub-make
is already part of a jobserver group?

_______________________________________________
Bug-make mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/bug-make


reply via email to

[Prev in Thread] Current Thread [Next in Thread]