cpu/avr: Make sure that GCC removes all unused symbols.

This magic comes from the `--gc-sections` linker flag, which turns on garbage collection for unused input sections. The compiler flags `-ffunction-sections` and `-fdata-sections` make sure that each function and each static data definition have their own section. The result is that GCC can prune away all unused symbols, reducing the size of the resulting executable.

These optimizations may be disabled by setting the Makefile variable
`SMALL` to zero.
This commit is contained in:
Robert Quattlebaum 2012-05-17 10:27:31 -07:00
parent b3de9a05e7
commit 67a39618eb

View File

@ -106,6 +106,15 @@ endif
LDFLAGS += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map \
-Wl,--section-start=.bootloader=$(BOOTLOADER_START)
SMALL ?= 1
### These flags help significantly reduce the code size
ifeq ($(SMALL),1)
CFLAGS += -ffunction-sections
CFLAGS += -fdata-sections
LDFLAGS += -Wl,--gc-sections
endif # SMALL
### Setup directory search path for source files
CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \