[U-Boot] [PATCH v2] config.mk: disable -fstack-usage for blackfin and m68k

Masahiro Yamada yamada.m at jp.panasonic.com
Tue Oct 15 10:24:17 CEST 2013


Currently gcc does not seem to support -fstack-usage option
for some targets, such as blackfin and m68k.

If -fstack-usage option is given for those targets,
gcc displays a warning message as follows:

    warning: -fstack-usage not supported for this target [enabled by default]

But it still exits with status 0.

So,

    # Report stack usage if supported
    CFLAGS_STACK := $(call cc-option,-fstack-usage)
    CFLAGS += $(CFLAGS_STACK)

does not work as we expect because cc-option sees exit status
to judge whether the given option is supported or not.

Adding -Werror option to cc-option function does not work either,
because gcc always succeeds in compiling /dev/null input
with -fstack-usage option.
We cannot rely on cc-option.

To suppress warnings for such targets that -fstack-usage is not supported,
this commit surrounds the concerned lines with
ifdef CONFIG_CC_STACKUSAGE .. endif.
And it adds CONFIG_CC_STACKUSAGE=y to arch/${ARCH}/config.mk
except blackfin and m68k.

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>
---
 arch/arm/config.mk        | 2 ++
 arch/avr32/config.mk      | 2 ++
 arch/microblaze/config.mk | 2 ++
 arch/mips/config.mk       | 2 ++
 arch/nds32/config.mk      | 2 ++
 arch/nios2/config.mk      | 2 ++
 arch/openrisc/config.mk   | 2 ++
 arch/powerpc/config.mk    | 2 ++
 arch/sandbox/config.mk    | 2 ++
 arch/sh/config.mk         | 2 ++
 arch/sparc/config.mk      | 2 ++
 arch/x86/config.mk        | 2 ++
 config.mk                 | 6 +++---
 13 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index bdabcf4..f63336d 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -103,3 +103,5 @@ ALL-y += checkarmreloc
 # such usage by requiring word relocations.
 PLATFORM_CPPFLAGS += $(call cc-option, -mword-relocations)
 endif
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/arch/avr32/config.mk b/arch/avr32/config.mk
index 4ab4745..39776fc 100644
--- a/arch/avr32/config.mk
+++ b/arch/avr32/config.mk
@@ -13,3 +13,5 @@ PLATFORM_RELFLAGS	+= -ffixed-r5 -fPIC -mno-init-got -mrelax
 PLATFORM_RELFLAGS	+= -ffunction-sections -fdata-sections
 
 LDFLAGS_u-boot		= --gc-sections --relax
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/arch/microblaze/config.mk b/arch/microblaze/config.mk
index fc545a9..84a2325 100644
--- a/arch/microblaze/config.mk
+++ b/arch/microblaze/config.mk
@@ -15,3 +15,5 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000
 PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__
 
 LDSCRIPT ?= $(SRCTREE)/$(CPUDIR)/u-boot.lds
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/arch/mips/config.mk b/arch/mips/config.mk
index c3f81b5..c182956 100644
--- a/arch/mips/config.mk
+++ b/arch/mips/config.mk
@@ -51,3 +51,5 @@ PLATFORM_LDFLAGS		+= -G 0 -static -n -nostdlib $(ENDIANNESS)
 PLATFORM_RELFLAGS		+= -ffunction-sections -fdata-sections
 LDFLAGS_FINAL			+= --gc-sections -pie
 OBJCFLAGS			+= --remove-section=.dynsym
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/arch/nds32/config.mk b/arch/nds32/config.mk
index e93e3a8..97cb937 100644
--- a/arch/nds32/config.mk
+++ b/arch/nds32/config.mk
@@ -17,3 +17,5 @@ PLATFORM_RELFLAGS	+= -gdwarf-2
 PLATFORM_CPPFLAGS	+= -DCONFIG_NDS32 -D__nds32__ -G0 -ffixed-10 -fpie
 
 LDFLAGS_u-boot		= --gc-sections --relax
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/arch/nios2/config.mk b/arch/nios2/config.mk
index 7d546ef..7ca6323 100644
--- a/arch/nios2/config.mk
+++ b/arch/nios2/config.mk
@@ -15,3 +15,5 @@ PLATFORM_CPPFLAGS += -G0
 
 LDFLAGS_FINAL += --gc-sections
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/arch/openrisc/config.mk b/arch/openrisc/config.mk
index 13015eb..8694c1c 100644
--- a/arch/openrisc/config.mk
+++ b/arch/openrisc/config.mk
@@ -14,3 +14,5 @@ PLATFORM_CPPFLAGS += -DCONFIG_OPENRISC -D__OR1K__ -ffixed-r10
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
 
 LDSCRIPT ?= $(SRCTREE)/$(CPUDIR)/u-boot.lds
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk
index e6bb935..33fcc16 100644
--- a/arch/powerpc/config.mk
+++ b/arch/powerpc/config.mk
@@ -34,3 +34,5 @@ endif
 ifneq ($(CONFIG_SPL_BUILD),y)
 ALL-y += checkgcc4
 endif
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index 6142dd4..49919f9 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -7,3 +7,5 @@ PLATFORM_LIBS += -lrt
 
 # Support generic board on sandbox
 __HAVE_ARCH_GENERIC_BOARD := y
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/arch/sh/config.mk b/arch/sh/config.mk
index 758c070..10da053 100644
--- a/arch/sh/config.mk
+++ b/arch/sh/config.mk
@@ -15,3 +15,5 @@ endif
 PLATFORM_CPPFLAGS += -DCONFIG_SH -D__SH__
 PLATFORM_LDFLAGS += -e $(CONFIG_SYS_TEXT_BASE) --defsym reloc_dst=$(CONFIG_SYS_TEXT_BASE)
 LDFLAGS_FINAL = --gc-sections
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/arch/sparc/config.mk b/arch/sparc/config.mk
index e94e7cb..c7a1b89 100644
--- a/arch/sparc/config.mk
+++ b/arch/sparc/config.mk
@@ -10,3 +10,5 @@ CROSS_COMPILE ?= sparc-elf-
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 -L $(gcclibdir) -T sparc.lds
 
 PLATFORM_CPPFLAGS += -DCONFIG_SPARC -D__sparc__
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index b22959f..3a3b723 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -35,3 +35,5 @@ NORMAL_LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
 PREFIXED_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/$(shell basename $(NORMAL_LIBGCC))
 
 export USE_PRIVATE_LIBGCC=$(shell dirname $(PREFIXED_LIBGCC))
+
+CONFIG_CC_STACKUSAGE=y
diff --git a/config.mk b/config.mk
index 3441387..811c10f 100644
--- a/config.mk
+++ b/config.mk
@@ -278,9 +278,9 @@ CFLAGS_WARN := $(call cc-option,-Wno-format-nonliteral) \
 	       $(call cc-option,-Wno-format-security)
 CFLAGS += $(CFLAGS_WARN)
 
-# Report stack usage if supported
-CFLAGS_STACK := $(call cc-option,-fstack-usage)
-CFLAGS += $(CFLAGS_STACK)
+ifdef CONFIG_CC_STACKUSAGE
+CFLAGS += $(call cc-option,-fstack-usage)
+endif
 
 BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
 
-- 
1.8.1.2



More information about the U-Boot mailing list