diff options
Diffstat (limited to 'src/Makefile.housekeeping')
-rw-r--r-- | src/Makefile.housekeeping | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index d18b65cc..c4350671 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -415,6 +415,19 @@ CFLAGS += -finstrument-functions CFLAGS += -finstrument-functions-exclude-file-list=core/fnrec.c endif +# Enable per-item sections and section garbage collection. Note that +# some older versions of gcc support -fdata-sections but treat it as +# implying -fno-common, which would break our build. +# +ifeq ($(CCTYPE),gcc) +DS_TEST = $(ECHO) 'char x;' | \ + $(CC) -fdata-sections -S -x c - -o - 2>/dev/null | \ + grep -E '\.comm' > /dev/null +DS_FLAGS := $(shell $(DS_TEST) && $(ECHO) '-fdata-sections') +CFLAGS += -ffunction-sections $(DS_FLAGS) +endif +LDFLAGS += --gc-sections + # compiler.h is needed for our linking and debugging system # CFLAGS += -include compiler.h |