[tools] disable mpfr tests compilation, slightly speeds up the build process
[openwrt.git] / toolchain / gcc / patches / 4.1.2 / 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 --- a/gcc/c-opts.c
21 +++ b/gcc/c-opts.c
22 @@ -103,6 +103,9 @@ static size_t deferred_count;
23 /* Number of deferred options scanned for -include. */
24 static size_t include_cursor;
25
26 +/* Check if a port honours COPTS. */
27 +static int honour_copts = 0;
28 +
29 static void set_Wimplicit (int);
30 static void handle_OPT_d (const char *);
31 static void set_std_cxx98 (int);
32 @@ -448,6 +451,14 @@ c_common_handle_option (size_t scode, co
33 mesg_implicit_function_declaration = 2;
34 break;
35
36 + case OPT_Werror_maybe_reset:
37 + {
38 + char *ev = getenv ("GCC_NO_WERROR");
39 + if ((ev != NULL) && (*ev != '0'))
40 + cpp_opts->warnings_are_errors = 0;
41 + }
42 + break;
43 +
44 case OPT_Wformat:
45 set_Wformat (value);
46 break;
47 @@ -691,6 +702,12 @@ c_common_handle_option (size_t scode, co
48 flag_exceptions = value;
49 break;
50
51 + case OPT_fhonour_copts:
52 + if (c_language == clk_c) {
53 + honour_copts++;
54 + }
55 + break;
56 +
57 case OPT_fimplement_inlines:
58 flag_implement_inlines = value;
59 break;
60 @@ -1121,6 +1138,47 @@ c_common_init (void)
61 /* Has to wait until now so that cpplib has its hash table. */
62 init_pragma ();
63
64 + if (c_language == clk_c) {
65 + char *ev = getenv ("GCC_HONOUR_COPTS");
66 + int evv;
67 + if (ev == NULL)
68 + evv = -1;
69 + else if ((*ev == '0') || (*ev == '\0'))
70 + evv = 0;
71 + else if (*ev == '1')
72 + evv = 1;
73 + else if (*ev == '2')
74 + evv = 2;
75 + else if (*ev == 's')
76 + evv = -1;
77 + else {
78 + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
79 + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
80 + }
81 + if (evv == 1) {
82 + if (honour_copts == 0) {
83 + error ("someone does not honour COPTS at all in lenient mode");
84 + return false;
85 + } else if (honour_copts != 1) {
86 + warning (0, "someone does not honour COPTS correctly, passed %d times",
87 + honour_copts);
88 + }
89 + } else if (evv == 2) {
90 + if (honour_copts == 0) {
91 + error ("someone does not honour COPTS at all in strict mode");
92 + return false;
93 + } else if (honour_copts != 1) {
94 + error ("someone does not honour COPTS correctly, passed %d times",
95 + honour_copts);
96 + return false;
97 + }
98 + } else if (evv == 0) {
99 + if (honour_copts != 1)
100 + inform ("someone does not honour COPTS correctly, passed %d times",
101 + honour_copts);
102 + }
103 + }
104 +
105 return true;
106 }
107
108 --- a/gcc/c.opt
109 +++ b/gcc/c.opt
110 @@ -185,6 +185,10 @@ Werror-implicit-function-declaration
111 C ObjC RejectNegative
112 Make implicit function declarations an error
113
114 +Werror-maybe-reset
115 +C ObjC C++ ObjC++
116 +; Documented in common.opt
117 +
118 Wfloat-equal
119 C ObjC C++ ObjC++ Var(warn_float_equal)
120 Warn if testing floating point numbers for equality
121 @@ -541,6 +545,9 @@ C++ ObjC++
122 fhonor-std
123 C++ ObjC++
124
125 +fhonour-copts
126 +C ObjC C++ ObjC++ RejectNegative
127 +
128 fhosted
129 C ObjC
130 Assume normal C execution environment
131 --- a/gcc/common.opt
132 +++ b/gcc/common.opt
133 @@ -77,6 +77,10 @@ Werror
134 Common Var(warnings_are_errors)
135 Treat all warnings as errors
136
137 +Werror-maybe-reset
138 +Common
139 +If environment variable GCC_NO_WERROR is set, act as -Wno-error
140 +
141 Wextra
142 Common
143 Print extra (possibly unwanted) warnings
144 @@ -451,6 +455,9 @@ fguess-branch-probability
145 Common Report Var(flag_guess_branch_prob)
146 Enable guessing of branch probabilities
147
148 +fhonour-copts
149 +Common RejectNegative
150 +
151 ; Nonzero means ignore `#ident' directives. 0 means handle them.
152 ; Generate position-independent code for executables if possible
153 ; On SVR4 targets, it also controls whether or not to emit a
154 --- a/gcc/opts.c
155 +++ b/gcc/opts.c
156 @@ -569,8 +569,6 @@ decode_options (unsigned int argc, const
157 flag_schedule_insns_after_reload = 1;
158 #endif
159 flag_regmove = 1;
160 - flag_strict_aliasing = 1;
161 - flag_delete_null_pointer_checks = 1;
162 flag_reorder_blocks = 1;
163 flag_reorder_functions = 1;
164 flag_tree_store_ccp = 1;
165 @@ -586,6 +584,9 @@ decode_options (unsigned int argc, const
166
167 if (optimize >= 3)
168 {
169 + flag_strict_aliasing = 1;
170 + flag_delete_null_pointer_checks = 1;
171 +
172 flag_inline_functions = 1;
173 flag_unswitch_loops = 1;
174 flag_gcse_after_reload = 1;
175 @@ -759,6 +760,17 @@ common_handle_option (size_t scode, cons
176 set_Wextra (value);
177 break;
178
179 + case OPT_Werror_maybe_reset:
180 + {
181 + char *ev = getenv ("GCC_NO_WERROR");
182 + if ((ev != NULL) && (*ev != '0'))
183 + warnings_are_errors = 0;
184 + }
185 + break;
186 +
187 + case OPT_fhonour_copts:
188 + break;
189 +
190 case OPT_Wextra:
191 set_Wextra (value);
192 break;
193 --- a/gcc/doc/cppopts.texi
194 +++ b/gcc/doc/cppopts.texi
195 @@ -166,6 +166,11 @@ in older programs. This warning is on b
196 Make all warnings into hard errors. Source code which triggers warnings
197 will be rejected.
198
199 +@item -Werror-maybe-reset
200 +@opindex Werror-maybe-reset
201 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
202 +variable is set to anything other than 0 or empty.
203 +
204 @item -Wsystem-headers
205 @opindex Wsystem-headers
206 Issue warnings for code in system headers. These are normally unhelpful
207 --- a/gcc/doc/invoke.texi
208 +++ b/gcc/doc/invoke.texi
209 @@ -222,7 +222,7 @@ Objective-C and Objective-C++ Dialects}.
210 -Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
211 -Wconversion -Wno-deprecated-declarations @gol
212 -Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels @gol
213 --Werror -Werror-implicit-function-declaration @gol
214 +-Werror -Werror-maybe-reset -Werror-implicit-function-declaration @gol
215 -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
216 -Wno-format-extra-args -Wformat-nonliteral @gol
217 -Wformat-security -Wformat-y2k @gol
218 @@ -3390,6 +3390,22 @@ This option is only supported for C and
219 @opindex Werror
220 Make all warnings into errors.
221
222 +@item -Werror-maybe-reset
223 +@opindex Werror-maybe-reset
224 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
225 +variable is set to anything other than 0 or empty.
226 +
227 +@item -fhonour-copts
228 +@opindex fhonour-copts
229 +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
230 +given at least once, and warn if it is given more than once.
231 +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
232 +given exactly once.
233 +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
234 +is not given exactly once.
235 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
236 +This flag and environment variable only affect the C language.
237 +
238 @item -Wstack-protector
239 This option is only active when @option{-fstack-protector} is active. It
240 warns about functions that will not be protected against stack smashing.
241 @@ -4679,7 +4695,7 @@ erroneously read data to propagate withi
242 Perform the optimizations of loop strength reduction and
243 elimination of iteration variables.
244
245 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
246 +Enabled at levels @option{-O3}.
247
248 @item -fthread-jumps
249 @opindex fthread-jumps
250 @@ -4826,7 +4842,7 @@ safely dereference null pointers. Use
251 @option{-fno-delete-null-pointer-checks} to disable this optimization
252 for programs which depend on that behavior.
253
254 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
255 +Enabled at levels @option{-O3}.
256
257 @item -fexpensive-optimizations
258 @opindex fexpensive-optimizations
259 @@ -5234,7 +5250,7 @@ node, an alias set for the node. Nodes
260 allowed to alias. For an example, see the C front-end function
261 @code{c_get_alias_set}.
262
263 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
264 +Enabled at levels @option{-O3}.
265
266 @item -falign-functions
267 @itemx -falign-functions=@var{n}
268 --- a/gcc/java/jvspec.c
269 +++ b/gcc/java/jvspec.c
270 @@ -620,6 +620,7 @@ lang_specific_pre_link (void)
271 class name. Append dummy `.c' that can be stripped by set_input so %b
272 is correct. */
273 set_input (concat (main_class_name, "main.c", NULL));
274 + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
275 err = do_spec (jvgenmain_spec);
276 if (err == 0)
277 {
This page took 0.050727 seconds and 5 git commands to generate.