将所有源文件一次传递给编译器有什么好处吗? [英] Is there any benefit to passing all source files at once to a compiler?

查看:164
本文介绍了将所有源文件一次传递给编译器有什么好处吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过关于整体程序优化(wpo)和链接时间代码生成(ltcg)的内容。我不知道是否有更多的模块间模块如果我一次从cli传递所有的源到编译器(如g ++ a.cpp b.cpp),分析会继续吗?
或者只是要启用其中一个标志?



编译器之间是否有区别?
例如,intel编译器可以从这种做法中受益,而其他编译器不会这样做吗?

解决方案

我想知道是否有更多的模块间分析继续进行,如果我一次从cli传递给编译器(比如g ++ a.cpp b.cpp)?


对于GCC,不,这样做不会启用任何WPO,每个转换单元都是单独处理的。我99%肯定Clang的情况也是如此,90%的人确信它对于其他大多数编译器都是如此。



使用GCC,为了实现模块间优化,您需要通过 -flto 开关显式请求它,该开关仍然独立地处理每个翻译单元,但是附加信息被写入目标文件,然后当它们链接在一起时,进一步优化通过完成以产生最终输出。

I have read about "Whole Program Optimization" (wpo) and "Link Time Code Generation" (ltcg).

I wonder is there more inter-module-analysis going on if I pass all sources at once to the compiler from the cli (like "g++ a.cpp b.cpp")? Or is that just going to enable one of those flags?

Is there a difference between compilers for this? For instance can the intel compiler benefit from such practice while other compilers don't?

解决方案

I wonder is there more inter-module-analysis going on if I pass all sources at once to the compiler from the cli (like "g++ a.cpp b.cpp")?

For GCC, no, doing that does not enable any WPO, each translation unit is processed separately, in isolation. I'm 99% sure the same is true for Clang, and 90% sure it's true for most other compilers.

With GCC, to enable inter-module optimisation you need to request it explicitly via the -flto switch, which still processes each translation unit in isolation, but additional information is written to the object file and then when they are linked together further optimisation passes are done to produce the final output.

这篇关于将所有源文件一次传递给编译器有什么好处吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆