bugmake - Bugs: bug #60919, Communicating -j to sub-make not...


bug #60919: Communicating -j to sub-make not working properly after make 4.1

Submitted by:  Bahaa Hamza <bahaahamza>
Submitted on:  Thu 15 Jul 2021 07:56:37 AM UTC  
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.1 Operating System:  None
Fixed Release:  None Triage Status:  None

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Thu 15 Jul 2021 05:48:17 PM UTC, comment #1: 

Your parent makefile is incorrect.  By adding an explicit -j option to the submake command line you are forcing the sub-make to run in a mode with no restrictions on the amount of parallelism; see the documentation:

> If there is nothing looking like an integer after the ‘-j’ option, there is no limit on the number of job slots.

If you want to have your sub-makes participate in the jobserver and obey the limits provided by the make command line, you should remove the -j option from the submake command line.  In other words, change:

        sleep .1; echo start test1; sleep .1; cd child; $(MAKE) -j ;  echo end test1

to this:

        sleep .1; echo start test1; sleep .1; cd child; $(MAKE) ;  echo end test1

And the same for all other sub-make invocations obviously.

In general you never want to add specific options to the command line of sub-makes unless you're trying to modify or override the operations that the user specified when they invoked the top-level make (which should be extremely rare).

Paul D. Smith <psmith>
Project Administrator
Thu 15 Jul 2021 07:56:37 AM UTC, original submission:  

Referring to make manual, in "Communicating Options to a Sub-make". The following was mentioned:
"The ‘-j’ option is a special case (see Parallel Execution). If you set it to some numeric value ‘N’ and your operating system supports it (most any UNIX system will; others typically won’t), the parent make and all the sub-makes will communicate to ensure that there are only ‘N’ jobs running at the same time between them all."

Prior to make version 4.1 (4.0 and earlier), this was working fine. If parent make was run with -jN, eventually make and sub-make will be running only N jobs.

But since make 4.1 (till 4.3), it's not working as before.
sub-make will spawn several jobs and the total count is more than N.

I tried to check in Changelog if this was an intended change in behavior, but i didn't find this change.

    • Testcase:

I've attached a testcase to this bug.
For example, you can run "make -j 2" using make 3.8 and make 4.2.
For v3.8, you will notice that only 2 jobs will be running at a time (subtests).
While for v4.2, all chile subtests will be spawned (2 * 8).

Bahaa Hamza <bahaahamza>


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

Attach Files:

Attached Files
file #51666:  testcase.tar.gz added by bahaahamza (447B - application/x-gzip)


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 bahaahamza (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-07-15 psmith StatusNone => Not A Bug
        Open/ClosedOpen => Closed
    2021-07-15 bahaahamza Attached File- => Added testcase.tar.gz, #51666

    Back to the top

    Powered by Savane 3.7