SEGGER Compiler
Optimizing C/C++
Generate optimized code for embedded systems.
Overview
The SEGGER Compiler is an optimizing C/C++ compiler for Arm and RISC-V microcontrollers. Based on Clang, it offers a modern and flexible front end, which supports the latest C and C++ language features. The back end, which produces the binary objects for the target architecture, has been optimized by SEGGER to generate fast and small Thumb-2 code for Cortex-M and Cortex-A processors. In combination with the SEGGER Linker, the SEGGER Assembler, and the SEGGER Runtime Library, it shapes a professional toolchain for any embedded application.
The SEGGER Compiler is directly integrated into Embedded Studio and can easily be used. As the front end is compatible to GCC and Clang, existing projects can be configured to use the SEGGER Compiler with just one option to be changed.
Key features
- Modern and flexible front end, supports the latest C/C++ language standard
 - Support for all popular Arm cores and RISC-V
 - Significantly improved code generation for Thumb-1/Thumb-2 target CPUs, achieving higher performance and smaller code size
 - Easy to use: Compiler invocation and language extensions compatible to clang and mostly compatible to GCC
 
Performance
Size optimization
The SEGGER Compiler can tweak the code generation to produce small code for size optimization, while retaining good execution speed.
The following table shows the code size of the compiler output with size optimization (-Oz). All measurements were performed on a Cortex-M4 target.
| Test Case | Code Size | |||||
|---|---|---|---|---|---|---|
SEGGER Compiler 20.1.0  | Clang 20.1.8 | GCC 14.2.1 | ||||
| CRC | 154 bytes = 100.00 % | 164 bytes = 106.5 % | 166 bytes = 107.8 % | |||
| CompressToGo | 2,120 bytes = 100.00 % | 2,310 bytes = 109.0 % | 2,134 bytes = 100.7 % | |||
| AES_CBC | 1,762 bytes = 100.00 % | 1,922 bytes = 109.1 % | 2,120 bytes = 120.3 % | |||
| SHA256 | 906 bytes = 100.00 % | 958 bytes = 105.7 % | 990 bytes = 109.3 % | |||
| RSA_Sign | 4,926 bytes = 100.00 % | 5,348 bytes = 108.6 % | 5,408 bytes = 109.8 % | |||
| FS_Test | 42,454 bytes = 100.00 % | 43,394 bytes = 102.2 % | 46,026 bytes = 108.4 % | |||
| coremark | 2,418 bytes = 100.00 % | 2,686 bytes = 111.1 % | 2,740 bytes = 113.3 % | |||
| emBench | 39,978 bytes = 100.00 % | 48,256 bytes = 120.7 % | 52,532 bytes = 131.4 % | |||
| Average | 100.00 % | 110.9 % | 118.4 % | |||
Speed optimization
With the highest optimization level, the SEGGER Compiler produces fastest code with advanced optimization and less focus on code size.
The following table shows the performance values of the compilers with the highest optimization (-O3). All measurements were performed on a Cortex-M4 target.
| Test Case | Run Time | ||
|---|---|---|---|
| SEGGER Compiler 20.1.0 | Clang 20.1.8 | GCC 14.2.1 | |
| CRC | 100.00 % | 103.1 % | 110.1 | 
| CompressToGo | 100.00 % | 112.5 % | 97.4 % | 
| AES_CBC | 100.00 % | 108.8 % | 123.2 % | 
| SHA256 | 100.00 % | 106.6 % | 111.3 % | 
| RSA_Sign | 100.00 % | 115.2 % | 116.2 % | 
| FS_TEST | 100.00 % | 102.5 % | 105.0 % | 
| coremark | 100.00 % | 135.8 % | 130.7 % | 
| emBench | 100.00 % | 108.1 % | 110.8 % | 
| Average | 100.00 % | 111.6 % | 113.1 % | 
Stack Overflow Prevention (STOP) technology
With STOP technology, the Compiler adds a call to stack limit-check routine wherever necessary, before adjusting the stack pointer. As an option for the Clang-based, highly optimizing SEGGER Compiler, STOP can be easily enabled, without any change to application code. This way, all stack overflows are prevented. If a stack overflow has been prevented, the system can enter a safe state and recover.