Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gcc 如何去上班?_Gcc - Fatal编程技术网

Gcc 如何去上班?

Gcc 如何去上班?,gcc,Gcc,我正在使用GCC4.7.2和LD2.23,但是当我在编译选项中添加-flto时,我的编译时间增加了20%以上!该手册似乎指出,需要使用-fuse链接器插件来进行优化。它还表示默认情况下使用-flto启用它,但当我显式添加它时,我在link命令中看到以下错误: g++: error: -fuse-linker-plugin is not supported in this configuration 根据手册,它应该由LD 2.21或更高版本支持。知道我为什么会犯这个错误吗?以下是我的完整编译命

我正在使用GCC4.7.2和LD2.23,但是当我在编译选项中添加-flto时,我的编译时间增加了20%以上!该手册似乎指出,需要使用-fuse链接器插件来进行优化。它还表示默认情况下使用-flto启用它,但当我显式添加它时,我在link命令中看到以下错误:

g++: error: -fuse-linker-plugin is not supported in this configuration
根据手册,它应该由LD 2.21或更高版本支持。知道我为什么会犯这个错误吗?以下是我的完整编译命令示例,以供参考:

g++ -Wall -pipe -O3 -flto -fno-strict-aliasing -mtune=generic --no-exceptions -fPIC -c some.cc
g++ -o exec -Xlinker some1.o some2.o -static some1.a some2.a -Wl,--wrap,open -flto -fuse-linker-plugin
运行“ld--help | grep plugin”会显示“-plugin”选项,所以我不明白GCC为什么会抱怨:

-plugin PLUGIN              Load named plugin
-plugin-opt ARG             Send arg to last-loaded plugin

链接时间优化不应该减少编译时间,而是优化程序的运行时

@选项,只需将“-flto-fuse-linker-plugin”添加到您的CFLAGS(或cxflags for c++)和LDFLAGS中,它就可以正常工作了

@gold:ld——版本可能会返回GNULD,切换到gold,使ld符号链接哪个ld指向哪个ld.gold which ld
e、 g.ln-s/usr/bin/ld.gold/usr/bin/ld

你查过了吗?谢谢你的链接。我没有构建我们的GCC,但我使用strace运行了GCC,甚至没有看到任何对LD的调用,因此我认为GCC不会抛出错误。删除该选项并使用strace,我可以确认没有使用系统LD。使用的版本是2.23.1。不确定它是否是金色的。你说这是定制的吗?不需要特殊的选项。只需使用g++进行链接,也可以使用-flto进行链接步骤(可能还包括编译开关)。AFAIK认为4.5或更早版本中需要插件。 which ld.gold ln -s /usr/bin/ld.gold /usr/bin/ld