开发者

Changes in gcc/persistence of optimization flags gcc/C

开发者 https://www.devze.com 2022-12-29 05:07 出处:网络
Just curious. Using gcc/gdb under Ubuntu 9.10. Reading a C book that also often gives the disassembly of the object file. When reading in January, my disassembly looks a lot like the book\'s; now, it

Just curious. Using gcc/gdb under Ubuntu 9.10.

Reading a C book that also often gives the disassembly of the object file. When reading in January, my disassembly looks a lot like the book's; now, it's quite different - poss开发者_JAVA百科ibly 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.

(1) Is the use of optimization options persistent, aka, if you use them once, you'll use them until switching them off? That would be weird (browsed man file and at least did not see anything to that sort). In the unlikely case that it is true, how do you switch them off?

(2) Has gcc's assembly changed through any recent upgrade?

(3) Does gcc sometimes produce (significantly) different assembly code although same compile options are chosen?

Thanks much.


1) No, the options don't persist.

2) Yes, the optimisers are constantly being changed and improved. If your gcc packages have been upgraded, then it is quite likely that the assembly generated for a particular source file will change.

3) Compiling with gcc is a deterministic process; 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号