From c376fe13aef7f8824a85ea7c665a19e2a6295c30 Mon Sep 17 00:00:00 2001 From: Pete Warden Date: Wed, 5 Feb 2020 13:44:51 -0800 Subject: [PATCH] Reduce binary size for Tensilica builds Here's the size of a test binary before this change: xt-size tensorflow/lite/micro/tools/make/gen/xtensa-xpg_xtensa-xpg/bin/micro_interpreter_test text data bss dec hex filename 79416 21272 7520 108208 1a6b0 tensorflow/lite/micro/tools/make/gen/xtensa-xpg_xtensa-xpg/bin/micro_interpreter_test After: xt-size tensorflow/lite/micro/tools/make/gen/xtensa-xpg_xtensa-xpg/bin/micro_interpreter_test text data bss dec hex filename 70912 20104 7504 98520 180d8 tensorflow/lite/micro/tools/make/gen/xtensa-xpg_xtensa-xpg/bin/micro_interpreter_test This saves us about 10KB of binary footprint. PiperOrigin-RevId: 293441475 Change-Id: I954efbecb819613c53435575c997544e7e002c3c --- .../lite/micro/tools/make/targets/xtensa_xpg_makefile.inc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tensorflow/lite/micro/tools/make/targets/xtensa_xpg_makefile.inc b/tensorflow/lite/micro/tools/make/targets/xtensa_xpg_makefile.inc index 22b013a7dfe..fa3b5c78192 100644 --- a/tensorflow/lite/micro/tools/make/targets/xtensa_xpg_makefile.inc +++ b/tensorflow/lite/micro/tools/make/targets/xtensa_xpg_makefile.inc @@ -14,7 +14,9 @@ ifeq ($(TARGET), xtensa-xpg) --xtensa-core=$(XTENSA_CORE) \ -mcoproc \ -O3 \ - -DXTENSA -DMAX_RFFT_PWR=9 -DMIN_RFFT_PWR=MAX_RFFT_PWR -fdata-sections \ + -DXTENSA -DMAX_RFFT_PWR=9 -DMIN_RFFT_PWR=MAX_RFFT_PWR \ + -fdata-sections \ + -ffunction-sections \ -fmessage-length=0 TARGET_TOOLCHAIN_PREFIX := xt- @@ -24,6 +26,8 @@ ifeq ($(TARGET), xtensa-xpg) CXXFLAGS = $(PLATFORM_ARGS) -std=c++11 CCFLAGS = $(PLATFORM_ARGS) -std=c11 + LDFLAGS += -Wl,-gc-sections + TEST_SCRIPT := tensorflow/lite/micro/testing/test_xtensa_xpg_binary.sh # These are microcontroller-specific rules for converting the ELF output