What is cc really doing - the condensed version
We understand how cc works in its simplest form:
- we invoke cc on a single C source file,
- we know the C-processor is invoked to include system-wide header files,
and to define our own preprocessor and definitions macros,
- the output of the preprocessor becomes the input of the "true"
compiler,
- the output of the compiler (for correct programs!)
is an executable program
(and we may use the -o option to provide a specific executable name).
What is cc really doing - the long version
Not surprisingly, there's much more going on!
cc is really a front-end program to a number of passes
or phases of the whole activity of "converting" our C source files
to executable programs:
- foreach C source file we're compiling:
- the C source code is given to the C preprocessor,
- the C preprocessor's output is given to the C parser,
- the parser's output is given to a code generator,
- the code generator's output is given to a code optimizer,
- the code optimizer's output, termed object code,
is written to a disk file termed an object file,
- all necessary object files (there may be more than one,
and some may be standard C libraries,
operating system-specific,
or provided by a third-party),
are presented to a program named the linker,
to be "combined" together, and
- the linker's output is written to disk as an executable file.
CITS4407 Open Source Tools and Scripting, Week 9, p2.
|