When I run make -j3
to build in parallel, I get
warning: -jN forced in submake: disabling jobserver mode.
In the documentation I found the warning is emitted
if make detects error conditions related to parallel processing on systems where sub-makes can communicate.
What are these error conditions? What can I do to heal them or suppress the error message?
The makefile is generated from CMake, so I cannot (=I don't want to) edit the makefile.
You call make -j3
for you top-level Makefile, which means that up to 3 targets can be built simultaneously (make uses 3 threads to build). Your top-level Makefile (generated by CMake) run another make (which is called sub-make). And in this invocation another -jN
option is used. So instead of using common jobserver for both makes, sub-make uses another N threads to build its targets. So up to 3 + N
threads in total are used for building. So this is what this warning about.
To enable common jobserver for parent make and sub-make, there are 2 requirements:
-jN
option mustn't be passed to sub-make. Call sub-make without this argument.$(MAKE)
expression (not just plain make
). Alternatively the +
prefix can be added before make
command. See this answer for details.If both requirements are satisfied, then, when you run make -jN
for you top-level Makefile, parent make and child make use N threads in common for building.
Usually this message occurres if you call make from your Makefile not by the variable $(MAKE)
Example:
Change
foo: cd foo/ && make foo
to
foo: cd foo && $(MAKE) foo
This is related to multi-threaded make feature. It happens when there is yet another multi-threaded make inside a make process that is already multi-threaded. As there is second level of multi-threaded make, the internal synchronization is not available.
It is possible to fix this by -j parameter.
make -j 1
The code above will avoid multiple thread and it will remove the warnings.
Again, we can use -j
parameter in the makefile as well.
target:
$(MAKE) -j 1 -C ${SUBDIR} $@
The above rule will not spawn threads for submake
and it will avoid the warning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With