diff --git a/build/toolchain.arm-gcc.mak b/build/toolchain.arm-gcc.mak index 9bd156e6e..14995b2d1 100644 --- a/build/toolchain.arm-gcc.mak +++ b/build/toolchain.arm-gcc.mak @@ -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)