config.mk: disable -fstack-usage for blackfin and m68k
Subsystems (9)
PATCH v2 1/1 config.mk: disable -fstack-usage for blackfin and m68k
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.
--- 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(-)
arch/arm/config.mk +2 -0
@@ -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
arch/avr32/config.mk +2 -0
@@ -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
arch/microblaze/config.mk +2 -0
@@ -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
arch/mips/config.mk +2 -0
@@ -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
arch/nds32/config.mk +2 -0
@@ -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
arch/nios2/config.mk +2 -0
@@ -15,3 +15,5 @@ PLATFORM_CPPFLAGS += -G0 LDFLAGS_FINAL += --gc-sections PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections + +CONFIG_CC_STACKUSAGE=y
arch/openrisc/config.mk +2 -0
@@ -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
arch/powerpc/config.mk +2 -0
@@ -34,3 +34,5 @@ endif ifneq ($(CONFIG_SPL_BUILD),y) ALL-y += checkgcc4 endif + +CONFIG_CC_STACKUSAGE=y
arch/sandbox/config.mk +2 -0
@@ -7,3 +7,5 @@ PLATFORM_LIBS += -lrt # Support generic board on sandbox __HAVE_ARCH_GENERIC_BOARD := y + +CONFIG_CC_STACKUSAGE=y
arch/sh/config.mk +2 -0
@@ -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
arch/sparc/config.mk +2 -0
@@ -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
arch/x86/config.mk +2 -0
@@ -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
config.mk +3 -3
@@ -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)%=%))
Signature · 1 line
1.8.1.2
PATCH v2 1/1 config.mk: disable -fstack-usage for blackfin and m68k
Hi Masahiro,
Quoted 24 lines · Masahiro Yamada
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/nullinput with -fstack-usage option.
We cannot rely on cc-option.
Quoted 5 lines
To suppress warnings for such targets that -fstack-usage is not supported, this commit surrounds the concerned lines with
ifdefCONFIG_CC_STACKUSAGE.. endif.
And it addsCONFIG_CC_STACKUSAGE=ytoarch/${ARCH}/config.mkexcept blackfin and m68k.
Please keep the commit message to a (short) description of the patch, and move the rationale to a comment below the '---' line.
Also: what is the benefit of creating an elaborate mechanism to hide a warning message that says the option is useless, IOW, wouldn't it be simpler to only specify -fstack-usage to the arches that support it?
Amicalement,
Signature · 1 line
Albert.
PATCH v2 1/1 config.mk: disable -fstack-usage for blackfin and m68k
Hello.
After I posted v2, I changed my mind.
Adding a new script to test -fstack-usage support
seems smarter, I think.
I posted version 3
config.mk: fix -fstack-usage support test
Quoted 2 lines
Please keep the commit message to a (short) description of the patch, and move the rationale to a comment below the '---' line.
Albert,
When posting a patch
I keep it in my mind to describe the reason or background in as much detail as possible especially when it is not clear at a glance.
A comment below the '---' line is dropped after the patch is applied.
But I understand what you said.
I posted v3 and I kept its commit message in short. Better?
Best Regards
Masahiro Yamada