Warning "forced in submake" in parallel execution of make
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.
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:
- Explicit
-jN
option mustn't be passed to sub-make. Call sub-make without this argument. - Sub-make must be called using
$(MAKE)
expression (not just plainmake
). Alternatively the+
prefix can be added beforemake
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.