Hello,
I'm using keil 3.4, optimization O3, cross module optimization.
I deleted all the objects files, listings... before compiling.
The first time I build the project, the code size is more than 11KB.
The second time ~7.7 KB.
The third time ~7.5
After that, it didn't change anymore.
No change was made between those builds. I just clicked the build button 3 times and it gave me 3 different code size.
I suppose it related to the using of cross-module optimization; but it's really strange.
Any clue?
Thanks,
The third time, the object files already contained hints from the second time, so why shouldn't the compiler be able to pick up one more little trick to improve the optimization?
Ok, from all the symptom, maybe it is how the compiler really does.
I just need to remember to rebuild every project at least 3 times to get the "best" optimization.
Thank you.
That would of course depend on your need for optimum optimization. In most situations, it is enough to just get "good enough" optimization. Fast enough to solve the problem in required time frame, and small enough that it fits in the chip and doesn't result in too large transfer costs if doing over-the-air updates.
A more important issue is that you have a policy how to build your project, so that you can - at a later time - rebuild the project and reproduce the same binary (with possible exception of build time stamp).