[PATCH] Only use -fno-zero-initialized-in-bss if it is available

Simon Horman horms at verge.net.au
Wed Oct 8 02:17:26 EDT 2008


As pointed out by Edgar E. Iglesias, the -fno-zero-initialized-in-bss
option to gcc is not available in the cris 3.2.1 toolchain.

Signed-off-by: Simon Horman <horms at verge.net.au>
---
 Makefile.in        |    1 +
 configure.ac       |   14 ++++++++++++++
 purgatory/Makefile |    6 +++---
 3 files changed, 18 insertions(+), 3 deletions(-)

I have applied this patch to the kexec-tools git tree.

diff --git a/Makefile.in b/Makefile.in
index f0621e1..6b4c954 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -46,6 +46,7 @@ TARGET_CFLAGS	= @TARGET_CFLAGS@
 CPPFLAGS	= @CPPFLAGS@ -I$(srcdir)/include -I$(srcdir)/util_lib/include \
 			-Iinclude/
 CFLAGS		= @CFLAGS@ -fno-strict-aliasing -Wall -Wstrict-prototypes
+PURGATORY_EXTRA_CFLAGS = @PURGATORY_EXTRA_CFLAGS@
 ASFLAGS		= @ASFLAGS@
 LDFLAGS		= @LDFLAGS@
 LIBS		= @LIBS@
diff --git a/configure.ac b/configure.ac
index c677334..5351d53 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,6 +7,7 @@ dnl ---Required
 AC_INIT(kexec-tools, 2.0.0-git)
 AC_CONFIG_AUX_DIR(./config)
 AC_CONFIG_HEADERS([include/config.h])
+AC_LANG(C)
 
 AC_DEFINE_UNQUOTED(PACKAGE_DATE, "19th July 2008",
 		[Define to the release date of this package])
@@ -105,6 +106,19 @@ else
 	TARGET_LD="$LD"
 fi
 
+AC_MSG_CHECKING([whether $TARGET_CC accepts -fno-zero-initialized-in-bss])
+saved_CFLAGS="$CFLAGS"
+saved_CC="$CC"
+CC="$TARGET_CC"
+CFLAGS="$CFLAGS -fno-zero-initialized-in-bss"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,,)],
+		  PURGATORY_EXTRA_CFLAGS="-fno-zero-initialized-in-bss"
+		  AC_MSG_RESULT([Yes]), AC_MSG_RESULT([No]))
+CFLAGS="$saved_CFLAGS"
+CC="$saved_CC"
+
+AC_SUBST(PURGATORY_EXTRA_CFLAGS, [$PURGATORY_EXTRA_CFLAGS])
+
 dnl Find the helper functions
 AC_PROG_INSTALL
 AC_CHECK_PROG([MKDIR],    mkdir,    mkdir,    "no", [$PATH])
diff --git a/purgatory/Makefile b/purgatory/Makefile
index ac58719..ceab269 100644
--- a/purgatory/Makefile
+++ b/purgatory/Makefile
@@ -45,9 +45,9 @@ purgatory/sha256.o: $(srcdir)/util_lib/sha256.c
 	$(COMPILE.c) -o $@ $^
 
 $(PURGATORY): CC=$(TARGET_CC)
-$(PURGATORY): CFLAGS+=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
-		      -Os -fno-builtin -ffreestanding \
-		      -fno-zero-initialized-in-bss
+$(PURGATORY): CFLAGS+=$(PURGATORY_EXTRA_CFLAGS) \
+		      $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
+		      -Os -fno-builtin -ffreestanding
 
 $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
 			-I$(srcdir)/purgatory/include \



More information about the kexec mailing list