简体   繁体   English

为什么将GCC设置为O0时仍会进行优化?

[英]Why GCC still optimized something while set to O0?

While Debugging Redis, I have compiled the code with make noopt , and in Makefile, the optimize is set to O0 . 在调试Redis时,我使用make noopt编译了代码,在Makefile中,优化设置为O0 While debugging, I still got something optimized: 调试时,我仍然进行了一些优化:

GDB屏幕截图

In line 1, we can see all the parameters of aeDeleteFileEvent , but when I step into aeApiDelEvent (line -2), all its parameters are <optimized out> . 在第1行中,我们可以看到aeDeleteFileEvent所有参数,但是当我进入aeApiDelEvent (第2行)时,其所有参数都是<optimized out>

Why these happed? 为什么这些要打架?

Another question, in line 3, I have list all the breakpoints. 在第3行中,另一个问题是我列出了所有断点。 Actually, the 3rd breakpoint is aeApiDelEvent that I have set in debug file( x.gdb ), but why it changed to aeDeleteFileEvent ? 事实上,第三断点aeApiDelEvent我在调试文件(x.gdb)已成立,但为什么它改成aeDeleteFileEvent

OK, thanks @alk(the fact is GCC optimized it) and @markys( V=1 works for me). 好的,谢谢@alk(事实是GCC优化了它)和@markys( V=1对我有用)。

I find a tricky (maybe Bug, because it makes the make noopt has no effect on debugging) in Redis's Makefile, there was a rule that will include a .make-settings , and within the file, one of the option is set O2 optimization. 我在Redis的Makefile中发现了一个棘手的问题(可能是Bug,因为它使make noopt对调试没有影响),其中有一条规则将包含.make-settings ,并且在文件中,选项之一是设置O2优化。

After comment the line in Makefile, no optimization appears in GDB now. 在注释Makefile中的行之后,现在没有优化出现在GDB中。

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

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