Browse Source

make: allow per-file conditional LTO compile

pr/spi.typo
Kaspar Schleiser 6 years ago
parent
commit
1f9a87972b
  1. 14
      Makefile.base
  2. 1
      Makefile.vars

14
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 $<))\" \

1
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.

Loading…
Cancel
Save