如何解开并行make -j编译器消息?

问题描述 投票:0回答:1

[当我使用make -j并行化编译命令时,并发命令中的任何编译器消息(警告/错误)都将被交错(毫不奇怪)。我想知道是否有办法unangle这些消息。

例如,使用make -j,我可能会看到类似的内容:

Scanning dependencies of target test
[ 33%] Building CXX object CMakeFiles/test.dir/C.cpp.o
[ 33%] Building CXX object CMakeFiles/test.dir/B.cpp.o
[ 50%] Building CXX object CMakeFiles/test.dir/A.cpp.o
[ 66%] Building CXX object CMakeFiles/test.dir/main.cpp.o
[ 83%] Building CXX object CMakeFiles/test.dir/D.cpp.o
/tmp/B.cpp:3:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/tmp/C.cpp:3:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
1 warning generated.
/tmp/A.cpp:3:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
/tmp/D.cpp:3:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
[100%] Linking CXX executable test
[100%] Built target test

每个.cpp都会触发警告,但它们以任意顺序交错。相反,如果我发出make,则会得到所需的顺序输出:

make 
[ 16%] Building CXX object CMakeFiles/test.dir/A.cpp.o
/tmp/A.cpp:3:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
[ 33%] Building CXX object CMakeFiles/test.dir/B.cpp.o
/tmp/B.cpp:3:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
[ 50%] Building CXX object CMakeFiles/test.dir/C.cpp.o
/tmp/C.cpp:3:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
[ 66%] Building CXX object CMakeFiles/test.dir/D.cpp.o
/tmp/D.cpp:3:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
[ 83%] Building CXX object CMakeFiles/test.dir/main.cpp.o
[100%] Linking CXX executable test
[100%] Built target test

但是很明显,我没有利用并行构建的优势。

在并行构建期间,有没有办法从每个命令收集警告/错误?

((我并没有超级附加到make。如果ninja或其他受cmake支持的命令行(非GUI IDE)构建系统可以执行此操作,那么我会接受它们。

makefile cmake stdout stderr build-system
1个回答
0
投票

您应使用output sync option

© www.soinside.com 2019 - 2024. All rights reserved.