compile/opt: add config DEBUG_OPT_UNUSED_SECTIONS

Enable this option to optimization the unused input sections with the
linker by compiling with " -ffunction-sections -fdata-sections ", and
linking with " --gc-sections ".

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an
2022-04-21 18:10:40 +08:00
committed by Xiang Xiao
parent 56ecd44f63
commit 64d7326ed5
46 changed files with 149 additions and 93 deletions
@@ -34,7 +34,7 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing
endif
ARCHCFLAGS += -fno-common -ffunction-sections -fdata-sections
ARCHCFLAGS += -fno-common
ARCHCXXFLAGS += -fno-common
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
@@ -61,8 +61,6 @@ CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs
LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)gnu-elf.ld)
LDFLAGS += --gc-sections
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif