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 16.1.0 | Clang 16.03 | GCC 12.2.1 | ||||
CRC | 156 bytes = 100.00 % | 166 bytes = 106.4 % | 168 bytes = 107.7 % | |||
emCompress | 2,154 bytes = 100.00 % | 2,288 bytes = 106.2 % | 2,132 bytes = 99.0 % | |||
AES-CBC | 1,766 bytes = 100.00 % | 1,916 bytes = 108.5 % | 2,144 bytes = 121.4 % | |||
SHA-256 | 920 bytes = 100.00 % | 978 bytes = 106.3 % | 986 bytes = 107.2 % | |||
RSA Sign | 5,104 bytes = 100.00 % | 5,402 bytes = 105.8 % | 5,284 bytes = 103.5 % | |||
FS Test | 42,890 bytes = 100.00 % | 43,444 bytes = 101.3 % | 46,074 bytes = 107.4 % | |||
coremark | 2,520 bytes = 100.00 % | 2,692 bytes = 106.8 % | 2,862 bytes = 113.6 % | |||
emBench | 45,304 bytes = 100.00 % | 48,388 bytes = 106.8 % | 52,658 bytes = 116.2 % | |||
Average | 100.00 % | 106.0 % | 109.5 % |
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 16.1.0 | Clang 16.0.3 | GCC 12.2.1 | |
CRC | 100.00 | 102.7 | 123.5 |
CompressToGo | 100.00 | 115.4 | 93.5 |
AES_CBC | 100.00 | 104.1 | 123.3 |
SHA256 | 100.00 | 102.5 | 107.6 |
RSA_Sign | 100.00 | 102.3 | 105.5 |
FS_TEST | 100.00 | 108.1 | 107.4 |
coremark | 100.00 | 103.3 | 92.4 |
emBench | 100.00 | 103.8 | 110.1 |
Average | 100.00 | 105.3 | 107.9 |
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.