Patchwork [U-Boot] config.mk: enable -fstack-usage only when it is desired

login
register
mail settings
Submitter Masahiro Yamada
Date Sept. 26, 2013, 2:17 a.m.
Message ID <1380161866-12232-1-git-send-email-yamada.m@jp.panasonic.com>
Download mbox | patch
Permalink /patch/278085/
State Superseded
Delegated to: Tom Rini
Headers show

Comments

Masahiro Yamada - Sept. 26, 2013, 2:17 a.m.
As far as I know, gcc does not support -fstack-usage
for some targets such as blackfin, m68k, microblaze, etc.

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.

To suppress warnings for such targets that -fstack-usage is not supported,
this commit surrounds the concerned lines with
ifdef CONFIG_CC_STACKUSAGE .. endif.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
---
 config.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Tom Rini - Sept. 26, 2013, 11:52 a.m.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/25/2013 10:17 PM, Masahiro Yamada wrote:
> As far as I know, gcc does not support -fstack-usage
> for some targets such as blackfin, m68k, microblaze, etc.
> 
> 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.
> 
> To suppress warnings for such targets that -fstack-usage is not supported,
> this commit surrounds the concerned lines with
> ifdef CONFIG_CC_STACKUSAGE .. endif.
> 
> Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
> Cc: Tom Rini <trini@ti.com>

The problem here is that except for whatever arches don't support
- -fstack-usage, we always want to generate this information, to assist in
debugging stack usage problems (which can be a real problem within SPL
for example).  How about ifneq($(CONFIG_M68K)$(CONFIG_...),y) ... endif
around it?

- -- 
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJSRCAOAAoJENk4IS6UOR1WQ3AP/2kWJVnQqpMXUvX5XJ/jXzsW
tNx0Rj+JZcXgH8Nl4EAPj/oBQEA6H5Qnic0pEE9G8HpkrgEsCfqn9wAsbvN/8pCw
ZaU7zkORh4ieAz1w+ZJeJgx8rksxWNbVqFzttwDrOtvOK2s1WMLi7zfypw7DPoc/
ZPuvZJRHbbEFMqf9Y6Mo2smnM9uo+z+JnsNBio2Fau5A8VoZIaAI8Z2rob352oQ7
1MM2J1ncrmxEOO178CEbLD0dAJWqNZFNfpSZpfb/V+vYMaAMmCgYALXuBbue+JDy
PfeRxPD8iXiv5G40dQce0mjoUVDujnuOAlralaQBv0okegnGgF6ghf+bWt+sxTuT
h9/nY3i0ToRplsk2GKNAMVDNzonKBgk9BAz78ZVc6qMaLi6g9d8XVfXhoLLbWLPC
XEEZOYlflt6pnsybQjhux0UOm6hyy1moqll6GukEVmUWtYrMjimPLy2uKmeTdPbU
vnHOCcRHUD8SPBAyA9voOlwDJteusVH6FAsNoXLSSjnLI+vrBLhXTlUH/kRXMuA3
JRSLLBcwRi/VDxe0gWjSGbmTnOiWVKkg9nLNBdqMnqJI8vTYZjwDxJ50RLUQJWSq
N+kB3yZ/+ElhPi7vjJc8hy+sHUNfoVN1z6TyfY1fRxJfXXccDyBUE8eqEOWxBGg7
YldF9zwHiqjs2m/WuiIY
=YRCk
-----END PGP SIGNATURE-----
Michal Simek - Sept. 26, 2013, 2:32 p.m.
On 09/26/2013 01:52 PM, Tom Rini wrote:
> On 09/25/2013 10:17 PM, Masahiro Yamada wrote:
>> As far as I know, gcc does not support -fstack-usage
>> for some targets such as blackfin, m68k, microblaze, etc.

Please remove microblaze from this list.
Our gcc support fstack-usage.

If your microblaze gcc doesn't support this flag
then upgrade gcc version.

Thanks,
Michal
Masahiro Yamada - Sept. 27, 2013, 2:09 a.m.
Hello Tom.

> The problem here is that except for whatever arches don't support
> - -fstack-usage, we always want to generate this information, to assist in
> debugging stack usage problems (which can be a real problem within SPL
> for example).  How about ifneq($(CONFIG_M68K)$(CONFIG_...),y) ... endif
> around it?

OK. This works.

But I'm kind of afraid ifneq($(CONFIG_M68K)$(CONFIG_...),y) ... endif
might be too arch-specific to be written in the top config.mk.

Instead, we can add
CONFIG_CC_STACKUSAGE=y
to arch/{arm, powerpc, x86, microblaze ...}/config.mk



Best Regards
Masahiro Yamada
Masahiro Yamada - Sept. 27, 2013, 2:23 a.m.
Hello Michal

> Please remove microblaze from this list.
> Our gcc support fstack-usage.

I will. Thanks for helpful information!


> If your microblaze gcc doesn't support this flag
> then upgrade gcc version.

I tested microblaze-linux-gcc 4.8.0
I downloaded from ftp://ftp.kernel.org/pub/tools/crosstool/index.html

Can I get the prebuilt newer version at some download sites
or need to build from source code?


Best Regards
Masahiro Yamada
Michal Simek - Sept. 27, 2013, 8:13 a.m.
Hi,

David: Can you please tell to Masahiro where he can download
toolchain in any format which will support -fstack-usage.

I have microblazeel-xilinx-linux-gnu-gcc (crosstool-NG 1.18.0) 4.6.4 20120924 (prerelease)

Thanks,
Michal

On 09/27/2013 04:23 AM, Masahiro Yamada wrote:
> Hello Michal
> 
>> Please remove microblaze from this list.
>> Our gcc support fstack-usage.
> 
> I will. Thanks for helpful information!
> 
> 
>> If your microblaze gcc doesn't support this flag
>> then upgrade gcc version.
> 
> I tested microblaze-linux-gcc 4.8.0
> I downloaded from ftp://ftp.kernel.org/pub/tools/crosstool/index.html
> 
> Can I get the prebuilt newer version at some download sites
> or need to build from source code?
> 
> 
> Best Regards
> Masahiro Yamada
>

Patch

diff --git a/config.mk b/config.mk
index 48913f6..d405ab4 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)%=%))