Преглед изворни кода

[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>
tags/v1.20.1
Michael Brown пре 13 година
родитељ
комит
95d82bb2a2
1 измењених фајлова са 8 додато и 2 уклоњено
  1. 8
    2
      src/Makefile.housekeeping

+ 8
- 2
src/Makefile.housekeeping Прегледај датотеку

@@ -450,14 +450,20 @@ endif
450 450
 
451 451
 # Enable per-item sections and section garbage collection.  Note that
452 452
 # some older versions of gcc support -fdata-sections but treat it as
453
-# implying -fno-common, which would break our build.
453
+# implying -fno-common, which would break our build.  Some other older
454
+# versions issue a spurious and uninhibitable warning if
455
+# -ffunction-sections is used with -g, which would also break our
456
+# build since we use -Werror.
454 457
 #
455 458
 ifeq ($(CCTYPE),gcc)
456 459
 DS_TEST		= $(ECHO) 'char x;' | \
457 460
 		  $(CC) -fdata-sections -S -x c - -o - 2>/dev/null | \
458 461
 		  grep -E '\.comm' > /dev/null
459 462
 DS_FLAGS	:= $(shell $(DS_TEST) && $(ECHO) '-fdata-sections')
460
-CFLAGS		+= -ffunction-sections $(DS_FLAGS)
463
+FS_TEST		= $(CC) -ffunction-sections -g -c -x c /dev/null \
464
+		  -o /dev/null 2>/dev/null
465
+FS_FLAGS	:= $(shell $(FS_TEST) && $(ECHO) '-ffunction-sections')
466
+CFLAGS		+= $(FS_FLAGS) $(DS_FLAGS)
461 467
 endif
462 468
 LDFLAGS		+= --gc-sections
463 469
 

Loading…
Откажи
Сачувај