add gcc-4.5.0 preliminary support
[openwrt/svn-archive/archive.git] / toolchain / gcc / patches / 4.5.0 / 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 at 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 @@ -105,6 +105,9 @@
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 @@ -690,6 +701,12 @@
33 flag_exceptions = value;
34 break;
35
36 + case OPT_fhonour_copts:
37 + if (c_language == clk_c) {
38 + honour_copts++;
39 + }
40 + break;
41 +
42 case OPT_fimplement_inlines:
43 flag_implement_inlines = value;
44 break;
45 @@ -1209,6 +1226,47 @@
46 return false;
47 }
48
49 + if (c_language == clk_c) {
50 + char *ev = getenv ("GCC_HONOUR_COPTS");
51 + int evv;
52 + if (ev == NULL)
53 + evv = -1;
54 + else if ((*ev == '0') || (*ev == '\0'))
55 + evv = 0;
56 + else if (*ev == '1')
57 + evv = 1;
58 + else if (*ev == '2')
59 + evv = 2;
60 + else if (*ev == 's')
61 + evv = -1;
62 + else {
63 + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
64 + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
65 + }
66 + if (evv == 1) {
67 + if (honour_copts == 0) {
68 + error ("someone does not honour COPTS at all in lenient mode");
69 + return false;
70 + } else if (honour_copts != 1) {
71 + warning (0, "someone does not honour COPTS correctly, passed %d times",
72 + honour_copts);
73 + }
74 + } else if (evv == 2) {
75 + if (honour_copts == 0) {
76 + error ("someone does not honour COPTS at all in strict mode");
77 + return false;
78 + } else if (honour_copts != 1) {
79 + error ("someone does not honour COPTS correctly, passed %d times",
80 + honour_copts);
81 + return false;
82 + }
83 + } else if (evv == 0) {
84 + if (honour_copts != 1)
85 + inform (0, "someone does not honour COPTS correctly, passed %d times",
86 + honour_copts);
87 + }
88 + }
89 +
90 return true;
91 }
92
93 --- a/gcc/c.opt
94 +++ b/gcc/c.opt
95 @@ -215,6 +215,10 @@
96 C ObjC RejectNegative Warning
97 This switch is deprecated; use -Werror=implicit-function-declaration instead
98
99 +Werror-maybe-reset
100 +C ObjC C++ ObjC++
101 +; Documented in common.opt
102 +
103 Wfloat-equal
104 C ObjC C++ ObjC++ Var(warn_float_equal) Warning
105 Warn if testing floating point numbers for equality
106 @@ -609,6 +613,9 @@
107 fhonor-std
108 C++ ObjC++
109
110 +fhonour-copts
111 +C ObjC C++ ObjC++ RejectNegative
112 +
113 fhosted
114 C ObjC
115 Assume normal C execution environment
116 --- a/gcc/common.opt
117 +++ b/gcc/common.opt
118 @@ -102,6 +102,10 @@
119 Common Joined
120 Treat specified warning as error
121
122 +Werror-maybe-reset
123 +Common
124 +If environment variable GCC_NO_WERROR is set, act as -Wno-error
125 +
126 Wextra
127 Common Warning
128 Print extra (possibly unwanted) warnings
129 @@ -573,6 +577,9 @@
130 Common Report Var(flag_guess_branch_prob) Optimization
131 Enable guessing of branch probabilities
132
133 +fhonour-copts
134 +Common RejectNegative
135 +
136 ; Nonzero means ignore `#ident' directives. 0 means handle them.
137 ; Generate position-independent code for executables if possible
138 ; On SVR4 targets, it also controls whether or not to emit a
139 --- a/gcc/opts.c
140 +++ b/gcc/opts.c
141 @@ -891,8 +891,6 @@
142 flag_schedule_insns_after_reload = opt2;
143 #endif
144 flag_regmove = opt2;
145 - flag_strict_aliasing = opt2;
146 - flag_strict_overflow = opt2;
147 flag_reorder_blocks = opt2;
148 flag_reorder_functions = opt2;
149 flag_tree_vrp = opt2;
150 @@ -912,6 +910,9 @@
151
152 /* -O3 optimizations. */
153 opt3 = (optimize >= 3);
154 + flag_strict_aliasing = opt3;
155 + flag_strict_overflow = opt3;
156 + flag_delete_null_pointer_checks = opt3;
157 flag_predictive_commoning = opt3;
158 flag_inline_functions = opt3;
159 flag_unswitch_loops = opt3;
160 @@ -1638,6 +1639,17 @@
161 enable_warning_as_error (arg, value, lang_mask);
162 break;
163
164 + case OPT_Werror_maybe_reset:
165 + {
166 + char *ev = getenv ("GCC_NO_WERROR");
167 + if ((ev != NULL) && (*ev != '0'))
168 + warnings_are_errors = 0;
169 + }
170 + break;
171 +
172 + case OPT_fhonour_copts:
173 + break;
174 +
175 case OPT_Wlarger_than_:
176 /* This form corresponds to -Wlarger-than-.
177 Kept for backward compatibility.
178 --- a/gcc/doc/cppopts.texi
179 +++ b/gcc/doc/cppopts.texi
180 @@ -164,6 +164,11 @@
181 Make all warnings into hard errors. Source code which triggers warnings
182 will be rejected.
183
184 + at item -Werror-maybe-reset
185 + at opindex Werror-maybe-reset
186 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
187 +variable is set to anything other than 0 or empty.
188 +
189 @item -Wsystem-headers
190 @opindex Wsystem-headers
191 Issue warnings for code in system headers. These are normally unhelpful
192 --- a/gcc/doc/invoke.texi
193 +++ b/gcc/doc/invoke.texi
194 @@ -234,7 +234,7 @@
195 -Wconversion -Wcoverage-mismatch -Wno-deprecated @gol
196 -Wno-deprecated-declarations -Wdisabled-optimization @gol
197 -Wno-div-by-zero -Wempty-body -Wenum-compare -Wno-endif-labels @gol
198 --Werror -Werror=* @gol
199 +-Werror -Werror=* -Werror-maybe-reset @gol
200 -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
201 -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
202 -Wformat-security -Wformat-y2k @gol
203 @@ -4161,6 +4161,22 @@
204 @option{-Wall} and by @option{-pedantic}, which can be disabled with
205 @option{-Wno-pointer-sign}.
206
207 + at item -Werror-maybe-reset
208 + at opindex Werror-maybe-reset
209 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
210 +variable is set to anything other than 0 or empty.
211 +
212 + at item -fhonour-copts
213 + at opindex fhonour-copts
214 +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
215 +given at least once, and warn if it is given more than once.
216 +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
217 +given exactly once.
218 +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
219 +is not given exactly once.
220 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
221 +This flag and environment variable only affect the C language.
222 +
223 @item -Wstack-protector
224 @opindex Wstack-protector
225 @opindex Wno-stack-protector
226 @@ -5699,7 +5715,7 @@
227 second branch or a point immediately following it, depending on whether
228 the condition is known to be true or false.
229
230 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
231 +Enabled at levels @option{-O3}.
232
233 @item -fsplit-wide-types
234 @opindex fsplit-wide-types
235 @@ -5844,7 +5860,7 @@
236 @option{-fno-delete-null-pointer-checks} to disable this optimization
237 for programs which depend on that behavior.
238
239 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
240 +Enabled at levels @option{-O3}.
241
242 @item -fexpensive-optimizations
243 @opindex fexpensive-optimizations
244 --- a/gcc/java/jvspec.c
245 +++ b/gcc/java/jvspec.c
246 @@ -670,6 +670,7 @@
247 class name. Append dummy `.c' that can be stripped by set_input so %b
248 is correct. */
249 set_input (concat (main_class_name, "main.c", NULL));
250 + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
251 err = do_spec (jvgenmain_spec);
252 if (err == 0)
253 {