mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 16:25:26 +03:00
Allow for different optimization profiles depending on file and target in Makefile
This commit is contained in:
parent
6753c410c6
commit
0da14f5ad5
3 changed files with 15 additions and 11 deletions
18
Makefile
18
Makefile
|
@ -301,14 +301,18 @@ $(TARGET_ELF): $(TARGET_OBJS)
|
|||
$(V0) $(SIZE) $(TARGET_ELF)
|
||||
|
||||
define compile_file
|
||||
echo "%% ($(1)) $<" "$(STDOUT)" && \
|
||||
echo "%% $(1) $<" "$(STDOUT)" && \
|
||||
$(CROSS_CC) -c -o $@ $(CFLAGS) $(2) $<
|
||||
endef
|
||||
|
||||
ifneq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))
|
||||
|
||||
OPTIMIZE_FLAG_SPEED = -Ofast
|
||||
OPTIMIZE_FLAG_SIZE = -Os
|
||||
OPTIMIZE_FLAG_NORMAL = -O2
|
||||
else
|
||||
|
||||
OPTIMIZE_FLAG_SPEED = -Os
|
||||
OPTIMIZE_FLAG_SIZE = -Os
|
||||
OPTIMIZE_FLAG_NORMAL = -Os
|
||||
endif
|
||||
|
||||
# Compile
|
||||
|
@ -316,12 +320,12 @@ $(TARGET_OBJ_DIR)/%.o: %.c
|
|||
$(V1) mkdir -p $(dir $@)
|
||||
|
||||
$(V1) $(if $(findstring $<,$(SIZE_OPTIMISED_SRC)), \
|
||||
$(call compile_file,(size),$(CC_NO_OPTIMISATION)) \
|
||||
$(call compile_file,(size),$(OPTIMIZE_FLAG_SIZE)) \
|
||||
, \
|
||||
$(if $(findstring $(subst ./src/main/,,$<),$(SPEED_OPTIMISED_SRC)), \
|
||||
$(call compile_file,(speed)),$(CC_SPEED_OPTIMISATION)) \
|
||||
$(if $(findstring $<,$(SPEED_OPTIMISED_SRC)), \
|
||||
$(call compile_file,(speed),$(OPTIMIZE_FLAG_SPEED)) \
|
||||
, \
|
||||
$(call compile_file,,$(CC_SIZE_OPTIMISATION)) \
|
||||
$(call compile_file,,$(OPTIMIZE_FLAG_NORMAL)) \
|
||||
) \
|
||||
)
|
||||
ifeq ($(GENERATE_ASM), 1)
|
||||
|
|
|
@ -281,9 +281,9 @@ SIZE_OPTIMISED_SRC := ""
|
|||
SPEED_OPTIMISED_SRC := ""
|
||||
ifneq ($(TARGET),$(filter $(TARGET),$(F3_TARGETS)))
|
||||
# SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \
|
||||
# ./src/main/common/filter.c \
|
||||
# ./src/main/common/filter.c \
|
||||
|
||||
# SPEED_OPTIMISED_SRC := $(SPEED_OPTIMISED_SRC) \
|
||||
# ./src/main/common/filter.c \
|
||||
# ./src/main/common/maths.c \
|
||||
|
||||
endif #!F3
|
|
@ -65,14 +65,14 @@
|
|||
#ifndef STM32F3
|
||||
#define FUNCTION_COMPILE_FOR_SIZE __attribute__((optimize("-Os")))
|
||||
#define FUNCTION_COMPILE_NORMAL __attribute__((optimize("-O2")))
|
||||
#define FUNCTION_COMPILE_FOR_SIZE __attribute__((optimize("-Ofast")))
|
||||
#define FUNCTION_COMPILE_FOR_SPEED __attribute__((optimize("-Ofast")))
|
||||
#define FILE_COMPILE_FOR_SIZE _Pragma("GCC optimize(\"Os\")")
|
||||
#define FILE_COMPILE_NORMAL _Pragma("GCC optimize(\"O2\")")
|
||||
#define FILE_COMPILE_FOR_SPEED _Pragma("GCC optimize(\"Ofast\")")
|
||||
#else
|
||||
#define FUNCTION_COMPILE_FOR_SIZE
|
||||
#define FUNCTION_COMPILE_NORMAL
|
||||
#define FUNCTION_COMPILE_FOR_SIZE
|
||||
#define FUNCTION_COMPILE_FOR_SPEED
|
||||
#define FILE_COMPILE_FOR_SIZE
|
||||
#define FILE_COMPILE_NORMAL
|
||||
#define FILE_COMPILE_FOR_SPEED
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue