[U-Boot] [PATCH v3] config.mk: fix -fstack-usage support test

Masahiro Yamada yamada.m at jp.panasonic.com
Tue Oct 15 12:11:26 CEST 2013


If -fstack-usage option is given for such architecures
that do not support it, gcc displays a warning message
but still exits with status 0.

This commits adds a new scripts to test -fstack-usage support
because we cannot rely on $(call cc-option,...) .

Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
Cc: Tom Rini <trini at ti.com>
Cc: Michal Simek <monstr at monstr.eu>
Cc: Jeroen Hofstee <jeroen at myspectrum.nl>
Cc: Albert ARIBAUD <albert.u.boot at aribaud.net>
---
 config.mk                  |  5 +++--
 scripts/gcc-stack-usage.sh | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100755 scripts/gcc-stack-usage.sh

diff --git a/config.mk b/config.mk
index 3441387..8a82ab4 100644
--- a/config.mk
+++ b/config.mk
@@ -279,8 +279,9 @@ CFLAGS_WARN := $(call cc-option,-Wno-format-nonliteral) \
 CFLAGS += $(CFLAGS_WARN)
 
 # Report stack usage if supported
-CFLAGS_STACK := $(call cc-option,-fstack-usage)
-CFLAGS += $(CFLAGS_STACK)
+ifeq ($(shell $(SHELL) $(SRCTREE)/scripts/gcc-stack-usage.sh $(CC)), y)
+	CFLAGS += -fstack-usage
+endif
 
 BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
 
diff --git a/scripts/gcc-stack-usage.sh b/scripts/gcc-stack-usage.sh
new file mode 100755
index 0000000..53eb10a
--- /dev/null
+++ b/scripts/gcc-stack-usage.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Test for gcc '-fstack-usage' support
+# Copyright (C) 2013, Masahiro Yamada <yamada.m at jp.panasonic.com>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+TMP=${OBJTREE}/"$$"
+
+cat << "END" | $@ -Werror -fstack-usage -x c - -c -o $TMP >/dev/null 2>&1 \
+							&& echo "y"
+int main(void)
+{
+	return 0;
+}
+END
+
+rm -f $TMP $TMP.su
-- 
1.8.1.2



More information about the U-Boot mailing list