config.mk: fix -fstack-usage support test
PATCH v3 1/1 config.mk: fix -fstack-usage support test
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,...) .
--- config.mk | 5 +++-- scripts/gcc-stack-usage.sh | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100755 scripts/gcc-stack-usage.sh
config.mk +3 -2
@@ -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)%=%))
scripts/gcc-stack-usage.sh new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/sh +# Test for gcc '-fstack-usage' support +# Copyright (C) 2013, Masahiro Yamada <[email protected]> +# +# 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
Signature · 1 line
1.8.1.2
PATCH v3 1/1 config.mk: fix -fstack-usage support test
Hi Masahiro,
Quoted 6 lines · Masahiro Yamada
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,...) .
Much better than the previous one (with a nitpick: superfluous "s" in "This commits")... But now we lack the rationale part, which was dropped rather than moved after the '---' line.
Regarding the patch itself, why a shell script rather than a variant of cc-option?
Quoted 41 lines
Signed-off-by Masahiro Yamada <[email protected]>Cc Tom Rini <[email protected]>Cc Michal Simek <[email protected]>Cc Jeroen Hofstee <[email protected]>Cc Albert ARIBAUD <[email protected]>--- config.mk | 5 +++-- scripts/gcc-stack-usage.sh | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100755 scripts/gcc-stack-usage.shconfig.mk +3
-2@@ -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)%=%))scripts/gcc-stack-usage.sh new file +8
-0@@ -0,0 +1,18 @@ +#!/bin/sh +# Test for gcc '-fstack-usage' support +# Copyright (C) 2013, Masahiro Yamada <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +TMP=${OBJTREE}/"$$"
scripts/gcc-stack-usage.sh line 18
Quoted 10 lines
scripts/gcc-stack-usage.sh new file +10
-0+ +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
Amicalement,
Signature · 1 line
Albert.
PATCH v3 1/1 config.mk: fix -fstack-usage support test
Hello Albert
Quoted 3 lines
Much better than the previous one (with a nitpick: superfluous "s" in "This commits")... But now we lack the rationale part, which was dropped rather than moved after the '---' line.
I will add the rationale part in v4 along with s/commits/commit/. Thanks.
Quoted 2 lines
Regarding the patch itself, why a shell script rather than a variant of cc-option?
We cannot simply test -fstack-option support by $(call cc-option,...)
This was mentioned in version 1 discussion,
(I should have written this below the '---')
Quoted 11 lines
So, I looked into it more closely and
I found gcc can compile the input file/dev/nullsuccessfully even if -fstack-usage is not supported.$ bfin-uclinux-gcc -fstack-usage -S -xc /dev/null $ echo $? 0 $ bfin-uclinux-gcc -Werror -fstack-usage -S -xc /dev/null $ echo $? 0
I chose a shell script because I wanted to keep Makefile cleaner and this is the way Linux Kernel often uses.
Please refer to
- scripts/gcc-goto.sh
- scripts/gcc-version.sh
etc. of Linux Kernel.
Best Regards
Masahiro Yamada
PATCH v3 1/1 config.mk: fix -fstack-usage support test
Hi Masahiro,
Quoted 10 lines
Quoted 2 lines
Regarding the patch itself, why a shell script rather than a variant of cc-option?
I chose a shell script because I wanted to keep
Makefilecleaner and this is the way Linux Kernel often uses.Please refer to
-scripts/gcc-goto.sh
-scripts/gcc-version.sh
etc. of Linux Kernel.
Understood, thanks.
Quoted 2 lines
Best Regards
Masahiro Yamada
Amicalement,
Signature · 1 line
Albert.