Compile with -ffunction-sectons -fdata-sections, link with -gc-sections
This seems to shrink code size by abou 3.5%. Not sure if there are any downsides.
This commit is contained in:
parent
0da6c97a9d
commit
1c9e106db8
1 changed files with 11 additions and 0 deletions
11
common.mk
11
common.mk
|
@ -94,14 +94,25 @@ OWN_LIBC ?= 1
|
|||
# Note: you will need a recent esp
|
||||
ENTRY_SYMBOL ?= call_user_start
|
||||
|
||||
# Set this to zero if you don't want individual function & data sections
|
||||
# (some code may be slightly slower, linking will be slighty slower,
|
||||
# but compiled code size will come down a small amount.)
|
||||
SPLIT_SECTIONS ?= 1
|
||||
|
||||
# Common flags for both C & C++_
|
||||
C_CXX_FLAGS = -Wall -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals $(CPPFLAGS)
|
||||
# Flags for C only
|
||||
CFLAGS = $(C_CXX_FLAGS) -std=gnu99
|
||||
# Flags for C++ only
|
||||
CXXFLAGS = $(C_CXX_FLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
LDFLAGS = -nostdlib -Wl,--no-check-sections -Wl,-L$(BUILD_DIR)sdklib -Wl,-L$(ROOT)lib -u $(ENTRY_SYMBOL) -Wl,-static -Wl,-Map=build/${PROGRAM}.map $(EXTRA_LDFLAGS)
|
||||
|
||||
ifeq ($(SPLIT_SECTIONS),1)
|
||||
C_CXX_FLAGS += -ffunction-sections -fdata-sections
|
||||
LDFLAGS += -Wl,-gc-sections
|
||||
endif
|
||||
|
||||
ifeq ($(FLAVOR),debug)
|
||||
C_CXX_FLAGS += -g -O0
|
||||
LDFLAGS += -g -O0
|
||||
|
|
Loading…
Reference in a new issue