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,
That behaviour has been noticed before. Most probably, the compiler needs the feedback from all other object files when compiling a new source file.
Thanks for a quick reply.
You imply that in the first build, the compiler didn't have all information from all object files, so in the second build, it has enough information to reduce the code size, right?
But how about the third build? It still reduced a code size a little from the second one.
And another question for ARM/Keil guys (if they have a chance to see this thread), is it easier and less confusing to automatically rebuild the project after having all needed object files?
Regards,
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).
We notice that symptom before and we resolve it by cleaning up all included files (global include versus local include).
Look in your dependencies tree in uVision (to enable it: uVision - View - Include File Dependencies). Browse in your project workspace and look for header file that are reported twice for the same c source file.
We use boot loaders and upgrade tools, so we need (and expect) to have the same hex file, no madder how many time you build your project.
Maybe it was not the same problem then you, I hope this help.
Francois.