GCC v12.1关于串行汇编的警告
我已经升级了整个 th 2022年5月)。 GCC
也从 v11.2
升级到 v12.1
。我尝试通过以下命令使用 g ++
( gcc
编译器收集的一部分)编译一些程序:
g++ -O3 -DNDEBUG -Os -Ofast -Og -s -march=native -flto -funroll-all-loops -std=c++20 main.cc -o ./main
该程序完美地编译了,并且在没有任何错误的情况下播放,但是我得到了警告:
lto-wrapper: warning: using serial compilation of 2 LTRANS jobs
但是,当使用 v11.2
编制同一程序时,会产生零数量的错误和警告。
我的问题:
- 此警告是什么意思?
- 我该如何解决?
- 是否由于升级
gcc
版本升级到v12.1
这是 g ++
在我的计算机上配置:
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (GCC)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此警告是无害的。它只是告诉您,GCC仅使用单个CPU核心来进行链路时间优化,这意味着它会很慢。
警告出现是由于
-flto
选项的更改而出现的,该选项是在GCC 11.4 中引入的此提交。显示警告是因为-flto
选项仅如果明确指示执行此操作,则仅使用并行汇编。默认情况下,它只是使用慢速串行汇编(除非您拥有运行的作业服务器)。另请参见此对话在GCC邮件列表中:使用
-flto =自动
明确启用并行汇编并摆脱警告。如果您通过MingW或Msys2在Windows上使用GCC,则可能还必须将
make
环境变量设置为mingw32-make
和/或或通过<代码> -save-temps 选项以摆脱所有警告。-flto 的确切语义和效果是(与其他优化选项一起)的
-flto
是(一起) -options.html“ rel =“ noreferrer”> GCC手册。顺便说一句,您不应该像在命令行中那样垃圾邮件优化选项。例如,指定多个-O ...
选项只会具有最后一个的效果。除非您确切地知道自己在做什么并仔细阅读手册,否则请坚持使用-O3
,就可以了。This warning is harmless. It just tells you that GCC is only using a single CPU core to do the link time optimization, which means that it will be slow.
The warning appears due to a change in the
-flto
option which was introduced in GCC 11.4 by this commit. The warning is shown because the-flto
option only uses parallel compilation if explicitly instructed to do so. By default, it simply uses slow serial compilation (unless you have a running job server). Also see this conversation on the GCC mailing list:Use
-flto=auto
to explicitly enable parallel compilation and to get rid of the warning.If you're using GCC on Windows via MinGW or MSYS2, then you'll likely also have to set the
MAKE
environment variable tomingw32-make
and/or pass the-save-temps
option to get rid of all warnings.The exact semantics and effects of the
-flto
is (together with the other optimization options) described in detail in the GCC manual. By the way you should not spam optimization options like you do in your command line. For example specifying multiple-O...
options will only have the effect of the last one of them. Unless you know exactly what you are doing and have carefully read the manual, just stick to use-O3
and you will be fine.