简体   繁体   English

我可以使用LLVM加速构建并减少GCC编译时间吗?

[英]Can I use LLVM to accelerate a build and reduce GCC compile time?

I am trying to reduce the compile time for HHVM which can take two hours. 我试图减少HHVM的编译时间,这可能需要两个小时。

I read somewhere that LLVM can act as a preprocessor to gcc and greatly reduce memory use and compile time? 我在某处读到LLVM可以充当gcc的预处理器并大大减少内存使用和编译时间?

Unfortunately I cannot seem to compile HHVM directly with clang as I get strange fatal errors like 'array' file not found even though I tried setting the CXXFLAGS to -std=c++11 or -std=gnu++11 mode, no luck. 不幸的是我似乎无法直接使用clang编译HHVM ,因为我发现奇怪的致命错误,如'array' file not found即使我尝试将CXXFLAGS设置为-std=c++11-std=gnu++11模式,没有运气。

I've read about dragonegg but not sure how to use it or if it is what I am looking for? 我读过有关dragonegg但不确定如何使用它或者它是否是我正在寻找的内容?

dragonegg is a LLVM code generation plugin for gcc, so it's the other way around from what you're looking for. dragonegg是gcc的LLVM代码生成插件,所以它与你正在寻找的方式相反。

I'm not aware of a way to plug Clang in the front of gcc that's supported these days. 我不知道如何在这些天支持的gcc前面插入Clang。 That said, if you can build a project with gcc, it shouldn't be hard to build it with Clang. 也就是说,如果你可以使用gcc构建一个项目,那么用Clang构建它应该不难。 Even the Linux kernel can be built with Clang these days with some minor patches. 如今,即使是Linux内核也可以使用Clang构建一些小补丁。 It's very likely that the HVVM developers build it with Clang as well, and they may have some patches for that. HVVM开发人员很可能也会使用Clang构建它,并且他们可能会有一些补丁。

But the answer to the question in the title is no. 但标题中问题的答案是否定的。

I read somewhere that LLVM can act as a preprocessor to gcc 我在某处读到LLVM可以充当gcc的预处理器

I think that what you read was literally about pre-processing. 我认为你读到的内容实际上是关于预处理的。 Indeed, I myself vaguely remember someone calling Clang's pre-processor faster than GCC's. 实际上,我自己依稀记得有人比GCC更快地打电话给Clang的预处理器。 Unfortunately for us, your answer does not provide the link to your source of information, so it is impossible to check what the actual claim was. 对我们来说不幸的是,您的答案并没有提供您的信息来源的链接,因此无法检查实际的索赔是什么。

You can pre-process your C files with clang -E file.c -o file.i . 您可以使用clang -E file.c -o file.i预处理C文件。 After this, you can compile file.i with GCC, and GCC will be able to omit its (supposedly slower) pre-processor. 在此之后,您可以使用GCC编译file.i ,GCC将能够省略其(假设速度较慢)的预处理器。 Unfortunately for you, pre-processing is the easiest step of the compilation of a C file, and I doubt it accounts for more than 3% of the total time, meaning that even halving the time taken by pre-processing will at best improve compilation time by 1.5%. 不幸的是,预处理是编译C文件的最简单步骤,我怀疑它占总时间的3%以上,这意味着即使将预处理所花费的时间减半,也最多可以改善编译时间减少1.5%。

I do not see any other language, common between the two compilation suites, than pre-processed C that could be output from Clang to be fed into GCC in order to speed up anything. 我没有看到两个编译套件之间常见的任何其他语言,而不是可以从Clang输出的预处理C,以便加速到GCC以加速任何事情。

In any case, I think working with clang directly would be much easier. 无论如何,我认为直接使用clang会更容易。 So try to find out why clang is not working for the project, and find patches / fixes for this. 因此,尝试找出为什么clang不适用于该项目,并找到补丁/修复程序。

For example, applying this patch might be a good start. 例如,应用此补丁可能是一个好的开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM