GCC (GNU Compiler Collection)…
Installing GCC on Linux
…
Compiling a C Program with GCC
…
Important GCC Compiler Flags
…
Link Time Optimization (LTO)
GCC supports Link Time Optimization (LTO) which performs whole program analysis and optimization at link time by combining previously compiled object files. This allows GCC to conduct interprocedural optimization and analyze the program as a whole.
To enable LTO, use the -flto flag:
gcc -o app -O2 -flto app.c
The LTO process comprises of two stages – optimization at compile time, and link time:

Figure 1 – GCC LTO stages. Image credit: Flicker presentation by IBM Research Zurich.
Benchmarking LTO optimization shows significant performance gains:
| Benchmark | Base GCC | With LTO |
|---|---|---|
| bzip2 compression | 5.7 sec | 4.2 sec |
| Himeno benchmark | 5.9 sec | 5.1 sec |
| LAME mp3 encoding | 16 sec | 14 sec |
Table 1 – Sample LTO benchmark data from Phoronix.
As seen above, LTO can provide over 25% speedup versus base GCC in certain applications by enabling optimizations across source code file boundaries.
Let‘s look at some more advanced compilation features in GCC…
Graphite Loop Optimizations
GCC uses the Graphite loop optimization framework to apply high-level loop transformations…
Debugging with GDB
…
Linux Distribution Specific Notes
Fedora
The stock GCC version installed on latest Fedora 37 editions is GCC 11.2.1. However, alternative compiler versions can be installed from official Fedora repositories:
dnf install gcc-12 gcc-11 gcc-10
This allows easy switching between multiple GCC versions.
OpenSUSE
On OpenSUSE, the default C/C++ development package group is named c-c++-devel:
zypper install c-c++-devel
The Leap distro ships with GCC 7 while Tumbleweed rolls with latest GCC 12.
Gentoo
Gentoo features extreme GCC customization via USE flags which selectively enable/disable GCC capabilities…
Analysis of GCC Performance
Compilation performance is critical for large C/C++ codebases, so GCC optimization for faster compile times is important.
Compiler Performance Comparison on OpenBenchmarking.org

Figure 2 – Relative compilation performance of various compilers Source
As seen above, GCC 12 ranks high on compilation speed based on extensive benchmarking data indexed by Phoronix Test Suite on OpenBenchmarking.org.
Let‘s look at GCC standards conformance next…
Leveraging GCC in CI Systems
GCC can be integrated into Continuous Integration pipelines to build and validate C/C++ code changes on every commit…
History of GCC
GCC was originally written as the compiler for the GNU operating system by Richard Stallman…
Over 100+ contributors have added various functionality and components like frontends, optimization passes etc. Some notable contributors include…
In this comprehensive guide, you learned:
- GCC compilation setup on Linux distros
- Building C programs with GCC
- Advanced functionality for performance and debugging
- Integration in CI/CD workflows
- Performance benchmarking and standards support
- Contributions and evolution of GCC over 30+ years
With its high-performance instrumentation and abundant community support, GCC forms the toolchain of choice for C/C++ development on Linux platforms.


