Structure
GCC's external interface is generally standard for a UNIX compiler. Users invoke a driver program named gcc
, which interprets command arguments, decides which language compilers to use for each input file, runs the assembler on their output, and then possibly runs the linker to produce a complete executable binary.
Each of the language compilers is a separate program that inputs source code and outputs machine code. All have a common internal structure. A per-language front end parses the source code in that language and produces an abstract syntax tree ("tree" for short).
These are, if necessary, converted to the middle-end's input representation, called GENERIC form; the middle-end then gradually transforms the program towards its final form. Compiler optimizations and static code analysis techniques (such as FORTIFY_SOURCE, a compiler directive that attempts to discover some buffer overflows) are applied to the code. These work on multiple representations, mostly the architecture-independent GIMPLE representation and the architecture-dependent RTL representation. Finally, machine code is produced using architecture-specific pattern matching originally based on an algorithm of Jack Davidson and Chris Fraser.
GCC is written primarily in C except for parts of the Ada front end. The distribution includes the standard libraries for Ada, C++, and Java whose code is mostly written in those languages. On some platforms, the distribution also includes a low-level runtime library, libgcc, written in a combination of machine-independent C and processor-specific machine code, designed primarily to handle arithmetic operations that the target processor cannot perform directly.
In May 2010, the GCC steering committee decided to allow use of a C++ compiler to compile GCC. The compiler will be written in C plus a subset of features from C++. In particular, this was decided so that GCC's developers could use the "destructors" and "generics" features of C++.
In August 2012, the GCC steering committee announced that GCC now uses C++ as its implementation language. This means that to build GCC from sources, a C++ compiler is required that understands C++ 2003. For more details on the rationale and specific changes, please refer to the C++ conversion page.
Read more about this topic: GNU Compiler Collection
Famous quotes containing the word structure:
“Im a Sunday School teacher, and Ive always known that the structure of law is founded on the Christian ethic that you shall love the Lord your God and your neighbor as yourselfa very high and perfect standard. We all know the fallibility of man, and the contentions in society, as described by Reinhold Niebuhr and many others, dont permit us to achieve perfection.”
—Jimmy Carter (James Earl Carter, Jr.)
“Just as a new scientific discovery manifests something that was already latent in the order of nature, and at the same time is logically related to the total structure of the existing science, so the new poem manifests something that was already latent in the order of words.”
—Northrop Frye (b. 1912)
“Who says that fictions only and false hair
Become a verse? Is there in truth no beauty?
Is all good structure in a winding stair?
May no lines pass, except they do their duty
Not to a true, but painted chair?”
—George Herbert (15931633)