[英]Is there a way to make G++/clang++ compile times as fast as MSVC?
For my tests I need to compile some thousand C++ files which have a lot of code in common.对于我的测试,我需要编译几千个 C++ 文件,这些文件有很多共同的代码。 Because not all compilers are conformant (or more permissive) I execute all my tests with g++, clang++ and msvc on windows and linux.因为并非所有编译器都符合(或更宽松),所以我使用 g++、clang++ 和 msvc 在 windows 和 linux 上执行所有测试。
To improve compile times I use already precompiled headers for common code.为了缩短编译时间,我对公共代码使用了已经预编译的标头。 Additionally I wrote a small preprocessor app to allow "unity builds" (combine *.cpp files into a single *.cpp file).此外,我编写了一个小型预处理器应用程序以允许“统一构建”(将 *.cpp 文件组合成一个 *.cpp 文件)。
Currently I get the following compile times (random test case):目前我得到以下编译时间(随机测试用例):
(approx 10 times) (约 10 次)
(approx 1.4 times) (约1.4倍)
(approx 1.9 times) (约1.9倍)
Unfortunately my code contains a lot of templates / template instantiations which seem to be only "saved" in the Microsoft PCH.不幸的是,我的代码包含很多模板/模板实例,它们似乎只“保存”在 Microsoft PCH 中。
Do you know any way to get similar compile times for g++ and clang++?你知道有什么方法可以使 g++ 和 clang++ 的编译时间相似吗? Do you have any suggestion how to improve my compile times?您对如何改善我的编译时间有什么建议吗?
Here you can see the chrome/clang trace (-ftime-trace and pch):在这里您可以看到 chrome/clang 跟踪(-ftime-trace 和 pch):
I see at least in the current clang trunk that there is some notable progress to improve compile times in combination with templates and precompiled headers / modules.我至少在当前的 clang 主干中看到,结合模板和预编译头文件/模块,在改进编译时间方面取得了一些显着进展。
Perhaps gcc implements something similar - we will see.或许 gcc 实现了类似的东西——我们将拭目以待。 But thanks for your comments.但感谢您的意见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.