ARM GCC: The ARM compiler for embedded developers

Posted by Magnus Unemyr on Sep 22, 2016 11:07:48 AM

In the past decade, there has been an unmistakable trend in the embedded industry towards the use of GNU build tools and open-source build management tools, such as the Eclipse IDE. The GNU ARM compiler and Eclipse also break development teams away from expensive vendor lock-in.

The ARM GCC compiler with its associated tools and the Eclipse IDE are freely available, of high quality, and are becoming the de-facto standard development environment in the software industry. This blog post will touch upon considerations of using the GNU GCC C/C++ compiler and associated tools for embedded systems development, for ARM-based projects and together with the ECLIPSE integrated development environment.


Using ARM GCC as your ARM compiler

The GNU compiler is one of the most widely used C/C++ compilers in the world. It is the basic build tool for building all embedded Linux systems, as well as all desktop or server Linux operating systems and their applications. The GNU compiler is also used to build many commercial real-time operating systems and their applications, for example from QNX.

GNU tools are being constantly improved upon by both commercial companies and private individuals. The GNU compiler is widely disseminated in academia as a teaching tool, and as the subject of computer science research projects. The expertise and enhancements developed there quickly become state-of-the-art compiler technology that finds its way into practical GNU tools use, and is of enormous benefit to real-world developers. Few companies, if any, are by themselves able to keep up with the pace of the collaborative development efforts done on GNU tools by a large amount of individuals, companies and academic research institutions.

The GNU toolchain is open-source, and thus freely available. It is available for most microprocessor architectures, including the different ARM processor cores. This makes it an ideal starting point for embedded software development.



A C or C++ compiler, assembler and linker are at the heart of any embedded development toolchain. The same goes for a critical tool such as a debugger. The GNU toolchain is not just build and link tools, but a whole suite of high-quality command line tools for management, build, debugging and testing ARM-based embedded applications:

  • Make utility
  • C/C++ compilers
  • Assembler
  • Linker
  • C/C++ runtime and math libraries
  • Librarian
  • Other binary utilities
  • Debugger

While not part of the GNU toolchain as such, other software are often used in combination with the GNU tools, such as an Eclipse-based IDE, and gdbservers that enables the GNU debugger (gdb) to connect to embedded JTAG probe debug hardware required to debug embedded targets.



Although technically not part of the GNU C/C++ compiler toolchain, the GNU make utility is often used to drive the build process. The make utility reads a makefile which is normally maintained by the developer and then builds the input files in an appropriate manner using the assembler, compiler and linker in conjunction with the dependency rules defined in the makefile.

The make utility and associated makefiles are perfectly usable, but many professional development teams of today prefer a tool-managed build process that does not require the manual maintenance of a makefile. This is a considerable time-saving feature because the IDE is managing the makefile on behalf of the developer. This capability is offered in Eclipse-based IDE’s, such as Atollic TrueSTUDIO.



The GNU compilers are highly optimizing compilers that support both the C and C++ languages. The GNU C compiler (gcc) supports the C language, while the GNU C++ compiler (G++) supports the C++ language.

The GNU C/C++ compilers have a number of extensions that make them well suited for embedded development, including fine-grained control using many command-line options, inline assembly, and compiler #pragmas that helps control the compiler behavior in great detail. Furthermore, the GNU compilers have extensive support for a large number of target processors and language dialect standards.
Some of the feature highlights are:

  • Highly optimizing C/C++ compiler
  • Supports inline assembly
  • Supports interrupt handlers in C
  • Supports a large number of generic and target specific #pragmas
  • Generates optimized production code or debug instrumented code
  • Generates information for linker optimization (dead code & data removal)
  • Generates reports (disassembly list files)
  • Extensive set of command line options to control the operation

The following C language standards are supported:

  • C89 (original ANSI-C, X3.159-1989)
  • C90 (original ANSI-C, ISO/IEC 9899:1990)
  • C94/C95 (amendment 1, AMD1)
  • C99 (ISO/IEC 9899:1999)
  • C11 (ISO/IEC 9899:2011)
  • GNU language extensions
The following C++ language standards are supported:

  • C++98 (ISO/IEC 14882:1998)
  • C++03 (ISO/IEC 14882:2003)
  • C++11 (ISO/IEC 14882:2011)

The GNU compilers support almost all CPU architectures in common use, such as Intel x86, Renesas SH and RX, PowerPC, MIPS, AVR, MSP430, etc. This blog post is focused on ARM processors, so it should be mentioned that the GNU compilers have excellent support for the ARM cores, including for example:

  • ARM7
  • ARM9
  • Cortex-M0, Cortex-M0+, Cortex-M1, Cortex-M3, Cortex-M4, Cortex-M7
  • Cortex-R4, Cortex-R5, Cortex-R7
  • Cortex-A5, Cortex-A7, Cortex-A8, Cortex-A9, Cortex-A15, Cortex-A17, Cortex-A53, Cortex-A57, Cortex-A72

The GNU C and C++ compilers are open-source, but their licenses (GPL) do not affect the application you build with them. In other words, the GNU compilers and associated libraries are open-source, but applications built using these tools can be as proprietary or closed-source as desired.



The GNU assembler (gas) is used to convert assembler source code to object files (machine code). Some of the feature highlights are:

  • Assembles CPU specific assembler source code to a format suitable for linking
  • C/C++ preprocessor directives like #define and #ifdef
  • C multiline comments in the form of /* ... */
  • Numerical expressions are evaluated by the assembler
  • More than 100 assembler directives for various purposes
  • Macro's with support for loops
  • Extensive set of command line options to control the operation



The GNU linker (ld) links object files and pre-compiled library files into an application binary file. Some of the feature highlights are:

  • Links object files and pre-compiled library files into a binary ELF file
  • Removes unused C/C++ functions and code sections (dead code removal)
  • Removes unused C/C++ variables and data sections (dead data removal)
  • Powerful linker script command and configuration language
  • Linker script language supports C/C++ numerical expressions
  • Generate memory usage reports (map files)
  • Extensive set of command line options to control the operation



Any compiler needs runtime and math libraries in order to build anything other than trivial applications. The GNU compiler is no exception. The following libraries are normally included in the toolchain:

  • C runtime library
  • C math library
  • C++ runtime library

The most commonly used C runtime library for use in embedded systems is newlib, while the most common C++ runtime library is stdlibc++. These compiler libraries are open-source, but their licenses do not affect the application you develop. In other words, the GNU compilers and associated libraries are open-source, but applications built using these tools can be as proprietary or closed-source as desired.

In addition to newlib, a somewhat smaller version called newlib nano is also available. Additionally, Atollic provides a super-tiny implementation of printf()-styled functions, making use of only about 1KB of code size, in the Atollic TrueSTUDIO IDE.



The GNU toolchain includes the GNU archive utility (ar) that is used to create and manage pre-built software libraries, thus simplifying management and linking of software components. Some of the feature highlights are:

  • Create a new library in a format suitable for linking
  • Add, delete, rearrange and extract files in a library
  • Print the contents of a library
  • Optional script mode
  • Extensive set of command line options to control the operation



The GNU toolchain additionally contains a number of other command line utilities. These perform various tasks, such as:

  • Convert application binary ELF-files into other formats (Intel Hex or Motorola S-Record format) better suited for flash loading using external flash loading equipment
  • List symbols in object files
  • Display information in object files
  • Disassemble machine code in object files
  • Generate symbol index in archive library files
  • Display the contents of ELF format files
  • List file section sizes and total size
  • List printable strings from files
  • Discard symbols in files
  • Demangle encoded C++ symbols
  • Convert addresses into file names and line numbers



The GNU debugger (gdb) is a powerful and flexible command line debugger. It supports all traditional features one expects from a debugger:

  • Loading debug instrumented application binary (ELF) files
  • Running or stepping code
  • Simple or complex code and data breakpoints
  • Inspecting variables, CPU registers or memory
  • Script language

The gdb debugger supports over 800 commands that can be typed on its command line. Additionally, gdb commands can be scripted using a script language that supports evaluation of mathematical expressions, loops and conditional execution. This facilitates for automation of advanced debug tasks.

Unfortunately, the gdb debugger by itself is not enough to create a productive debug solution for embedded ARM targets. It does not handle DRAM or Flash support or JTAG-probe integration as-is.

Nor does it handle device specific debug features required by professional developers, like providing a graphical IDE debugger, peripheral register (SFR) visualization, real-time event- and data tracing using the ARM Serial Wire Viewer (SWV) technology, instruction tracing using the ETM/ETB technology, etc. It also does not include a Cortex-M hard fault crash analyzer or RTOS kernel aware debugging. For this, a commercial GUI debugger on top of GBD is needed. Atollic TrueSTUDIO is a great choice here.

Topics: GNU tools (GCC/GDB)