LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Does ccache take care of the optimization applied to the compiled code? (http://www.linuxquestions.org/questions/linux-software-2/does-ccache-take-care-of-the-optimization-applied-to-the-compiled-code-867251/)

dhruv17singhal 03-08-2011 01:04 PM

Does ccache take care of the optimization applied to the compiled code?
 
Hi,

I have recently began compiling custom-kernels and have come across ccache and distcc, two excellent tool to speed up the compilation. I was wondering whether ccache takes care that I had specified (or unspecified) optimizations like -Os, -O1, -O2, etc.? In other words, if I first apply, say, -O2 optimization and allow ccache to cache the optimized object file, and later if I compile the same code using, say, -Os, will ccache use the previously cached data, and thus ignore my new settings?

Ideally, ccache should allow the code to be completely recompiled with the new optimization settings, and then cache the new files, along with the previous ones, so that if I ever want to compile the code using either -Os or -O2 optimization, I would not have to wait for the complete code to be compiled again. Is that the case?

ForzaItalia2006 03-08-2011 06:13 PM

Quote:

Originally Posted by dhruv17singhal (Post 4283041)
I have recently began compiling custom-kernels and have come across ccache and distcc, two excellent tool to speed up the compilation. I was wondering whether ccache takes care that I had specified (or unspecified) optimizations like -Os, -O1, -O2, etc.? In other words, if I first apply, say, -O2 optimization and allow ccache to cache the optimized object file, and later if I compile the same code using, say, -Os, will ccache use the previously cached data, and thus ignore my new settings?

First of all, here is a reference to a description of how ccache works. That should answer most of your future upcoming questions ;-)

To answer your specific question: ccache does not try to be more clever than you are. If you specify new options (e.g. -Os), ccache will not be able to find any cached results in its cache (because you only cached -O2) so that ccache will recompile your code.

Quote:

Originally Posted by dhruv17singhal (Post 4283041)
Ideally, ccache should allow the code to be completely recompiled with the new optimization settings, and then cache the new files, along with the previous ones, so that if I ever want to compile the code using either -Os or -O2 optimization, I would not have to wait for the complete code to be compiled again. Is that the case?

Yes, think so. Unless you clear the cache, you'll keep all the previous results.

Best regards,
Andi

dhruv17singhal 03-09-2011 01:26 AM

Thanks ForzaItalia2006, that's exactly what I wanted !


All times are GMT -5. The time now is 07:02 AM.