2 This patch brings over a few features from MirBSD:
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.
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
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.
17 This patch was authored by Thorsten Glaser <tg at mirbsd.de>
18 with copyright assignment to the FSF in effect.
20 Index: gcc-4.3.0/gcc/c-opts.c
21 ===================================================================
22 --- gcc-4.3.0.orig/gcc/c-opts.c 2007-07-31 02:27:12.007256629 +0200
23 +++ gcc-4.3.0/gcc/c-opts.c 2007-07-31 02:27:39.324813371 +0200
25 /* Number of deferred options scanned for -include. */
26 static size_t include_cursor;
28 +/* Check if a port honours COPTS. */
29 +static int honour_copts = 0;
31 static void set_Wimplicit (int);
32 static void handle_OPT_d (const char *);
33 static void set_std_cxx98 (int);
35 enable_warning_as_error ("implicit-function-declaration", value, CL_C | CL_ObjC);
38 + case OPT_Werror_maybe_reset:
40 + char *ev = getenv ("GCC_NO_WERROR");
41 + if ((ev != NULL) && (*ev != '0'))
42 + cpp_opts->warnings_are_errors = 0;
50 flag_exceptions = value;
53 + case OPT_fhonour_copts:
54 + if (c_language == clk_c) {
59 case OPT_fimplement_inlines:
60 flag_implement_inlines = value;
62 @@ -1248,6 +1265,47 @@
63 /* Has to wait until now so that cpplib has its hash table. */
66 + if (c_language == clk_c) {
67 + char *ev = getenv ("GCC_HONOUR_COPTS");
71 + else if ((*ev == '0') || (*ev == '\0'))
73 + else if (*ev == '1')
75 + else if (*ev == '2')
77 + else if (*ev == 's')
80 + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
81 + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
84 + if (honour_copts == 0) {
85 + error ("someone does not honour COPTS at all in lenient mode");
87 + } else if (honour_copts != 1) {
88 + warning (0, "someone does not honour COPTS correctly, passed %d times",
91 + } else if (evv == 2) {
92 + if (honour_copts == 0) {
93 + error ("someone does not honour COPTS at all in strict mode");
95 + } else if (honour_copts != 1) {
96 + error ("someone does not honour COPTS correctly, passed %d times",
100 + } else if (evv == 0) {
101 + if (honour_copts != 1)
102 + inform ("someone does not honour COPTS correctly, passed %d times",
110 Index: gcc-4.3.0/gcc/c.opt
111 ===================================================================
112 --- gcc-4.3.0.orig/gcc/c.opt 2007-07-31 02:27:12.015257093 +0200
113 +++ gcc-4.3.0/gcc/c.opt 2007-07-31 02:27:39.328813597 +0200
115 C ObjC RejectNegative Warning
116 This switch is deprecated; use -Werror=implicit-function-declaration instead
120 +; Documented in common.opt
123 C ObjC C++ ObjC++ Var(warn_float_equal) Warning
124 Warn if testing floating point numbers for equality
130 +C ObjC C++ ObjC++ RejectNegative
134 Assume normal C execution environment
135 Index: gcc-4.3.0/gcc/common.opt
136 ===================================================================
137 --- gcc-4.3.0.orig/gcc/common.opt 2007-07-31 02:27:12.023257546 +0200
138 +++ gcc-4.3.0/gcc/common.opt 2007-07-31 02:27:39.360815422 +0200
141 Treat specified warning as error
145 +If environment variable GCC_NO_WERROR is set, act as -Wno-error
149 Print extra (possibly unwanted) warnings
151 Common Report Var(flag_guess_branch_prob) Optimization
152 Enable guessing of branch probabilities
155 +Common RejectNegative
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.3.0/gcc/opts.c
161 ===================================================================
162 --- gcc-4.3.0.orig/gcc/opts.c 2007-07-31 02:27:12.031257991 +0200
163 +++ gcc-4.3.0/gcc/opts.c 2007-07-31 02:28:36.320061346 +0200
165 flag_schedule_insns_after_reload = 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;
178 + flag_strict_aliasing = 1;
179 + flag_strict_overflow = 1;
180 + flag_delete_null_pointer_checks = 1;
182 flag_predictive_commoning = 1;
183 flag_inline_functions = 1;
184 flag_unswitch_loops = 1;
185 @@ -1441,6 +1442,17 @@
186 enable_warning_as_error (arg, value, lang_mask);
189 + case OPT_Werror_maybe_reset:
191 + char *ev = getenv ("GCC_NO_WERROR");
192 + if ((ev != NULL) && (*ev != '0'))
193 + warnings_are_errors = 0;
197 + case OPT_fhonour_copts:
203 Index: gcc-4.3.0/gcc/doc/cppopts.texi
204 ===================================================================
205 --- gcc-4.3.0.orig/gcc/doc/cppopts.texi 2007-07-31 02:27:12.039258455 +0200
206 +++ gcc-4.3.0/gcc/doc/cppopts.texi 2007-07-31 02:27:39.408818157 +0200
208 Make all warnings into hard errors. Source code which triggers warnings
211 + at item -Werror-maybe-reset
212 + at 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.
216 @item -Wsystem-headers
217 @opindex Wsystem-headers
218 Issue warnings for code in system headers. These are normally unhelpful
219 Index: gcc-4.3.0/gcc/doc/invoke.texi
220 ===================================================================
221 --- gcc-4.3.0.orig/gcc/doc/invoke.texi 2007-07-31 02:27:12.047258920 +0200
222 +++ gcc-4.3.0/gcc/doc/invoke.texi 2007-07-31 02:29:13.218164047 +0200
224 -Wconversion -Wcoverage-mismatch -Wno-deprecated-declarations @gol
225 -Wdisabled-optimization -Wno-div-by-zero @gol
226 -Wempty-body -Wno-endif-labels @gol
227 --Werror -Werror=* @gol
228 +-Werror -Werror=* -Werror-maybe-reset @gol
229 -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
230 -Wno-format-extra-args -Wformat-nonliteral @gol
231 -Wformat-security -Wformat-y2k -Wignored-qualifiers @gol
232 @@ -4030,6 +4030,22 @@
233 @option{-Wall} and by @option{-pedantic}, which can be disabled with
234 @option{-Wno-pointer-sign}.
236 + at item -Werror-maybe-reset
237 + at 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.
241 + at item -fhonour-copts
242 + at 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
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.
252 @item -Wstack-protector
253 @opindex Wstack-protector
254 @opindex Wno-stack-protector
255 @@ -5490,7 +5806,7 @@
256 second branch or a point immediately following it, depending on whether
257 the condition is known to be true or false.
259 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
260 +Enabled at levels @option{-O3}.
262 @item -fsplit-wide-types
263 @opindex fsplit-wide-types
264 @@ -5635,7 +5514,7 @@
265 @option{-fno-delete-null-pointer-checks} to disable this optimization
266 for programs which depend on that behavior.
268 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
269 +Enabled at levels @option{-O3}.
271 @item -fexpensive-optimizations
272 @opindex fexpensive-optimizations
273 Index: gcc-4.3.0/gcc/java/jvspec.c
274 ===================================================================
275 --- gcc-4.3.0.orig/gcc/java/jvspec.c 2007-07-31 02:27:12.055259364 +0200
276 +++ gcc-4.3.0/gcc/java/jvspec.c 2007-07-31 02:27:39.484822490 +0200
278 class name. Append dummy `.c' that can be stripped by set_input so %b
280 set_input (concat (main_class_name, "main.c", NULL));
281 + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
282 err = do_spec (jvgenmain_spec);