Skip to content

Commit

Permalink
Merge pull request #22 from dmsc/use-lto
Browse files Browse the repository at this point in the history
Use link-time-optimization in the build.
  • Loading branch information
devanlai authored Apr 19, 2020
2 parents f7d5035 + 7b62074 commit 3c5a855
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ PREFIX ?= arm-none-eabi
CC := $(PREFIX)-gcc
CXX := $(PREFIX)-g++
LD := $(PREFIX)-gcc
AR := $(PREFIX)-ar
AR := $(PREFIX)-gcc-ar
AS := $(PREFIX)-as
OBJCOPY := $(PREFIX)-objcopy
OBJDUMP := $(PREFIX)-objdump
Expand All @@ -94,15 +94,15 @@ LIB_DIR = $(OPENCM3_DIR)/lib
####################################################################
# C flags

CFLAGS += -Os -g -std=gnu11
CFLAGS += -Os -flto -g -std=gnu11
CFLAGS += -Wextra -Wshadow -Wimplicit-function-declaration
CFLAGS += -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
CFLAGS += -fno-common -ffunction-sections -fdata-sections

####################################################################
# C++ flags

CXXFLAGS += -Os -g
CXXFLAGS += -Os -flto -g
CXXFLAGS += -Wextra -Wshadow -Wredundant-decls -Weffc++
CXXFLAGS += -fno-common -ffunction-sections -fdata-sections

Expand All @@ -116,7 +116,7 @@ CPPFLAGS += -I$(INCLUDE_DIR) $(DEFS)
####################################################################
# Linker flags

LDFLAGS += --static -nostartfiles
LDFLAGS += -flto -Os -g --static -nostartfiles
LDFLAGS += -L$(LIB_DIR)
LDFLAGS += -T$(LDSCRIPT)
LDFLAGS += -Wl,-Map=$(*).map
Expand Down Expand Up @@ -159,7 +159,7 @@ $(OPENCM3_DIR)/Makefile:
$(Q)git submodule update --init $(OPENCM3_DIR)

$(LIB_DIR)/lib$(LIBNAME).a: $(OPENCM3_DIR)/Makefile
$(Q)$(MAKE) -C $(OPENCM3_DIR) TARGETS=$(OPENCM3_TARGET)
$(Q)$(MAKE) -C $(OPENCM3_DIR) AR=$(AR) CFLAGS="-flto -g" TARGETS=$(OPENCM3_TARGET)

locm3: $(LIB_DIR)/lib$(LIBNAME).a

Expand Down

0 comments on commit 3c5a855

Please sign in to comment.