Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parallel Make Output

When running a CMake generated Makefile with multiple processes (make -jN), the output often gets messed up like this:

[  8%] [  8%] [  9%] Building CXX object App/CMakeFiles/App.dir/src/File1.cpp.o
Building CXX object App/CMakeFiles/App.dir/src/File2.cpp.o
Building CXX object App/CMakeFiles/App.dir/src/File3.cpp.o

I'm not sure, but I think this behavior is also there for Makefiles not generated by CMake. I'd say it happens when multiple processes write to stdout at the same time.

I know I'm probably being pedantic, but is there any (simple) fix to this? ;)

like image 817
lucas clemente Avatar asked Dec 04 '22 23:12

lucas clemente


2 Answers

If you're using GNU make, you can do it by redefining SHELL such that commands are wrapped by a trivial utility that ensures atomicity of information printed to standard output. Here's a more detailed description, including sample source for the wrapper utility.

like image 70
Eric Melski Avatar answered Dec 12 '22 10:12

Eric Melski


I tried to get the CMake people to fix this, but apparently they don't want to. See http://www.cmake.org/Bug/view.php?id=7062.

like image 43
JesperE Avatar answered Dec 12 '22 11:12

JesperE