c++ - 二进制链接与 gold 链接器运行得更快吗?

标签 c++ ubuntu linker ld gold-linker

使用 GEANT4(大型 Monte Carlo C++ 仿真框架,大量共享库)运行仿真代码。使用黄金链接器和基于标准 BFD 的链接器编译并链接 GEANT 和我的应用程序。看起来金色的跑得更快了一点(1'47"对 1'51")。有人可以阐明造成差异的原因是什么吗? Ubuntu 15.04、64 位、GCC 4.9.2。每个测试运行大约 10 次,用时最少,没有其他事件,一个终端。

最佳答案

当然,不同的链接器会产生不同的结果,就像不同的编译器一样。结果主要取决于每个链接器上启用(和可用)的优化选项。这是您看到的差异的一个可能原因,但可能还有许多其他原因:

-fipa-icf

Perform Identical Code Folding for functions and read-only variables. The optimization reduces code size and may disturb unwind stacks by replacing a function by equivalent one with a different name. The optimization works more effectively with link time optimization enabled. Nevertheless the behavior is similar to Gold Linker ICF optimization, GCC ICF works on different levels and thus the optimizations are not same - there are equivalences that are found only by GCC and equivalences found only by Gold.

来自:https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

最后但同样重要的是:除了实际的二进制内容之外,还有许多环境因素会影响运行时。例如,缓存抖动会对执行时间产生相当大的影响。此外,10 次执行的集合对于统计结论来说太小了。

关于c++ - 二进制链接与 gold 链接器运行得更快吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30010588/

相关文章:

c++ - 反转字符串中的单词,

linux - 值错误 : Namespace Gtk not available

linux - 获取 MAC 地址问题 Linux(Ubuntu)

ubuntu - 无法在 ubuntu 中升级 PHPUnit

c++ - 为什么删除 const 会给我链接器错误?

c++ - 为什么有些函数分布密集,而另一些函数则用 int 3 指令对齐和填充?

c++ - Visual Studio 链接错误 LNK2005 和 LNK2020

c++ - 把最胖的人从重载的飞机上扔下来。

c++ - boost 图是否正在切片我的 shared_ptr

c++ - Visual Studio 中函数的返回值