The GNU Toolchain

Stages of toolchain

A toolchain is a suite of tools used in a serial manner to develop software applications and operating systems. The GNU toolchain is a broad collection of programming tools produced by the GNU Project.

The GNU toolchain plays a vital role in development of Linux, some BSD systems, and more importantly software for embedded systems. Before we delve into the components of GNU toolchain, let’s understand the general aspects of a toolchain.

A toolchain is a set of distinct software development tools that are linked (or chained) together by specific stages such as GCC, binutils and glibc (a portion of the GNU Toolchain). Optionally, a toolchain may contain other tools such as a Debugger or a Compiler for a specific programming language, such as ,C++. Quite often, the toolchain used for embedded development is a cross toolchain, or more commonly known as a cross compiler. All the programs (like GCC) run on a host system of a specific architecture (such as x86) but produce binary code (executables) to run on a different architecture (e.g. ARM). This is called cross compilation and and is the typical way of building embedded software.

When talking about toolchains, we must distinguish three different machines :

  • The build machine, on which the toolchain is built
  • The host machine, on which the toolchain is executed
  • The target machine, for which the toolchain generates code

From these three different machines, we distinguish four different types of toolchain building processes :

  • A native toolchain, as can be found in normal Linux distributions, has usually been compiled on x86, runs on x86 and generates code for x86.
  • A cross-compilation toolchain, which is the most interesting toolchain type for embedded development, is typically compiled on x86, runs on x86 and generates code for the target architecture (be it ARM, MIPS, PowerPC or any other architecture supported by the different toolchain components)
  • A cross-native toolchain, is a toolchain that has been built on x86, but runs on your target architecture and generates code for your target architecture. It’s typically needed when you want a native gcc on your target platform, without building it on your target platform.
  • A canadian build is the process of building a toolchain on machine A, so that it runs on machine B and generates code for machine C. It’s usually not really necessary.

The projects included in the GNU toolchain are,


GNU Compiler Collection (GCC)

The GNU Compiler Collection (GCC) is a compiler system supporting various programming languages. Originally named the GNU C Compiler, when it only handled the C programming language, GCC 1.0 was released in 1987. It was extended to compile C++ in December of that year. Front ends were later developed for Objective-C, Objective-C++, Fortran, Java, Ada, and Go among others.

As well as being the official compiler of the GNU operating system, GCC has been adopted as the standard compiler by many other modern Unix-like computer operating systems, including the BSD family, although FreeBSD and OS X have moved to the LLVM system. Versions are also available for Windows and other operating systems; GCC can compile code for Android and iOS.

GCC has been ported to a wide variety of processor architectures, and is widely deployed as a tool in the development of both free and proprietary software. GCC is also available for most embedded platforms, including Symbian (called gcce), AMCC, and Freescale Power Architecture-based chips. The compiler can target a wide variety of platforms, including video game consoles such as the PlayStation 2 and Dreamcast.

GNU Binutils

As a matter of fact,  The GNU Binutils are the first component of a toolchain. The GNU Binutils contains two very important tools :

  • as, the assembler, that turns assembly code (generated by gcc) to binary
  • ld, the linker, that links several object code into a library, or an executable

Binutils also contains a couple of other binary file manipulation or analysis tools, such as objcopy, objdump, nm, readelf, strip, and so on. The Binutils website has some documentation on all these tools.

GNU Build System

The GNU Build System, also known as the Autotools, is a suite of programming tools designed to assist in making source code packages portable to many Unix-like systems.

It can be difficult to make a software program portable: the C compiler differs from system to system; certain library functions are missing on some systems; header files may have different names. One way to handle this is to write conditional code, with code blocks selected by means of preprocessor directives (#ifdef); but because of the wide variety of build environments this approach quickly becomes unmanageable. Autotools is designed to address this problem more manageably.

Autotools is part of the GNU toolchain and is widely used in many free software and open source packages.

The GNU Build System makes it possible to build many programs using a two-step process:

  1. configureA shell script that goes and detects what is available in the environment and/or what is desired by the user to determine how to build the software.
  2. makeUses timestamps to rebuild modules.

Autotools consists of the GNU utility programs Autoconf, Automake, and Libtool. Other related tools frequently used alongside it include GNU’s make program, GNU gettext, pkg-config, and the GCC.

GNU Make

Make is a build automation tool that automatically builds executable programs and libraries from source code by reading files called Makefiles which specify how to derive the target program. Though integrated development environments and language-specific compiler features can also be used to manage a build process, Make remains widely used, especially in Unix.

Besides building programs, Make can be used to manage any project where some files must be updated automatically from others whenever the others change.

GNU Debugger

The GNU Debugger, usually called just GDB and named gdb as an executable file, is the standard debugger for the GNU operating system. However, its use is not strictly limited to the GNU operating system; it is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, C,C++, Objective-C, Free Pascal, Fortran, Java and partially others.


GNU m4 is an implementation of the m4 macro preprocessor. Developed by the GNU Project, GNU m4 is designed to avoid many kinds of arbitrary limits found in traditional m4 implementations, such as maximum line lengths, maximum size of a macro and number of macros. Removing such arbitrary limits is one of the stated goals of the GNU Project.

The GNU Autoconf package makes extensive use of the features of GNU m4.

GNU Bison

GNU bison, commonly known as Bison, is a parser generator that is part of the GNU Project. Bison reads a specification of a context-free language, warns about any parsing ambiguities, and generates a parser (either in C, C++, or Java) which reads sequences of tokens and decides whether the sequence conforms to the syntax specified by the grammar. Bison by default generates LALR parsers but can also create GLR parsers.

In POSIX mode, Bison is compatible with yacc, but also has several improvements over this earlier program. flex, an automatic lexical analyser, is often used with Bison, to tokenise input data and provide Bison with tokens.

About Deepak Devanand

Seeker of knowledge
This entry was posted in C, gcc, Linux and tagged , , , . Bookmark the permalink.

3 Responses to The GNU Toolchain

  1. Pingback: Installing GNU Toolchain on Debian/Ubuntu/Kali Linux | Deepak's Kaleidoscope

  2. Pingback: Installing GNU Toolchain on RHEL/CentOS/Fedora | Deepak's Kaleidoscope

  3. Pingback: Journey of a C Program | Deepak's Kaleidoscope

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s