diff --git a/Makefile.base b/Makefile.base index 98f75964a3..04bfec914c 100644 --- a/Makefile.base +++ b/Makefile.base @@ -23,7 +23,7 @@ ${DIRS:%=CLEAN--%}: "$(MAKE)" -C ${@:CLEAN--%=%} clean ifeq ($(strip $(SRC)),) - SRC := $(wildcard *.c) + SRC := $(filter-out $(SRC_NOLTO), $(wildcard *.c)) endif ifeq ($(strip $(SRCXX)),) SRCXX := $(wildcard *.cpp) @@ -35,10 +35,12 @@ ifeq ($(strip $(ASSMSRC)),) ASSMSRC := $(wildcard *.S) endif -OBJC := $(SRC:%.c=$(BINDIR)$(MODULE)/%.o) -OBJCXX := $(SRCXX:%.cpp=$(BINDIR)$(MODULE)/%.o) -ASMOBJ := $(ASMSRC:%.s=$(BINDIR)$(MODULE)/%.o) -ASSMOBJ := $(ASSMSRC:%.S=$(BINDIR)$(MODULE)/%.o) +OBJC_LTO := $(SRC:%.c=$(BINDIR)$(MODULE)/%.o) +OBJC_NOLTO := $(SRC_NOLTO:%.c=$(BINDIR)$(MODULE)/%.o) +OBJC := $(OBJC_NOLTO) $(OBJC_LTO) +OBJCXX := $(SRCXX:%.cpp=$(BINDIR)$(MODULE)/%.o) +ASMOBJ := $(ASMSRC:%.s=$(BINDIR)$(MODULE)/%.o) +ASSMOBJ := $(ASSMSRC:%.S=$(BINDIR)$(MODULE)/%.o) OBJ := $(OBJC) $(OBJCXX) $(ASMOBJ) $(ASSMOBJ) DEP := $(OBJC:.o=.d) $(OBJCXX:.o=.d) $(ASSMOBJ:.o=.d) @@ -56,6 +58,8 @@ CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS) # compile and generate dependency info +$(OBJC_LTO): CFLAGS+=$(LTOFLAGS) + $(OBJC): $(BINDIR)$(MODULE)/%.o: %.c $(RIOTBUILD_CONFIG_HEADER_C) $(AD)$(CCACHE) $(CC) \ -DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \ diff --git a/Makefile.vars b/Makefile.vars index b7ee2f776d..09d6ef720e 100644 --- a/Makefile.vars +++ b/Makefile.vars @@ -35,6 +35,7 @@ export AS # The assembler. export ASFLAGS # Flags for the assembler. export LINK # The command used to link the files. Must take the same parameters as GCC, i.e. "ld" won't work. export LINKFLAGS # Flags to supply in the linking step. +export LTOFLAGS # extra CFLAGS for compiling with link time optimization export OBJCOPY # The command used to create the HEXFILE. export OFLAGS # The parameter for OBJCOPY, e.g. to strip the debug information. export OBJDUMP # The command used to create the assembly listing.