Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trace gcc compilation and what code slows it down

Tags:

c++

linux

gcc

I want to find out what code causes slow compilation times in gcc. I previously had a code being compiled slowly and someone told me the command-line switch that makes gcc to print each step that it compiles, including each function/variable/symbol and so on. That helped a lot (I could literally see in console where gcc chokes), but I forgot what was the switch.

like image 471
queen3 Avatar asked Dec 14 '12 13:12

queen3


People also ask

What is O3 in GCC?

Optimization level -O3 -O3 instructs the compiler to optimize for the performance of generated code and disregard the size of the generated code, which might result in an increased code size. It also degrades the debug experience compared to -O2 .

Why should code optimization be controlled by a compile time flag?

Turning on optimization flags makes the compiler attempt to improve the performance and/or code size at the expense of compilation time and possibly the ability to debug the program. The compiler performs optimization based on the knowledge it has of the program.

Is GCC slow?

GCC is slower to compile than clang, so I spend a lot of time compiling, but my final system is (usually) faster with GCC, so I have set GCC as my system compiler.

What is optimization level in GCC?

GCC has a range of optimization levels, plus individual options to enable or disable particular optimizations. The overall compiler optimization level is controlled by the command line option -On, where n is the required optimization level, as follows: -O0 . (default). No optimization is performed.


1 Answers

I found it (from the gcc man page):

-Q

Makes the compiler print out each function name as it is compiled, and print some statistics about each pass when it finishes.

like image 198
queen3 Avatar answered Sep 20 '22 09:09

queen3