mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
63c475cd4d
Use the -gz option to compress ELF sections containing DWARF information. This saves around 50% of disk space, without any side effects. See https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Debugging-Options.html#Debugging-Options for more infomation on this option. Some platforms have an outdated toolchain that does not support -gz so the flag is blacklisted there. Even then, the results are quite impressive. I used @cladmi's `buildtest` branch (https://github.com/cladmi/RIOT/tree/wip/du/buildtest) with this change and compiled the `examples/default` application: ``` $ BUILD_IN_DOCKER=1 DOCKER="sudo docker" make -C examples/default buildtest-indocker ``` The size was obtained with: ``` $ find output -name "*.bin.bindirsize" -type f -exec tail -n1 '{}' \; | cut -f 1 | awk '{s+=$1} END {printf "%.0f", s}' ``` Results: - Vanilla: 10328112 KB (~10GB). - with -gz: 4982788 KB (~5GB). This was inspired by #8496.
22 lines
803 B
Makefile
22 lines
803 B
Makefile
# Target architecture for the build. Use msp430 if you are unsure.
|
|
export TARGET_ARCH ?= msp430
|
|
|
|
# define build specific options
|
|
CFLAGS_CPU = -mmcu=$(CPU_MODEL)
|
|
# default std set to gnu99 of not overwritten by user
|
|
ifeq (, $(filter -std=%, $(CFLAGS)))
|
|
CFLAGS += -std=gnu99
|
|
endif
|
|
CFLAGS_LINK = -ffunction-sections -fdata-sections
|
|
CFLAGS_DBG ?= -gdwarf-2
|
|
CFLAGS_OPT ?= -Os
|
|
CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
|
|
ASFLAGS += $(CFLAGS_CPU) --defsym $(CPU_MODEL)=1 $(CFLAGS_DBG)
|
|
# export linker flags
|
|
export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -Wl,--gc-sections -static -lgcc
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -fdiagnostics-color
|
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-overflow
|
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-truncation
|
|
OPTIONAL_CFLAGS_BLACKLIST += -gz
|