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@mirbsd.de>
18 with copyright assignment to the FSF in effect.
20 Index: gcc-3.4.6/gcc/c-opts.c
21 ===================================================================
22 --- gcc-3.4.6.orig/gcc/c-opts.c 2005-03-09 02:00:56.000000000 +0100
23 +++ gcc-3.4.6/gcc/c-opts.c 2007-07-30 23:36:53.376930075 +0200
25 /* Permit Fotran front-end options. */
26 static bool permit_fortran_options;
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 mesg_implicit_function_declaration = 2;
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;
46 case OPT_Wfloat_equal:
47 warn_float_equal = value;
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 @@ -1211,6 +1228,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 ("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 ("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-3.4.6/gcc/c.opt
111 ===================================================================
112 --- gcc-3.4.6.orig/gcc/c.opt 2005-03-19 21:30:38.000000000 +0100
113 +++ gcc-3.4.6/gcc/c.opt 2007-07-30 23:36:53.380930305 +0200
115 C ObjC RejectNegative
116 Make implicit function declarations an error
120 +; Documented in common.opt
124 Warn if testing floating point numbers for equality
130 +C ObjC C++ ObjC++ RejectNegative
134 Assume normal C execution environment
135 Index: gcc-3.4.6/gcc/common.opt
136 ===================================================================
137 --- gcc-3.4.6.orig/gcc/common.opt 2004-10-28 05:43:09.000000000 +0200
138 +++ gcc-3.4.6/gcc/common.opt 2007-07-30 23:36:53.396931215 +0200
141 Treat all warnings as errors
145 +If environment variable GCC_NO_WERROR is set, act as -Wno-error
149 Print extra (possibly unwanted) warnings
152 Enable guessing of branch probabilities
155 +Common RejectNegative
159 Process #ident directives
160 Index: gcc-3.4.6/gcc/opts.c
161 ===================================================================
162 --- gcc-3.4.6.orig/gcc/opts.c 2004-02-18 01:09:07.000000000 +0100
163 +++ gcc-3.4.6/gcc/opts.c 2007-07-30 23:36:53.436933495 +0200
165 flag_schedule_insns_after_reload = 1;
168 - flag_strict_aliasing = 1;
169 - flag_delete_null_pointer_checks = 1;
170 flag_reorder_blocks = 1;
171 flag_reorder_functions = 1;
172 flag_unit_at_a_time = 1;
177 + flag_strict_aliasing = 1;
178 + flag_delete_null_pointer_checks = 1;
180 flag_inline_functions = 1;
181 flag_rename_registers = 1;
182 flag_unswitch_loops = 1;
184 warnings_are_errors = value;
187 + case OPT_Werror_maybe_reset:
189 + char *ev = getenv ("GCC_NO_WERROR");
190 + if ((ev != NULL) && (*ev != '0'))
191 + warnings_are_errors = 0;
198 @@ -1040,6 +1049,9 @@
199 flag_guess_branch_prob = value;
202 + case OPT_fhonour_copts:
206 flag_no_ident = !value;
208 Index: gcc-3.4.6/gcc/doc/cppopts.texi
209 ===================================================================
210 --- gcc-3.4.6.orig/gcc/doc/cppopts.texi 2004-06-28 22:28:07.000000000 +0200
211 +++ gcc-3.4.6/gcc/doc/cppopts.texi 2007-07-30 23:36:53.456934635 +0200
213 Make all warnings into hard errors. Source code which triggers warnings
216 +@item -Werror-maybe-reset
217 +@opindex Werror-maybe-reset
218 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
219 +variable is set to anything other than 0 or empty.
221 @item -Wsystem-headers
222 @opindex Wsystem-headers
223 Issue warnings for code in system headers. These are normally unhelpful
224 Index: gcc-3.4.6/gcc/doc/invoke.texi
225 ===================================================================
226 --- gcc-3.4.6.orig/gcc/doc/invoke.texi 2005-10-08 02:22:20.000000000 +0200
227 +++ gcc-3.4.6/gcc/doc/invoke.texi 2007-07-30 23:36:53.464935090 +0200
229 -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
230 -Wconversion -Wno-deprecated-declarations @gol
231 -Wdisabled-optimization -Wno-div-by-zero -Wendif-labels @gol
232 --Werror -Werror-implicit-function-declaration @gol
233 +-Werror -Werror-maybe-reset -Werror-implicit-function-declaration @gol
234 -Wfloat-equal -Wformat -Wformat=2 @gol
235 -Wno-format-extra-args -Wformat-nonliteral @gol
236 -Wformat-security -Wformat-y2k @gol
237 @@ -2989,6 +2989,22 @@
240 Make all warnings into errors.
242 +@item -Werror-maybe-reset
243 +@opindex Werror-maybe-reset
244 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
245 +variable is set to anything other than 0 or empty.
247 +@item -fhonour-copts
248 +@opindex fhonour-copts
249 +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
250 +given at least once, and warn if it is given more than once.
251 +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
253 +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
254 +is not given exactly once.
255 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
256 +This flag and environment variable only affect the C language.
259 @node Debugging Options
260 @@ -3879,7 +3895,7 @@
261 Perform the optimizations of loop strength reduction and
262 elimination of iteration variables.
264 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
265 +Enabled at levels @option{-O3}.
268 @opindex fthread-jumps
269 @@ -4006,7 +4022,7 @@
270 @option{-fno-delete-null-pointer-checks} to disable this optimization
271 for programs which depend on that behavior.
273 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
274 +Enabled at levels @option{-O3}.
276 @item -fexpensive-optimizations
277 @opindex fexpensive-optimizations
278 @@ -4250,7 +4266,7 @@
279 allowed to alias. For an example, see the C front-end function
280 @code{c_get_alias_set}.
282 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
283 +Enabled at levels @option{-O3}.
285 @item -falign-functions
286 @itemx -falign-functions=@var{n}
287 Index: gcc-3.4.6/gcc/java/jvspec.c
288 ===================================================================
289 --- gcc-3.4.6.orig/gcc/java/jvspec.c 2003-10-05 04:52:33.000000000 +0200
290 +++ gcc-3.4.6/gcc/java/jvspec.c 2007-07-30 23:36:53.496936915 +0200
292 class name. Append dummy `.c' that can be stripped by set_input so %b
294 set_input (concat (main_class_name, "main.c", NULL));
295 + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
296 err = do_spec (jvgenmain_spec);