bugmake - Bugs: bug #65685, Submake starts its own jobserver...

 
 

bug #65685: Submake starts its own jobserver when its recipe contains $(MAKE) $(MFLAGS)

Submitter:  Dmitry Goncharov <dgoncharov>
Submitted:  Sat 04 May 2024 08:57:53 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  SCM Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 07 May 2024 01:37:56 AM UTC, comment #3: 


>  The way I remember it is that if we see a valid jobserver-auth argument, we ignore the value of -j.


My understanding was that we ignore -j that comes from MAKEFLAGS, we still honor -j specified on the command line.

> I wonder if we should simply keep the same behavior for both; if we see a jobserver-auth on the command line we also ignore -j.


My concern is that ignoring -j specified on the command line would cause the submake in the following example run within the parent jobserver.


all:; $(MAKE) $(MFLAGS) -j3


Dmitry Goncharov <dgoncharov>
Mon 06 May 2024 06:26:13 PM UTC, comment #2: 

I'm not sure I get where the problem is coming from.  The way I remember it is that if we see a valid jobserver-auth argument, we ignore the value of -j.  This is so that we can keep the -j option in the value of MAKEFLAGS so that users can review it.

I suppose the difference we're tracking is whether the option is passed via the environment or via the command line?

I wonder if we should simply keep the same behavior for both; if we see a jobserver-auth on the command line we also ignore -j.  This would still allow people to run an explicit $(MAKE) -jN and have it do the right thing.

But that might be tricky since we'd have to understand whether the jobserver-auth was actually on the command line or whether it came from the environment earlier.

Paul D. Smith <psmith>
Group administrator
Sat 04 May 2024 09:17:59 PM UTC, comment #1: 

Make adds '-j' to MAKEFLAGS and MFLAGS when -j is specified on the command
line.
When MFLAGS that contains -j is expanded in a recipe, the submake gets -j as
a command line switch. This causes submake to start its own jobserver and the
submake no longer participates in the parent jobserver.


$ ls
makefile  makefile2
$ cat makefile
all:; $(MAKE) -fmakefile2 $(MFLAGS)
$ cat makefile2
all:;:
$ make --no-print-directory -j4
make -fmakefile2 -j4 --jobserver-auth=3,4 --no-print-directory
make[1]: warning: -j4 forced in submake: resetting jobserver mode.
:


This was recently reported to the bash mailing list.
https://lists.gnu.org/archive/html/bug-bash/2024-04/msg00078.html.

Submakes don't need -j to participate in the top make's jobserver.
The obvious temptation is to keep MAKEFLAGS and MFLAGS free of -j.
However, -j needs to stay in MAKEFLAGS to allow makefiles to append -j to
MAKEFLAGS.
E.g. the following code needs -j in MAKEFLAGS.


MAKEFLAGS+=-j2


This patch modifies make to avoid -j in MFLAGS.
This patch keeps MAKEFLAGS intact.
Ofcourse, if the user explicitly expands MAKEFLAGS in a recipe they are back to
the quare one. Explicitly expanding MFLAGS in a recipe is legalized in the
make manual, but explicitly expanding MAKEFLAGS is not. On top of that
explicitly expanding MAKEFLAGS has other isses, see
https://savannah.gnu.org/bugs/?62469.

Dmitry Goncharov <dgoncharov>
Sat 04 May 2024 08:57:53 PM UTC, original submission:  

.

Dmitry Goncharov <dgoncharov>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #56011:  sv65685_part1.diff added by dgoncharov (23KiB - text/x-patch)
file #56012:  sv65685_part2.diff added by dgoncharov (5KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by dgoncharov (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-05-04 dgoncharov Attached File- Added sv65685_part1.diff, #56011
        Attached File- Added sv65685_part2.diff, #56012

    Back to the top

    Powered by Savane 3.14-0608.
    Corresponding source code