简体   繁体   English

为什么gcc -O1的行为与gcc -O0 +选项不同

[英]Why does gcc -O1 behave differently than gcc -O0 + options

Given that the gcc documentation ( https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gcc.pdf ) specifies that -O1 is -O0 plus a specific list of options, why is it when I time compiling my code with -O1 it takes 2 times longer to compile than using -O0 + all the options listed as being enabled when -O1 is turned on? 鉴于gcc文档( https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gcc.pdf )指定-O1为-O0加上特定的选项列表,为什么当我编译我的代码时-O1编写的代码比使用-O0 +打开-O1时列出的所有选项要编译的时间长2倍? Are there other options that are being enabled that are not specified in the documentation (my suspicion), or is there something else, more sinister, happening in the background? 是否有其他未在文档中指定的选项正在启用(我怀疑),还是在后台发生了其他更险恶的事情?

If the documentation is just out of date, that would be something I'd be interested in knowing about, if only to better understand the optimization options available for GCC and my code. 如果文档只是过时的话,那只是为了更好地了解可用于GCC和我的代码的优化选项,我将对此感兴趣。

If the documentation is just out of date ... 如果文档刚刚过时...

It is a fair assumption that the documentation is inaccurate. 可以合理地认为文档不正确。 Stuff like that happens. 这样的事情发生了。

Another possibility is that you have misread the documentation. 另一种可能是您误读了文档。 My reading of the document you linked to (page 111) is that -O and -O1 are supposed to mean the same thing. 我对链接到的文档(第111页)的理解是, -O-O1应该是同一意思。 If that is correct, then what you are apparently trying to do doesn't make much sense. 如果那是正确的,那么您显然想做的事情就没有多大意义了。

I suggest that you look at the GCC source code to figure out exactly how -O1 is implemented. 我建议您查看GCC源代码以准确了解如何实现-O1 That should tell you whether the behavior you are seeing can be explained by inaccurate documentation 1 , or whether there is something else going on here. 那应该告诉您是否可以通过不正确的文档1来解释您所看到的行为,或者这里是否还有其他情况。


1 - If the problem is inaccurate documentation, you can help the GCC folks and ultimately other GCC users by submitting a bug report with corrections. 1-如果问题出在文档不正确,则可以通过提交带有更正的错误报告来帮助GCC人员,甚至最终帮助其他GCC用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 GCC 删除了我在 O3 上的代码,而不是在 O0 上? - Why does GCC delete my code on O3 but not on O0? 为什么gcc链接程序对.a文件和.o文件的行为有所不同? - Why does the gcc linker behave differently with .a files and .o files? 是g ++ buggy?和clang ++呢?带有-O0和-O1选项的g ++编译代码表现不同,对于具有-O0和-O2的clang ++也是如此 - is g++ buggy ? and clang++ too ? g++ compiled code with -O0 and -O1 options behaves differently the same is true for clang++ with -O0 and -O2 为什么不能-O0禁用gcc编译优化? - Why can't -O0 disable gcc compile optimization? 是否是 gcc -O2 优化错误(与 -O1 的结果不同)? - Is it a gcc -O2 optimization bug (different result from -O1)? 为什么gcc的相同编译选项在不同的计算机体系结构上表现不同? - Why will the same compile options of gcc behave differently on different computer architecture? 具有不匹配的优化级别(-O3、-O2、-O1、-O0)的二进制文件是否会导致稳定性问题? - Does having binaries with mismatched optimization levels (-O3, -O2, -O1, -O0) cause stability issues? -O0、-O1 和 -g 之间有什么区别 - What is the difference between -O0 ,-O1 and -g gcc -O0与-Og编译时间 - gcc -O0 vs. -Og compilation time 当选项为-std = C ++ 0x -O0时,GCC 4.4无法链接有效的C ++ 11代码 - GCC 4.4 fails to link valid C++11 code, when options are -std=C++0x -O0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM