I tend to write rather large templated header-only C++ libraries and my users commonly complain about compilation times. After thinking about the matter, it occurred to me that I have no idea where the time is going. Is there some simple way to profile the C++ compilation process with common compilers, such as g++, icc, and xlC? For instance, is it possible to get an idea of how much time is spent within each of the phases of C++ compilation?
Compilation process in C is also known as the process of converting Human Understandable Code (C Program) into a Machine Understandable Code (Binary Code)) Compilation process in C involves four steps: pre-processing, compiling, assembling, and linking.
There are three basic steps involved in compiling a C program: preprocessing, compilation of C source code to machine code (or assembly) (also called object code), and linking of multiple object files into a single binary executable program.
The compilation process can be divided into four steps, i.e., Pre-processing, Compiling, Assembling, and Linking. The preprocessor takes the source code as an input, and it removes all the comments from the source code. The preprocessor takes the preprocessor directive and interprets it.
For GCC there are debugging options to find how much time is spent within each of the phases of C++ compilation?
-Q Makes the compiler print out each function name as it is compiled, and print some statistics about each pass when it finishes.
-ftime-report Makes the compiler print some statistics about the time consumed by each pass when it finishes.
Passes are described in GCCINT 9: Passes and Files of the Compiler.
You can post output of g++ compilation of single source file with -v -ftime-report
here to discuss it. There could be some help on the GCC mailing list.
For compilers other than GCC (or GCC more ancient than 3.3.6) see the other options in this thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With