aboutsummaryrefslogtreecommitdiff
path: root/Makefile.main
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2017-01-05 19:35:48 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-02-06 18:57:43 +1100
commit2bec353d38a685a4352f48fbbf0d765359da3bdb (patch)
tree5077bc246e46be3d843a4ab67ece4830ec6cf31b /Makefile.main
parent4ebde139333659b6de4516830a2785b8a89c08a4 (diff)
downloadskiboot-2bec353d38a685a4352f48fbbf0d765359da3bdb.zip
skiboot-2bec353d38a685a4352f48fbbf0d765359da3bdb.tar.gz
skiboot-2bec353d38a685a4352f48fbbf0d765359da3bdb.tar.bz2
Dead code and data elimination
Add an experimental option to do basic dead code and data elimintation with -ffunction-sections/-fdata-sections/--gc-sections. This saves about 80kB of text/data. Also remove the use of of -ffunction-sections by default. This predates git history, but I don't think there is a good reason to use it without --gc-sections. The GCC manual says: Only use these options when there are significant benefits from doing so. When you specify these options, the assembler and linker create larger object and executable files and are also slower. You cannot use gprof on all systems if you specify this option, and you may have problems with debugging if you specify both this option and -g. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'Makefile.main')
-rw-r--r--Makefile.main10
1 files changed, 9 insertions, 1 deletions
diff --git a/Makefile.main b/Makefile.main
index 5656cb7..6a69b65 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -48,7 +48,7 @@ VALGRIND=valgrind -q --show-reachable=yes --error-exitcode=99
# Target options
-OPTS=-Os -ffunction-sections
+OPTS=-Os
DBG=-g
CPPFLAGS := -I$(SRC)/include -Iinclude -MMD -include $(SRC)/include/config.h
@@ -78,6 +78,10 @@ else
CFLAGS += $(call try-cflag,$(CC),-mabi=elfv1)
endif
+ifeq ($(DEAD_CODE_ELIMINATION),1)
+CFLAGS += -ffunction-sections -fdata-sections
+endif
+
ifeq ($(SKIBOOT_GCOV),1)
CFLAGS += -fprofile-arcs -ftest-coverage -DSKIBOOT_GCOV=1
endif
@@ -112,6 +116,10 @@ LDRFLAGS=-melf64ppc
# Debug stuff
#LDFLAGS += -Wl,-v -Wl,-Map,foomap
+ifeq ($(DEAD_CODE_ELIMINATION),1)
+LDFLAGS += -Wl,--gc-sections
+endif
+
AFLAGS := -D__ASSEMBLY__ -mbig-endian -m64
ifeq ($(ELF_ABI_v2),1)
AFLAGS += $(call try-cflag,$(CC),-mabi=elfv2)