简体   繁体   中英

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? 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.

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. 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. 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 - If the problem is inaccurate documentation, you can help the GCC folks and ultimately other GCC users by submitting a bug report with corrections.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM