Makefile: enable LTO
This rearranges Makefile a bit and enables Link Time Optimisation which leads to a smaller code (77724 text with gcc 4.7.3). Unconditionally adding -ggdb3 doesn't affect code size anyhow as all the debugging info is stored in separate sections. Build-tested only. Signed-off-by: Paul Fertser <fercerpav@gmail.com> Conflicts: Makefile
This commit is contained in:
parent
53623d4d7f
commit
f218d3c040
25
Makefile
25
Makefile
|
@ -335,9 +335,21 @@ SIZE = arm-none-eabi-size
|
|||
# Tool options.
|
||||
#
|
||||
|
||||
BASE_CFLAGS = $(ARCH_FLAGS) \
|
||||
ifeq ($(DEBUG),GDB)
|
||||
OPTIMIZE = -O0
|
||||
LTO_FLAGS = $(OPTIMIZE)
|
||||
else
|
||||
OPTIMIZE = -Os
|
||||
LTO_FLAGS = -flto -fuse-linker-plugin $(OPTIMIZE)
|
||||
endif
|
||||
|
||||
DEBUG_FLAGS = -ggdb3
|
||||
|
||||
CFLAGS = $(ARCH_FLAGS) \
|
||||
$(LTO_FLAGS) \
|
||||
$(addprefix -D,$(OPTIONS)) \
|
||||
$(addprefix -I,$(INCLUDE_DIRS)) \
|
||||
$(DEBUG_FLAGS) \
|
||||
-Wall \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
|
@ -354,6 +366,8 @@ ASFLAGS = $(ARCH_FLAGS) \
|
|||
# XXX Map/crossref output?
|
||||
LDFLAGS = -lm \
|
||||
$(ARCH_FLAGS) \
|
||||
$(LTO_FLAGS) \
|
||||
$(DEBUG_FLAGS) \
|
||||
-static \
|
||||
-Wl,-gc-sections,-Map,$(TARGET_MAP) \
|
||||
-T$(LD_SCRIPT)
|
||||
|
@ -369,15 +383,6 @@ ifeq ($(filter $(TARGET),$(VALID_TARGETS)),)
|
|||
$(error Target '$(TARGET)' is not valid, must be one of $(VALID_TARGETS))
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG),GDB)
|
||||
CFLAGS = $(BASE_CFLAGS) \
|
||||
-ggdb \
|
||||
-O0
|
||||
else
|
||||
CFLAGS = $(BASE_CFLAGS) \
|
||||
-Os
|
||||
endif
|
||||
|
||||
|
||||
TARGET_HEX = $(BIN_DIR)/$(FORKNAME)_$(TARGET).hex
|
||||
TARGET_ELF = $(OBJECT_DIR)/$(FORKNAME)_$(TARGET).elf
|
||||
|
|
Loading…
Reference in New Issue