SEGGER Compiler
Optimizing C/C++
Generate optimized code for embedded systems.
Overview
The SEGGER Compiler is an optimizing C/C++ compiler for Arm 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
- 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).
Test Case | Code Size | |||||
---|---|---|---|---|---|---|
SEGGER Compiler 18.1.0 | Clang 18.1.6 | GCC 13.2.1 | ||||
CRC | 152 bytes = 100.00 % | 166 bytes = 109.2 % | 164 bytes = 107.9 % | |||
CompressToGo | 2,096 bytes = 100.00 % | 2,308 bytes = 110.1 % | 2,124 bytes = 101.3 % | |||
AES-CBC | 1,768 bytes = 100.00 % | 1,924 bytes = 108.8 % | 2,120 bytes = 119.9 % | |||
SHA-256 | 926 bytes = 100.00 % | 978 bytes = 105.6 % | 986 bytes = 106.5 % | |||
RSA Sign | 4,996 bytes = 100.00 % | 5,364 bytes = 107.4 % | 5,318 bytes = 106.4 % | |||
FS Test | 42,804 bytes = 100.00 % | 43,544 bytes = 101.7 % | 45,800 bytes = 107.0 % | |||
coremark | 2,496 bytes = 100.00 % | 2,700 bytes = 108.2 % | 2,734 bytes = 109.5 % | |||
emBench | 40,654 bytes = 100.00 % | 48,292 bytes = 118.8 % | 52,662 bytes = 129.5 % | |||
Average | 100.00 % | 109.8 % | 116.7 % |
Speed optimization
With 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 highest optimization (-O3).
Test Case | Run Time | ||
---|---|---|---|
SEGGER Compiler 18.1.0 | Clang 18.1.6 | GCC 13.2.1 | |
CRC | 100.00 | 103.0 | 110.4 |
CompressToGo | 100.00 | 110.3 | 93.2 |
AES_CBC | 100.00 | 106.2 | 122.5 |
SHA256 | 100.00 | 107.0 | 112.7 |
RSA_Sign | 100.00 | 105.8 | 107.5 |
FS_TEST | 100.00 | 116.8 | 102.2 |
coremark | 100.00 | 100.9 | 91.7 |
emBench | 100.00 | 104.7 | 110.5 |
Average | 100.00 | 106.8 | 106.3 |
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.