隐形GCC优化标志? [英] Invisible GCC optimization flags?

查看:161
本文介绍了隐形GCC优化标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是一些建设大型项目的 GCC 4.4.2 。因为我想建立它的释放,我用 -O1 GCC优化标志,但偏偏它与我的code莫名其妙地打乱,最终的二进制文件不作为工作预计,随着 -O0 建筑时,标志(或没有优化)一切工作正常。
我以前曾与我的项目类似的问题,在那个时候它是 -fstrict走样引起的烦恼标志 -O2 优化级别,我设法找到通过使那些本文档中提及的所有标志进行搜索,关于 -O2 的优化,它是由特定的标志引起级别:

I'm building some large project using GCC 4.4.2. Since I want to build it for release, I use -O1 GCC optimization flag, but unluckily it messes somehow with my code, and the final binaries do not work as expected, when building with -O0 flag (or no optimization) everything works fine. I had a similar problem with my project before, in that time it was the -fstrict-aliasing flag that caused troubles on -O2 optimization level, I managed to find that it was caused by that specific flag by making a search on all flags that are mentioned in this documentation, regarding the -O2 optimization level:

http://gcc.gnu.org/ onlinedocs / GCC-4.4.2 / GCC /优化,Options.html

现在我试着做他们提到关于 -O1 标记列表相同,但不幸的是它似乎并不是所有的标志所提到的,或者有一些隐藏被启用的标志,因为当我编译只用 -O1 标记或只是一个没有把所提供的标志(名单 -O1 本身)我得到不同的编译结果,我的二进制文件拒绝只与特定的 -O1 标志工作,所以我无法找到确切惹是生非的选项。

Now I tried to do the same with the list they mention regarding the -O1 flag, but unfortunately it seems that not all the flags mentioned, or there are some hidden flags being enabled, because when I compile with just -O1 flag or with just a list of the provided flags (without putting -O1 itself) I get different compilation results, and my binaries refuse to work only with the specific -O1 flag, so I can't find the exact troublemaking option.

是否有可能知道什么隐藏的选项 -O1 选项包括,我怎么可以禁用其中的一些?

Is it possible to know what hidden options the -O1 option includes, and how can I disable some of them?

推荐答案

您可以在一个小的C文件运行 GCC -Q -v 有GCC转储的选项是用过的。
使用和不使用 -O1 选项来运行它得到启用的选项之间的区别。

You can run gcc -Q -v on a small C file to have GCC dump the options being used. Run it with and without the -O1 option to get the difference between the enabled options.

这篇关于隐形GCC优化标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆