]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Avoid using -ffunction-sections on some older versions of gcc
authorMichael Brown <mcb30@ipxe.org>
Wed, 29 Jun 2011 10:42:07 +0000 (11:42 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 29 Jun 2011 10:48:29 +0000 (11:48 +0100)
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>
src/Makefile.housekeeping

index 06f9e7aeece24ff4488949a3d779727aeaef4374..41c59562863da8384a656275bd3df0e46a89e0c8 100644 (file)
@@ -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