3

From various sources (like this) state that you can parallelise your build jobs with:

make -j n

where n is the number of jobs. In QNX 6.5.0 with GNU Make 3.81 I noticed that the number doesnt seem to work. If i call make -j (no number) a huge number of compilers will be started and the processors will be used fully:

CPU states: 80.5% user, 5.0% kernel
CPU  0 Idle: 15.2%
CPU  1 Idle: 13.2%
CPU  2 Idle: 14.7%
Memory: 0 total, 281M avail, page size 4K

      PID   TID PRI STATE    HH:MM:SS    CPU  COMMAND
     8200     2  21 Rcv       0:00:17  12.02% devb-eide
 43565087     1  10 Rdy       0:00:00  11.38% make
 43819103     1  10 Rply      0:00:00   3.01% cmake
 43716678     1  10 Rply      0:00:00   2.80% cmake
 43671611     1  10 Rply      0:00:00   1.87% make
 43589671     1  10 Rply      0:00:00   1.73% make
 43569184     1  10 Rply      0:00:00   1.73% make
 43573283     1  10 Rply      0:00:00   1.46% make
 43667514     1  10 Rply      0:00:00   1.28% make
 43839590     1  10 Send      0:00:00   1.10% cmake

Unfortunately when i use make -j having the huge number of concurrent builds means that my limited VM quickly runs out of memory.

But if I add a number (eg. make -j 4, which corresponds to the number of cores in my VM) then it will only ever start 1 process. This also occurs with the following variants:

make -j4
make -j 4
make --jobs=4
make --jobs 4

As well as with some other processor numbers (2, 3, 4, 5, 6, 7, 8).

Why doesnt make -j with a specified number work in QNX?

Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175
  • 2
    How is that related to c++? – Slava May 25 '18 at 12:57
  • What implementation of `make` are you using? What version of that implementation? – Some programmer dude May 25 '18 at 12:59
  • @Someprogrammerdude Added to the quest, and it is GNU Make 3.81 – Fantastic Mr Fox May 25 '18 at 13:01
  • You are free to remove makefile tag if it is unrelated, but I would say it is much more related than c++ – Slava May 25 '18 at 13:08
  • did you try to create simple makefile with echo command without any dependency and run `make -j` on it? Did you try to run `mke -j4` (without space)? Did you try to use full form `make --jobs=4` ? Did you check that you do not have alias for `make`? – Slava May 25 '18 at 13:11
  • @Slava, I updated the question with more information of what i have tried. I will try the simple makefile now. I have no make aliases. – Fantastic Mr Fox May 25 '18 at 13:17
  • 1
    I have no access to QNX but the last time I used it (>10 years ago) it had a fairly robust POSIX interface, so I have no idea why -j N would not work. I assume that since you're using such an old version you didn't build it yourself. Maybe the person who built it disabled the jobserver. I recommend you obtain the latest GNU make version source file and try to compile it yourself. When you run configure, see what it says about jobserver support. – MadScientist May 25 '18 at 14:10
  • @MadScientist But it can create multiple jobs when no number is supplied. Do you think the build configuration could have caused behaviour like this? – Fantastic Mr Fox May 25 '18 at 14:14
  • 1
    make uses entirely different ways of handling multiple jobs when you give a number with -j and when you give no number. With `-j` by itself you are asking for "infinite parallelism" so make doesn't count the number of jobs running or track them. And since 2 * infinity == infinity, all sub-makes also run infinite jobs and there's no tracking of jobs between recursive invocations of make. When you use `-jN` all those extra capabilities come into play. Using `-j` with no maximum is intended to be used in conjunction with `-l` (limit jobs based on system load). – MadScientist May 25 '18 at 14:22
  • @MadScientist Makes sense. Thanks for the advice, i will look into it. – Fantastic Mr Fox May 25 '18 at 14:30

1 Answers1

0

The make version used in the system must have been compiled using a configure item that disabled the -j task engine. Recompiling GNU Make 3.81 and 4.2 yielded a binary that can successfully use the -j switch with a number.

Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175