GCC and IAR compiler comparison


Jump to: navigation, search

With the recent release of the IAR compiler for Lego Mindstorms NXT, it is possible to compare the size of the firmware that the two compilers generate. Start by looking at the memory layout. The table below shows the size of the compiled firmware in the flash and RAM of NXT. The term "packing" refers to packing of structs.

Compiler (1.05 sources) Size of .text (Flash bytes) Size of .data (RAM bytes) Speed #loops (using a benchmark)
GCC (pack all) 202052 54548 -
NXTGCC (pack selected) 180104 54144 615
GCC (pack none) 162136 54228 -
IAR (speed optimization) 127552 49831 -
IAR (size optimization) 122440 49763 640

IAR produce a smaller and faster image than GCC.

IAR Compiler

You can set the speed or size optimization flags here:



Then choose Rebuild All, and read the numbers from the IAR map output. Check the IAR linker reference for a good explanation of the segments. The .text (Flash) size is CODE + CONST, and .data (RAM) is the DATA segment:



In NXTGCC you can also read the numbers after a firmware build. The RAM requirement is .data + .bss. It is indicated how to produce the numbers when (1)all structs are packed, (2)some are packed (NXTGCC default), and (3)none are packed:


Personal tools