summaryrefslogtreecommitdiffstats
path: root/src/Makefile.housekeeping
diff options
context:
space:
mode:
authorMichael Brown2011-06-29 12:42:07 +0200
committerMichael Brown2011-06-29 12:48:29 +0200
commit95d82bb2a23bf645d995aed0d643cc34d5d8a3af (patch)
treeec1c7965f7df1792984a704a48da987a643f4dd9 /src/Makefile.housekeeping
parent[http] Fix size_t format specifiers (diff)
downloadipxe-95d82bb2a23bf645d995aed0d643cc34d5d8a3af.tar.gz
ipxe-95d82bb2a23bf645d995aed0d643cc34d5d8a3af.tar.xz
ipxe-95d82bb2a23bf645d995aed0d643cc34d5d8a3af.zip
[build] Avoid using -ffunction-sections on some older versions of gcc
Some older versions of gcc issue a warning if -ffunction-sections is used in combination with -g (gcc bug #18553). Inhibit -ffunction-sections when building with such a version of gcc. Reported-by: zhengwei <zw111_2001@126.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/Makefile.housekeeping')
-rw-r--r--src/Makefile.housekeeping10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
index 06f9e7ae..41c59562 100644
--- a/src/Makefile.housekeeping
+++ b/src/Makefile.housekeeping
@@ -450,14 +450,20 @@ 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.
+# implying -fno-common, which would break our build. Some other older
+# versions issue a spurious and uninhibitable warning if
+# -ffunction-sections is used with -g, which would also break our
+# build since we use -Werror.
#
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)
+FS_TEST = $(CC) -ffunction-sections -g -c -x c /dev/null \
+ -o /dev/null 2>/dev/null
+FS_FLAGS := $(shell $(FS_TEST) && $(ECHO) '-ffunction-sections')
+CFLAGS += $(FS_FLAGS) $(DS_FLAGS)
endif
LDFLAGS += --gc-sections