[build] LTO flag can be set by user, else it is opposite of DEBUG flag

If no LTO, at least prune symbols.
This commit is contained in:
Léa Saviot
2018-10-16 11:34:11 +02:00
committed by EmilieNumworks
parent 5cd0f8796a
commit fb2bde7938

View File

@@ -5,18 +5,25 @@ GDB = arm-none-eabi-gdb
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
LTO=1
ifeq ($(DEBUG),1)
# Always generate debug information
SFLAGS += -ggdb3
# LTO ?= NOT(DEBUG)
ifeq ($(DEBUG),1)
LTO ?= 0
else
LTO ?= 1
endif
ifeq ($(LTO),1)
# Use link-time optimization if LTO=1
SFLAGS += -flto
else
# Otherwise, just get rid of unused symbols
SFLAGS += -fdata-sections -ffunction-sections
LDFLAGS += -Wl,--gc-sections
endif
endif
SFLAGS += -mthumb -march=armv7e-m -mfloat-abi=hard -mcpu=cortex-m4 -mfpu=fpv4-sp-d16
LDFLAGS += $(SFLAGS) -lgcc -Wl,-T,$(LDSCRIPT)