🌐
GNU
gcc.gnu.org
GCC, the GNU Compiler Collection - GNU Project
The GNU Compiler Collection includes front ends for C, C++, Objective-C, Objective-C++, Fortran, Ada, Go, D, Modula-2, COBOL, Rust, and Algol 68 as well as libraries for these languages (libstdc++,...). GCC was originally written as the compiler for the GNU operating system.
Installing GCC
The latest version of this document is always available at https://gcc.gnu.org/install/. It refers to the current development sources, instructions for specific released versions are included with the sources.
GCC mirror sites
Include the URL of the gcc.gnu.org mirror area, the country/city where the mirror is located, and a contact e-mail address (and name if appropriate).
GCC Releases
GCC releases may be downloaded from our mirror sites. Important: these are source releases, so will be of little use if you do not already have a C++ compiler installed. As one option, there are pre-compiled binaries.
Downloading GCC
Please refer to the releases web page for information on how to obtain GCC. The source distribution includes the Ada, C, C++, Objective-C, COBOL (GCC 15 and later), D (GCC 9 and later), Fortran, Go, Modula-2 (GCC 13 and later) and Algol 68 (GCC 16 and later, experimental) compilers, as well ...
optimizing compiler produced by the GNU Project, key component of the GNU tool-chain and standard compiler for most projects related to GNU and the Linux kernel.
GCC_10.2_GNU_Compiler_Collection_self-compilation.png
gcc 11 1 0 compiling chicken screenshot
The GNU Compiler Collection (GCC) (formerly GNU C Compiler) is a collection of compilers from the GNU Project that support various programming languages, hardware architectures, and operating systems. The Free Software Foundation … Wikipedia
Factsheet
Original author Richard Stallman
Developer GNU Project
Initial release March 22, 1987; 38 years ago (1987-03-22)
Factsheet
Original author Richard Stallman
Developer GNU Project
Initial release March 22, 1987; 38 years ago (1987-03-22)
🌐
GitHub
github.com › gcc-mirror › gcc
GitHub - gcc-mirror/gcc
The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs.
Starred by 10.7K users
Forked by 4.7K users
Languages   C++ 30.1% | C 29.3% | Ada 14.0% | D 5.9% | Go 5.3% | HTML 3.6%
🌐
Wikipedia
en.wikipedia.org › wiki › GNU_Compiler_Collection
GNU Compiler Collection - Wikipedia
3 weeks ago - These work on multiple representations, ... pattern matching originally based on an algorithm of Jack Davidson and Chris Fraser. GCC was written primarily in C except for parts of the Ada front end....
Top answer
1 of 2
12

The .md (machine description) files of GCC source contain stuff to generate assembly. GCC contains several specialized C/C++ code generators (and some of them translates the .md files into code emitting assembly).

GCC is a very complex program. The documentation of GCC MELT (an obsolete project) contains several interesting links and slides, notably refering to the Indian GCC Resource Center

Most of the optimizations in GCC happens in the middle-end (which is mostly independent of source language or target system), notably with many passes working on the Gimple representations.

The GCC repo is an SVN repository.

See also this answer, notably the pictures inside it.

2 of 2
5

The actual source code for GCC is most accessible from here:

https://gcc.gnu.org/svn.html

The software is accessible via SVN (subversion), a source code control system. This would be installed on many versions of Linux/UNIX, but if not on your platform, you can install the svn kit and then fetch the source using the following command:

svn checkout svn://gcc.gnu.org/svn/gcc/trunk SomeLocalDir

GCC is complex and would take significant experience to understand the nature of how the application actually compiles to different architectures.

In a nutshell, GCC has three major components - front-end, middle and back-end processing. The front-end processor has the component of the language parsing to understand the syntax of languages (like C, C++, Objective-C, etc). The front-end deconstructs the code to a portable construct which is then passed to the back-end for compilation to the target environment.

The middle part performs code analysis and optimisation, attempting to prioritise the code to generate the best possible output at the end of the full process. Technically, optimisation can occur at any part of the process as patterns are discovered during analysis.

The back-end processor compiles the code to a tree-style output format (not actually final executable code). Based on what the expected output is designed to be, the "pseudo-code" is optimised for using registers, bit-sizes, endian-ness, and so on. The final code is then generated during the assembly phase, which converts the back-end code into machine executable instructions.

It's important to note that the compiler has many options to deal with output formats so you can create output to many classes of architecture, usually out of the box. For cross-compiling and target compiler options, try checking out this link:

https://gcc.gnu.org/install/configure.html

🌐
GNU
gcc.gnu.org › install › download.html
Downloading GCC - GNU Project
The source distribution includes the Ada, C, C++, Objective-C, COBOL (GCC 15 and later), D (GCC 9 and later), Fortran, Go, Modula-2 (GCC 13 and later) and Algol 68 (GCC 16 and later, experimental) compilers, as well as runtime libraries for C++, Objective-C, COBOL, Fortran and Algol 68.
🌐
IIT Bombay
cse.iitb.ac.in › ~uday › courses › cs715-09 › gcc-code-view.pdf pdf
GCC Source Code: An Internal View Uday Khedker GCC Resource Center,
The Architecture of GCC · Language · Specific · Code · Language and · Machine · Independent · Generic Code · Machine · Dependent · Generator · Code · Machine · Descriptions · Compiler Generation Framework · Parser · Gimplifier · Tree SSA · Optimizer · RTL · Generator · Optimizer · Code · Generator · Generated Compiler (cc1) Source Program ·
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_enterprise_linux › 7 › html › developer_guide › gcc-compiling-code
Chapter 15. Building Code with GCC | Developer Guide | Red Hat Enterprise Linux | 7 | Red Hat Documentation
Source code written in the C or C++ language, present as plain text files. The files typically use extensions such as .c, .cc, .cpp, .h, .hpp, .i, .inc. For a complete list of supported extensions and their interpretation, see the gcc manual pages:
Find elsewhere
🌐
Quora
quora.com › How-can-I-view-the-source-code-for-a-C-compiler
How to view the source code for a C compiler - Quora
Answer (1 of 6): What about to try some open source one. Do not start with the big ones like gcc.gnu.org Git - gcc.git/summary or llvm/llvm-project. These are too big to comprehend on first try. You may try something more easy like IanHarvey/pcc or davidgiven/ack.
🌐
Opensource.com
opensource.com › article › 22 › 5 › gnu-c-compiler
A programmer's guide to GNU C Compiler | Opensource.com
There are actually four steps to compiling, even though GCC performs them automatically in simple use-cases. Pre-Processing: The GNU C Preprocessor (cpp) parses the headers (#include statements), expands macros (#define statements), and generates an intermediate file such as hellogcc.i with expanded source code.
🌐
Wikibooks
en.wikibooks.org › wiki › GNU_C_Compiler_Internals
GNU C Compiler Internals - Wikibooks, open books for an open world
Additional branches were created later on. As of now, the active development branches are GCC 3.4 with a latest release on November 30, 2005, and GCC 4.0 released last time on September 28, 2005. GCC 4.1 was released on Feb 28 2006. GCC 4.2 is the development branch of GCC. The source code repository is available online.
🌐
GNU
ftp.gnu.org › gnu › gcc
Index of /gnu/gcc
Index of /gnu/gcc · Apache/2.4.52 (Trisquel_GNU/Linux) Server at ftp.gnu.org Port 443
🌐
Pepas
leopard-adc.pepas.com › documentation › DeveloperTools › gcc-4.2.1 › gcc › Source-Code.html
Source Code - Using the GNU Compiler Collection (GCC)
The source code for released versions of Apple's GCC is available at `http://www.opensource.apple.com/darwinsource/', in `.tar.gz' format. For unreleased versions (including 'seeds', beta versions and engineering roots), source can be obtained by asking the Apple contact from which you obtained ...
🌐
Texas Instruments
ti.com › tool › MSP430-GCC-OPENSOURCE
MSP430-GCC-OPENSOURCE IDE, configuration, compiler or debugger | TI.com
MSP430™ GCC open source package is a complete debugger and open source C/C++ compiler toolchain for building and debugging embedded applications based on MSP430 microcontrollers. This compiler supports all MSP430 devices without code size limitations. This compiler can be used standalone ...
🌐
GitHub
github.com › gcc-mirror › gcc › blob › master › README
gcc/README at master · gcc-mirror/gcc
This directory contains the GNU Compiler Collection (GCC).
Author   gcc-mirror
🌐
Free Software Directory
directory.fsf.org › wiki › Gcc
Gcc - Free Software Directory
It provides compiler front-ends for several languages, including C, C++, Objective-C, Fortran, Ada, and Go. It also includes runtime support libraries for these languages. GCC provides many levels of source code error checking traditionally provided by other tools (such as lint), produces debugging ...
🌐
Wikibooks
en.wikibooks.org › wiki › GNU_C_Compiler_Internals › GNU_C_Compiler_Architecture
GNU C Compiler Internals/GNU C Compiler Architecture - Wikibooks, open books for an open world
It is a driver program that invokes the appropriate compilation programs depending on the language of the source file. For a C source file they are the preprocessor and compiler cc1, the assembler as, and the linker collect2. The first and the third programs come with a GCC distribution, the ...