]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: Linus Torvalds <torvalds@linux-foundation.org> |
2 | Date: Thu, 19 Mar 2009 18:10:17 +0000 (-0700) | |
3 | Subject: Add '-fwrapv' to gcc CFLAGS | |
4 | Patch-mainline: 2.6.29 | |
5 | Git-commit: 68df3755e383e6fecf2354a67b08f92f18536594 | |
6 | References: bko#12597 bnc#487106 | |
7 | ||
8 | Add '-fwrapv' to gcc CFLAGS | |
9 | ||
10 | This makes sure that gcc doesn't try to optimize away wrapping | |
11 | arithmetic, which the kernel occasionally uses for overflow testing, ie | |
12 | things like | |
13 | ||
14 | if (ptr + offset < ptr) | |
15 | ||
16 | which technically is undefined for non-unsigned types. See | |
17 | ||
18 | http://bugzilla.kernel.org/show_bug.cgi?id=12597 | |
19 | ||
20 | for details. | |
21 | ||
22 | Not all versions of gcc support it, so we need to make it conditional | |
23 | (it looks like it was introduced in gcc-3.4). | |
24 | ||
25 | Reminded-by: Alan Cox <alan@lxorguk.ukuu.org.uk> | |
26 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | |
27 | Acked-by: Jeff Mahoney <jeffm@suse.com> | |
28 | --- | |
29 | ||
30 | Makefile | 1 + | |
31 | 1 file changed, 1 insertion(+) | |
32 | ||
33 | --- a/Makefile | |
34 | +++ b/Makefile | |
35 | @@ -341,6 +341,7 @@ KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXI | |
36 | KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ | |
37 | -fno-strict-aliasing -fno-common \ | |
38 | -Werror-implicit-function-declaration | |
39 | +KBUILD_CFLAGS += $(call cc-option,-fwrapv) | |
40 | KBUILD_AFLAGS := -D__ASSEMBLY__ | |
41 | ||
42 | # Warn about unsupported modules in kernels built inside Autobuild |