问题描述
如果我想用-flto
编译我的项目,用--enable-gold
构建gcc是否足够?还是我还需要构建gold并用它替换ld?我还需要其他标志吗?即我正在这样做
If I want to compile my project with -flto
is it enough to have built gcc with --enable-gold
or do I also need to build gold and replace ld with it? And do I need any other flags? Ie I'm doing this
gcc -flto one.c two.c
推荐答案
根据 https://gcc.gnu.org/wiki/LinkTimeOptimization#Requirements ,
此外, GCC文档表示-fuse-linker-plugin
:
因此,即使您想使用特殊的链接器插件"功能从库档案中的目标文件中获取优化信息,也根本不需要gold
.
So you don't need gold
at all, even if you want to use the special "linker plugin" feature to pick up optimization information from object files in library archives.
There are usage examples in the -flto
documentation. Either
gcc -o myprog -flto -O2 foo.c bar.c
或
gcc -c -O2 -flto foo.c
gcc -c -O2 -flto bar.c
gcc -o myprog -flto -O2 foo.o bar.o
将起作用.
截至 GCC 4.9 ,您甚至不需要-flto
进行链接:
As of GCC 4.9, you don't even need -flto
for linking:
并且自 GCC 5 :
这篇关于使用flto的要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!