Issue
I know this is a very basic question but when I compile my c/c++ code with gcc/g++ what exactly is the type of the intermediate output before assembler comes into play to generate the machine code ? Is it something like X86 instructions ?
Solution
GCC's processing chain is as follows:
your source code
preprocessed source code (expand macros and includes, strip comments) (
-E
,.ii
)compile to assembly (
-S
,.s
)assemble to binary (
-c
,.o
)link to executable
At each stage I've listed the relevant compiler flags that make the process stop there, as well as the corresponding file suffix.
If you compile with -flto
, then object files will be embellished with GIMPLE bytecode, which is a type of low-level intermediate format, the purpose of which is to delay the actual final compilation to the linking stage, which allows for link-time optimizations.
The "compiling" stage proper is the actual heavy lifting part. The preprocessor is essentially a separate, independent tool (although its behaviour is mandated by the C and C++ standards), and the assembler and linker are acutally separate, free-standing tools that basically just implement, respectively, the hardware's binary instruction format and the operating system's loadable executable format.
Answered By - Kerrek SB Answer Checked By - Senaida (WPSolving Volunteer)