GCC v12.1关于串行汇编的警告

发布于 2025-01-28 05:34:59 字数 1873 浏览 4 评论 0 原文

我已经升级了整个 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) 

I have upgraded my whole arch linux system today (12th May, 2022). gcc was also upgraded from v11.2 to v12.1. I tried compiling some of my programs with g++ (part of gcc compiler collection) by the following command:

g++ -O3 -DNDEBUG -Os -Ofast -Og -s -march=native -flto -funroll-all-loops -std=c++20 main.cc -o ./main

The program compiled perfectly and ran as excepted without any errors, but I got a warning:

lto-wrapper: warning: using serial compilation of 2 LTRANS jobs

But, when the same program was compiled using v11.2 it produces zero number of errors and warnings.

My Questions:

  • What is the meaning of this warning?
  • How can I fix this?
  • Is this warning occurred due to upgrading gcc version to v12.1

Here's the g++ configuration on my machine:

$ 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悸初 2025-02-04 05:34:59

此警告是无害的。它只是告诉您,GCC仅使用单个CPU核心来进行链路时间优化,这意味着它会很慢。

警告出现是由于 -flto 选项的更改而出现的,该选项是在GCC 11.4 中引入的此提交。显示警告是因为 -flto 选项仅如果明确指示执行此操作,则仅使用并行汇编。默认情况下,它只是使用慢速串行汇编(除非您拥有运行的作业服务器)。另请参见此对话在GCC邮件列表中:

同样,如果人们只使用-flto和自动检测[工作服务器]
什么都没找到:

警告:使用n ltrans Jobs的串行汇编
注意:请参阅http:// ....有关如何使用并行编译

[...]

也就是说,教用户而不是第二次猜测,最终
炸毁东西。

使用 -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:

Likewise if people just use -flto and auto-detection [of job server]
finds nothing:

warning: using serial compilation of N LTRANS jobs
note: refer to http://.... for how to use parallel compile

[...]

That is, teach users rather than second-guessing and eventually
blowing things up.

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 to mingw32-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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文