daj daj - 1 year ago 328
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?

Answer Source

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++.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download