Recommended avr-gcc compiler settings

It can be daunting when you first set up a project in Eclipse and you start browsing the available compiler options. There are just so many it’s not even funny. The aim of this article is to show you which options you should change, and what you should change them to in order to get the smallest possible output size for your code

All of the options that you need to change are found by right-clicking on your project name in the Project Explorer and selecting Properties. Expand the C/C++ Build category and select Settings.

AVR Assembler

Debugging -> Generate Debugging Info. Select “No debugging info” from the drop-down list.


Click image to magnify it.

AVR C++ Compiler

Debugging -> Generate Debugging Info. Select “No debugging info” from the drop-down list.

Optimization -> Optimization Level. Select “Size Optimizations (-Os)” from the drop-down list.


Click image to magnify it.

Miscellaneous -> Other Flags. Enter -ffunction-sections -fdata-sections into this field. These options will cause the compiler to place each function and data into a separately named section. This gives the linker the power to garbage collection unused functions and data and reduce the size of your final program.

AVR C Compiler

Repeat the steps from the above section AVR C++ Compiler

AVR C++ Linker

General->Other Arguments. Enter -Wl,–gc-sections into this field to enable garbage collection.