简体   繁体   English

gcc /优化标记gcc / C的持久性更改

[英]Changes in gcc/persistence of optimization flags gcc/C

Just curious. 只是好奇。 Using gcc/gdb under Ubuntu 9.10. 在Ubuntu 9.10下使用gcc / gdb。

Reading a C book that also often gives the disassembly of the object file. 读一本C书也常常会反汇编目标文件。 When reading in January, my disassembly looks a lot like the book's; 一月份阅读时,我的拆卸看起来很像这本书。 now, it's quite different - possibly more optimized (I notice some re-arrangements in the assembly code now that, at least in the files I checked, look optimized). 现在,它已经完全不同了-可能已经进行了优化(我注意到汇编代码中的一些重新安排,至少在我检查的文件中,看起来是优化的)。 I have used optimization options -O1 - -O3 for gcc between the first and second read, but not before the first. 我在第一次和第二次读取之间使用了优化选项-O1--O3作为gcc,但没有在第一次读取之前。

(1) Is the use of optimization options persistent, aka, if you use them once, you'll use them until switching them off? (1)优化选项的使用是否持久化(如果您一次使用它们,直到关闭它们之前都将使用它们)? That would be weird (browsed man file and at least did not see anything to that sort). 那会很奇怪(浏览过的man文件,至少看不到那种东西)。 In the unlikely case that it is true, how do you switch them off? 在不太可能的情况下,您该如何关闭它们?

(2) Has gcc's assembly changed through any recent upgrade? (2)gcc的程序集是否通过最近的升级进行了更改?

(3) Does gcc sometimes produce (significantly) different assembly code although same compile options are chosen? (3)尽管选择了相同的编译选项,gcc有时还是会产生(大量)不同的汇编代码吗?

Thanks much. 非常感谢。

1) No, the options don't persist. 1)不,选项不会持续存在。

2) Yes, the optimisers are constantly being changed and improved. 2)是的,优化器一直在不断变化和改进。 If your gcc packages have been upgraded, then it is quite likely that the assembly generated for a particular source file will change. 如果您的gcc软件包已升级,则为特定源文件生成的程序集很可能会更改。

3) Compiling with gcc is a deterministic process; 3)使用gcc进行编译是确定性的过程; if you compile the same source with the same version of gcc and the same options for the same target, then the assembly produced should be the same (modulo some symbol names). 如果使用相同版本的gcc和相同的目标使用相同的选项编译相同的源,则生成的程序集应该相同(以一些符号名称为模)。

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

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