[ar71xx] update kernel config
[openwrt.git] / toolchain / gcc / patches / 4.2.4 / 910-mbsd_multi.patch
1
2 This patch brings over a few features from MirBSD:
3 * -fhonour-copts
4 If this option is not given, it's warned (depending
5 on environment variables). This is to catch errors
6 of misbuilt packages which override CFLAGS themselves.
7 * -Werror-maybe-reset
8 Has the effect of -Wno-error if GCC_NO_WERROR is
9 set and not '0', a no-operation otherwise. This is
10 to be able to use -Werror in "make" but prevent
11 GNU autoconf generated configure scripts from
12 freaking out.
13 * Make -fno-strict-aliasing and -fno-delete-null-pointer-checks
14 the default for -O2/-Os, because they trigger gcc bugs
15 and can delete code with security implications.
16
17 This patch was authored by Thorsten Glaser <tg@mirbsd.de>
18 with copyright assignment to the FSF in effect.
19
20 Index: gcc-4.2.3/gcc/c-opts.c
21 ===================================================================
22 --- gcc-4.2.3.orig/gcc/c-opts.c 2008-01-27 19:36:59.000000000 +0100
23 +++ gcc-4.2.3/gcc/c-opts.c 2008-05-21 13:46:01.550289703 +0200
24 @@ -106,6 +106,9 @@
25 /* Number of deferred options scanned for -include. */
26 static size_t include_cursor;
27
28 +/* Check if a port honours COPTS. */
29 +static int honour_copts = 0;
30 +
31 static void set_Wimplicit (int);
32 static void handle_OPT_d (const char *);
33 static void set_std_cxx98 (int);
34 @@ -450,6 +453,14 @@
35 mesg_implicit_function_declaration = 2;
36 break;
37
38 + case OPT_Werror_maybe_reset:
39 + {
40 + char *ev = getenv ("GCC_NO_WERROR");
41 + if ((ev != NULL) && (*ev != '0'))
42 + cpp_opts->warnings_are_errors = 0;
43 + }
44 + break;
45 +
46 case OPT_Wformat:
47 set_Wformat (value);
48 break;
49 @@ -692,6 +703,12 @@
50 flag_exceptions = value;
51 break;
52
53 + case OPT_fhonour_copts:
54 + if (c_language == clk_c) {
55 + honour_copts++;
56 + }
57 + break;
58 +
59 case OPT_fimplement_inlines:
60 flag_implement_inlines = value;
61 break;
62 @@ -1157,6 +1174,47 @@
63 /* Has to wait until now so that cpplib has its hash table. */
64 init_pragma ();
65
66 + if (c_language == clk_c) {
67 + char *ev = getenv ("GCC_HONOUR_COPTS");
68 + int evv;
69 + if (ev == NULL)
70 + evv = -1;
71 + else if ((*ev == '0') || (*ev == '\0'))
72 + evv = 0;
73 + else if (*ev == '1')
74 + evv = 1;
75 + else if (*ev == '2')
76 + evv = 2;
77 + else if (*ev == 's')
78 + evv = -1;
79 + else {
80 + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
81 + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
82 + }
83 + if (evv == 1) {
84 + if (honour_copts == 0) {
85 + error ("someone does not honour COPTS at all in lenient mode");
86 + return false;
87 + } else if (honour_copts != 1) {
88 + warning (0, "someone does not honour COPTS correctly, passed %d times",
89 + honour_copts);
90 + }
91 + } else if (evv == 2) {
92 + if (honour_copts == 0) {
93 + error ("someone does not honour COPTS at all in strict mode");
94 + return false;
95 + } else if (honour_copts != 1) {
96 + error ("someone does not honour COPTS correctly, passed %d times",
97 + honour_copts);
98 + return false;
99 + }
100 + } else if (evv == 0) {
101 + if (honour_copts != 1)
102 + inform ("someone does not honour COPTS correctly, passed %d times",
103 + honour_copts);
104 + }
105 + }
106 +
107 return true;
108 }
109
110 Index: gcc-4.2.3/gcc/c.opt
111 ===================================================================
112 --- gcc-4.2.3.orig/gcc/c.opt 2007-09-01 17:28:30.000000000 +0200
113 +++ gcc-4.2.3/gcc/c.opt 2008-05-21 13:46:01.550289703 +0200
114 @@ -188,6 +188,10 @@
115 C ObjC RejectNegative
116 Make implicit function declarations an error
117
118 +Werror-maybe-reset
119 +C ObjC C++ ObjC++
120 +; Documented in common.opt
121 +
122 Wfloat-equal
123 C ObjC C++ ObjC++ Var(warn_float_equal)
124 Warn if testing floating point numbers for equality
125 @@ -543,6 +547,9 @@
126 fhonor-std
127 C++ ObjC++
128
129 +fhonour-copts
130 +C ObjC C++ ObjC++ RejectNegative
131 +
132 fhosted
133 C ObjC
134 Assume normal C execution environment
135 Index: gcc-4.2.3/gcc/common.opt
136 ===================================================================
137 --- gcc-4.2.3.orig/gcc/common.opt 2008-01-27 19:36:59.000000000 +0100
138 +++ gcc-4.2.3/gcc/common.opt 2008-05-21 13:46:01.550289703 +0200
139 @@ -80,6 +80,10 @@
140 Common Joined
141 Treat specified warning as error
142
143 +Werror-maybe-reset
144 +Common
145 +If environment variable GCC_NO_WERROR is set, act as -Wno-error
146 +
147 Wextra
148 Common
149 Print extra (possibly unwanted) warnings
150 @@ -480,6 +484,9 @@
151 Common Report Var(flag_guess_branch_prob)
152 Enable guessing of branch probabilities
153
154 +fhonour-copts
155 +Common RejectNegative
156 +
157 ; Nonzero means ignore `#ident' directives. 0 means handle them.
158 ; Generate position-independent code for executables if possible
159 ; On SVR4 targets, it also controls whether or not to emit a
160 Index: gcc-4.2.3/gcc/opts.c
161 ===================================================================
162 --- gcc-4.2.3.orig/gcc/opts.c 2008-01-27 19:36:59.000000000 +0100
163 +++ gcc-4.2.3/gcc/opts.c 2008-05-21 13:46:01.562288718 +0200
164 @@ -483,9 +483,6 @@
165 flag_schedule_insns_after_reload = 1;
166 #endif
167 flag_regmove = 1;
168 - flag_strict_aliasing = 1;
169 - flag_strict_overflow = 1;
170 - flag_delete_null_pointer_checks = 1;
171 flag_reorder_blocks = 1;
172 flag_reorder_functions = 1;
173 flag_tree_store_ccp = 1;
174 @@ -501,6 +498,10 @@
175
176 if (optimize >= 3)
177 {
178 + flag_strict_aliasing = 1;
179 + flag_strict_overflow = 1;
180 + flag_delete_null_pointer_checks = 1;
181 +
182 flag_inline_functions = 1;
183 flag_unswitch_loops = 1;
184 flag_gcse_after_reload = 1;
185 @@ -702,6 +703,17 @@
186 }
187 break;
188
189 + case OPT_Werror_maybe_reset:
190 + {
191 + char *ev = getenv ("GCC_NO_WERROR");
192 + if ((ev != NULL) && (*ev != '0'))
193 + warnings_are_errors = 0;
194 + }
195 + break;
196 +
197 + case OPT_fhonour_copts:
198 + break;
199 +
200 case OPT_Wextra:
201 set_Wextra (value);
202 break;
203 Index: gcc-4.2.3/gcc/doc/cppopts.texi
204 ===================================================================
205 --- gcc-4.2.3.orig/gcc/doc/cppopts.texi 2006-08-16 22:36:23.000000000 +0200
206 +++ gcc-4.2.3/gcc/doc/cppopts.texi 2008-05-21 13:46:01.570286943 +0200
207 @@ -166,6 +166,11 @@
208 Make all warnings into hard errors. Source code which triggers warnings
209 will be rejected.
210
211 +@item -Werror-maybe-reset
212 +@opindex Werror-maybe-reset
213 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
214 +variable is set to anything other than 0 or empty.
215 +
216 @item -Wsystem-headers
217 @opindex Wsystem-headers
218 Issue warnings for code in system headers. These are normally unhelpful
219 Index: gcc-4.2.3/gcc/doc/invoke.texi
220 ===================================================================
221 --- gcc-4.2.3.orig/gcc/doc/invoke.texi 2008-05-21 13:45:54.274288067 +0200
222 +++ gcc-4.2.3/gcc/doc/invoke.texi 2008-05-21 13:46:01.582288192 +0200
223 @@ -226,7 +226,7 @@
224 -Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
225 -Wconversion -Wno-deprecated-declarations @gol
226 -Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels @gol
227 --Werror -Werror=* -Werror-implicit-function-declaration @gol
228 +-Werror -Werror-maybe-reset -Werror=* -Werror-implicit-function-declaration @gol
229 -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
230 -Wno-format-extra-args -Wformat-nonliteral @gol
231 -Wformat-security -Wformat-y2k @gol
232 @@ -3566,6 +3566,22 @@
233 @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
234 imply anything.
235
236 +@item -Werror-maybe-reset
237 +@opindex Werror-maybe-reset
238 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
239 +variable is set to anything other than 0 or empty.
240 +
241 +@item -fhonour-copts
242 +@opindex fhonour-copts
243 +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
244 +given at least once, and warn if it is given more than once.
245 +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
246 +given exactly once.
247 +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
248 +is not given exactly once.
249 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
250 +This flag and environment variable only affect the C language.
251 +
252 @item -Wstack-protector
253 @opindex Wstack-protector
254 This option is only active when @option{-fstack-protector} is active. It
255 @@ -4893,7 +4909,7 @@
256 second branch or a point immediately following it, depending on whether
257 the condition is known to be true or false.
258
259 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
260 +Enabled at levels @option{-O3}.
261
262 @item -fcse-follow-jumps
263 @opindex fcse-follow-jumps
264 @@ -5011,7 +5027,7 @@
265 @option{-fno-delete-null-pointer-checks} to disable this optimization
266 for programs which depend on that behavior.
267
268 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
269 +Enabled at levels @option{-O3}.
270
271 @item -fexpensive-optimizations
272 @opindex fexpensive-optimizations
273 @@ -5460,7 +5476,7 @@
274 allowed to alias. For an example, see the C front-end function
275 @code{c_get_alias_set}.
276
277 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
278 +Enabled at levels @option{-O3}.
279
280 @item -fstrict-overflow
281 @opindex fstrict-overflow
282 Index: gcc-4.2.3/gcc/java/jvspec.c
283 ===================================================================
284 --- gcc-4.2.3.orig/gcc/java/jvspec.c 2007-08-31 10:27:50.000000000 +0200
285 +++ gcc-4.2.3/gcc/java/jvspec.c 2008-05-21 13:46:01.582288192 +0200
286 @@ -631,6 +631,7 @@
287 class name. Append dummy `.c' that can be stripped by set_input so %b
288 is correct. */
289 set_input (concat (main_class_name, "main.c", NULL));
290 + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
291 err = do_spec (jvgenmain_spec);
292 if (err == 0)
293 {
This page took 0.062582 seconds and 5 git commands to generate.