Compilation Phases

Most modern compilers do not create an executable from high level source code in single go, but the overall compilation is performed in different phases. A typical compilation of a program from High level language program to final executable comprises of the following phases:

    • Preprocessing
    • Compilation
    • Assembly
    • Linking

There are individual commands for each of the stages which are used by gcc. However, gcc makes the transition from one phase to another completely transparent to the programmer. However, to understand the different we can use these commands.

Although gcc hides all the intermediate phases from the programmer but gcc can be requested to save the intermediate files for debugging purposes by using the -save-temps option.gcc would save the intermediate files with the following extension

Pre-processed file

Assembly file

Object file

filename.i

filename.s

filename.o