Merge pull request #43748 from advaitjain:makefile-flags-cleanup

PiperOrigin-RevId: 335537355
Change-Id: I7d97e4ddbe24997c2c32b9c1134bcdac1c77ad53
This commit is contained in:
TensorFlower Gardener 2020-10-05 17:43:09 -07:00
commit d39f175a14
5 changed files with 63 additions and 64 deletions

View File

@ -38,10 +38,9 @@ void FftCompute(struct FftState* state, const int16_t* input,
}
// Apply the FFT.
kiss_fftr(
reinterpret_cast<const kiss_fftr_cfg>(state->scratch),
state->input,
reinterpret_cast<kiss_fft_cpx*>(state->output));
kiss_fftr(reinterpret_cast<kiss_fftr_cfg>(state->scratch),
state->input,
reinterpret_cast<kiss_fft_cpx*>(state->output));
}
void FftInit(struct FftState* state) {

View File

@ -90,17 +90,47 @@ TAG_DEFINES := $(foreach TAG,$(TAGS),-D$(shell echo $(TAG) | tr [a-z] [A-Z] | tr
OPTIMIZATION_LEVEL := -O3
CC_WARNINGS := -Werror -Wsign-compare -Wdouble-promotion \
-Wshadow -Wunused-variable -Wmissing-field-initializers \
-Wunused-function -Wswitch -Wvla
# TODO(b/150240249): Add in -fno-rtti once that works for the Xtensa toolchain.
CXXFLAGS := -std=c++11 -Wstrict-aliasing -DTF_LITE_STATIC_MEMORY \
$(CC_WARNINGS) $(OPTIMIZATION_LEVEL) $(TAG_DEFINES)
CCFLAGS := -DTF_LITE_STATIC_MEMORY $(CC_WARNINGS) $(OPTIMIZATION_LEVEL) \
$(TAG_DEFINES)
CC_WARNINGS := \
-Werror \
-Wsign-compare \
-Wdouble-promotion \
-Wshadow \
-Wunused-variable \
-Wmissing-field-initializers \
-Wunused-function \
-Wswitch \
-Wvla \
-Wall \
-Wextra \
-Wstrict-aliasing \
-Wno-unused-parameter
COMMON_FLAGS := \
-fno-unwind-tables \
-ffunction-sections \
-fdata-sections \
-fmessage-length=0 \
-DTF_LITE_STATIC_MEMORY \
$(OPTIMIZATION_LEVEL) \
$(CC_WARNINGS) \
$(TAG_DEFINES)
CXXFLAGS := \
-std=c++11 \
-fno-rtti \
-fno-exceptions \
-fno-threadsafe-statics \
$(COMMON_FLAGS)
CCFLAGS := \
-std=c11 \
$(COMMON_FLAGS)
ARFLAGS := -r
LDFLAGS += -Wl,--fatal-warnings
LDFLAGS += \
-Wl,--fatal-warnings \
-Wl,--gc-sections
# override these in the makefile.inc for specific compiler targets
TARGET_TOOLCHAIN_PREFIX :=

View File

@ -1,5 +1,6 @@
# Settings for Blue Pill platforms.
ifeq ($(TARGET), bluepill)
export PATH := $(MAKEFILE_DIR)/downloads/gcc_embedded/bin/:$(PATH)
TARGET_ARCH := cortex-m3
TARGET_TOOLCHAIN_PREFIX := arm-none-eabi-
@ -9,54 +10,38 @@ ifeq ($(TARGET), bluepill)
$(eval $(call add_third_party_download,$(STM32_BARE_LIB_URL),$(STM32_BARE_LIB_MD5),stm32_bare_lib,))
PLATFORM_FLAGS = \
-DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK \
-DTF_LITE_MCU_DEBUG_LOG \
-fmessage-length=0 \
-fno-exceptions \
-fno-unwind-tables \
-ffunction-sections \
-fdata-sections \
-funsigned-char \
-MMD \
-mcpu=cortex-m3 \
-mthumb \
-Wall \
-Wextra \
-Wno-vla \
-Wno-unused-parameter \
-Wno-strict-aliasing \
-Wno-shadow \
-Wno-type-limits \
-fno-delete-null-pointer-checks \
-fomit-frame-pointer \
-nostdlib \
-g \
-Os
-nostdlib
# TODO(b/168334217): Currently we always add -DNDEBUG because the build is
# broken w/o it. Remove this workaround once the issue is resolved.
PLATFORM_FLAGS += -DNDEBUG
CXXFLAGS += $(PLATFORM_FLAGS) -fno-rtti -fno-threadsafe-statics \
-fno-use-cxa-atexit
CXXFLAGS += $(PLATFORM_FLAGS) -fno-use-cxa-atexit
CCFLAGS += $(PLATFORM_FLAGS)
LDFLAGS += \
-T $(MAKEFILE_DIR)/targets/bluepill/bluepill.lds \
-Wl,-Map=$(MAKEFILE_DIR)/gen/$(TARGET).map,--cref \
-Wl,--gc-sections
BUILD_TYPE := micro
MICROLITE_LIBS := \
-lm
-Wl,-Map=$(MAKEFILE_DIR)/gen/$(TARGET).map,--cref
# Additional include paths needed for the stm_32_bare_lib only.
INCLUDES += \
-isystem$(MAKEFILE_DIR)/downloads/cmsis/CMSIS/Core/Include/ \
-I$(MAKEFILE_DIR)/downloads/stm32_bare_lib/include
MICROLITE_CC_SRCS += \
$(wildcard $(MAKEFILE_DIR)/downloads/stm32_bare_lib/source/*.c) \
$(wildcard $(MAKEFILE_DIR)/downloads/stm32_bare_lib/source/*.cc)
EXCLUDED_SRCS := \
$(MAKEFILE_DIR)/downloads/stm32_bare_lib/source/debug_log.c
MICROLITE_CC_SRCS := $(filter-out $(EXCLUDED_SRCS), $(MICROLITE_CC_SRCS))
TEST_SCRIPT := tensorflow/lite/micro/testing/test_bluepill_binary.sh
# TODO(b/143286954): Figure out why some tests fail and enable ince the issues
# are resolved.
@ -74,13 +59,6 @@ ifeq ($(TARGET), bluepill)
tensorflow/lite/micro/examples/image_recognition_experimental/Makefile.inc
MICRO_LITE_EXAMPLE_TESTS := $(filter-out $(EXCLUDED_EXAMPLE_TESTS), $(MICRO_LITE_EXAMPLE_TESTS))
# These are microcontroller-specific rules for converting the ELF output
# of the linker into a binary image that can be loaded directly.
OBJCOPY := $(TARGET_TOOLCHAIN_PREFIX)objcopy
$(BINDIR)/%.bin: $(BINDIR)/%
@mkdir -p $(dir $@)
$(OBJCOPY) $< $@ -O binary
TEST_SCRIPT := tensorflow/lite/micro/testing/test_bluepill_binary.sh
endif

View File

@ -7,13 +7,8 @@ ifeq ($(TARGET), cortex_m_gcc_generic)
$(eval $(call add_third_party_download,$(GCC_EMBEDDED_URL),$(GCC_EMBEDDED_MD5),gcc_embedded,))
PLATFORM_FLAGS = \
-DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK \
-DTF_LITE_MCU_DEBUG_LOG \
-fmessage-length=0 \
-fno-exceptions \
-fno-unwind-tables \
-ffunction-sections \
-fdata-sections \
-Wno-type-limits \
-funsigned-char \
-mcpu=cortex-m4 \
-mfpu=fpv4-sp-d16 \
@ -32,5 +27,5 @@ endif
CXXFLAGS += $(PLATFORM_FLAGS)
CCFLAGS += $(PLATFORM_FLAGS)
endif
endif

View File

@ -23,28 +23,25 @@ ifeq ($(TARGET), xtensa_hifimini)
$(error XTENSA_CORE is undefined)
endif
PLATFORM_ARGS = \
PLATFORM_FLAGS = \
-DTF_LITE_MCU_DEBUG_LOG \
--xtensa-core=$(XTENSA_CORE) \
-mcoproc \
-DXTENSA -DMAX_RFFT_PWR=9 -DMIN_RFFT_PWR=MAX_RFFT_PWR \
-fdata-sections \
-ffunction-sections \
-fno-exceptions \
-fno-unwind-tables \
-fno-use-cxa-atexit \
-fmessage-length=0 \
-fno-threadsafe-statics
-DXTENSA \
-DMAX_RFFT_PWR=9 \
-DMIN_RFFT_PWR=MAX_RFFT_PWR
export PATH := $(XTENSA_BASE)/tools/$(XTENSA_TOOLS_VERSION)/XtensaTools/bin:$(PATH)
TARGET_TOOLCHAIN_PREFIX := xt-
CXX_TOOL := clang++
CC_TOOL := clang
CXXFLAGS += $(PLATFORM_ARGS)
CCFLAGS += $(PLATFORM_ARGS)
CXXFLAGS += $(PLATFORM_FLAGS)
CCFLAGS += $(PLATFORM_FLAGS)
LDFLAGS += -Wl,-gc-sections
# TODO(b/150240249): Do not remove -fno-rtti once that works for the Xtensa toolchain.
CXXFLAGS := $(filter-out -fno-rtti, $(CXXFLAGS))
TEST_SCRIPT := tensorflow/lite/micro/testing/test_xtensa_hifimini_binary.sh