daj daj - 3 months ago 65
C++ Question

gcc -O0 vs. -Og compilation time

The release notes for gcc were a little vague on -Og:

It addresses the need for fast compilation and a superior debugging experience while providing a reasonable level of runtime performance. Overall experience for development should be better than the default optimization level -O0.

Does "Overall experience for development" include compilation time? If I don't need debug symbols and am optimizing for compile time, should I be using -O0 or -Og?


With -Og the compiler has to construct and write out extra data (for debugging), so it will take longer. Just compile to assembler (with gcc -S -Og, etc) and compare. But whatever difference there is between -O0 and -Og runtime is probably dwarfed by the time to start gcc and its complete machinery.

If you want compile time, perhaps you should consider tcc for C. Perhaps LLVM is faster for C++.