Commit 35bb5b1e0e84cfa1a8906f7e6a77f391ff315791

Authored by Andi Kleen
Committed by Sam Ravnborg
1 parent 80ff262416

Add option to enable -Wframe-larger-than= on gcc 4.4

Add option to enable -Wframe-larger-than= on gcc 4.4

gcc mainline (upcoming 4.4) added a new -Wframe-larger-than=...
option to warn at build time about too large stack frames. Add a config
option to enable this warning, since this very useful for the kernel.

I choose (somewhat arbitarily) 2048 as default warning threshold for 64bit
and 1024 as default for 32bit architectures.  With some research and
fixing all the code for smaller values these defaults should be probably
lowered.

With the default allyesconfigs have some new warnings, but I think
that is all code that should be just fixed.

At some point (when gcc 4.4 is released and widely used) this should
obsolete make checkstack

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Showing 2 changed files with 15 additions and 0 deletions Side-by-side Diff

... ... @@ -507,6 +507,10 @@
507 507 KBUILD_CFLAGS += -O2
508 508 endif
509 509  
  510 +ifneq (CONFIG_FRAME_WARN,0)
  511 +KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
  512 +endif
  513 +
510 514 # Force gcc to behave correct even for buggy distributions
511 515 # Arch Makefiles may override this setting
512 516 KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
... ... @@ -25,6 +25,17 @@
25 25 suppress the "warning: ignoring return value of 'foo', declared with
26 26 attribute warn_unused_result" messages.
27 27  
  28 +config FRAME_WARN
  29 + int "Warn for stack frames larger than (needs gcc 4.4)"
  30 + range 0 8192
  31 + default 1024 if !64BIT
  32 + default 2048 if 64BIT
  33 + help
  34 + Tell gcc to warn at build time for stack frames larger than this.
  35 + Setting this too low will cause a lot of warnings.
  36 + Setting it to 0 disables the warning.
  37 + Requires gcc 4.4
  38 +
28 39 config MAGIC_SYSRQ
29 40 bool "Magic SysRq key"
30 41 depends on !UML