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-4.1.2/gcc/c-opts.c
21 ===================================================================
22 --- gcc-4.1.2.orig/gcc/c-opts.c 2007-07-31 01:14:52.799979303 +0200
23 +++ gcc-4.1.2/gcc/c-opts.c 2007-07-31 01:17:10.535828420 +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 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;
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 @@ -1121,6 +1138,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.1.2/gcc/c.opt
111 ===================================================================
112 --- gcc-4.1.2.orig/gcc/c.opt 2007-07-31 01:14:52.807979755 +0200
113 +++ gcc-4.1.2/gcc/c.opt 2007-07-31 01:15:32.270228583 +0200
115 C ObjC RejectNegative
116 Make implicit function declarations an error
120 +; Documented in common.opt
123 C ObjC C++ ObjC++ Var(warn_float_equal)
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.1.2/gcc/common.opt
136 ===================================================================
137 --- gcc-4.1.2.orig/gcc/common.opt 2007-07-31 01:14:52.815980213 +0200
138 +++ gcc-4.1.2/gcc/common.opt 2007-07-31 01:17:41.997621326 +0200
140 Common Var(warnings_are_errors)
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
151 Common Report Var(flag_guess_branch_prob)
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.1.2/gcc/opts.c
161 ===================================================================
162 --- gcc-4.1.2.orig/gcc/opts.c 2007-07-31 01:14:52.823980670 +0200
163 +++ gcc-4.1.2/gcc/opts.c 2007-07-31 01:18:38.152821428 +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_tree_store_ccp = 1;
177 + flag_strict_aliasing = 1;
178 + flag_delete_null_pointer_checks = 1;
180 flag_inline_functions = 1;
181 flag_unswitch_loops = 1;
182 flag_gcse_after_reload = 1;
187 + case OPT_Werror_maybe_reset:
189 + char *ev = getenv ("GCC_NO_WERROR");
190 + if ((ev != NULL) && (*ev != '0'))
191 + warnings_are_errors = 0;
195 + case OPT_fhonour_copts:
201 Index: gcc-4.1.2/gcc/doc/cppopts.texi
202 ===================================================================
203 --- gcc-4.1.2.orig/gcc/doc/cppopts.texi 2007-07-31 01:14:52.827980895 +0200
204 +++ gcc-4.1.2/gcc/doc/cppopts.texi 2007-07-31 01:15:32.362233824 +0200
206 Make all warnings into hard errors. Source code which triggers warnings
209 +@item -Werror-maybe-reset
210 +@opindex Werror-maybe-reset
211 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
212 +variable is set to anything other than 0 or empty.
214 @item -Wsystem-headers
215 @opindex Wsystem-headers
216 Issue warnings for code in system headers. These are normally unhelpful
217 Index: gcc-4.1.2/gcc/doc/invoke.texi
218 ===================================================================
219 --- gcc-4.1.2.orig/gcc/doc/invoke.texi 2007-07-31 01:14:59.592366375 +0200
220 +++ gcc-4.1.2/gcc/doc/invoke.texi 2007-07-31 01:16:22.569094954 +0200
222 -Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
223 -Wconversion -Wno-deprecated-declarations @gol
224 -Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels @gol
225 --Werror -Werror-implicit-function-declaration @gol
226 +-Werror -Werror-maybe-reset -Werror-implicit-function-declaration @gol
227 -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
228 -Wno-format-extra-args -Wformat-nonliteral @gol
229 -Wformat-security -Wformat-y2k @gol
230 @@ -3390,6 +3390,22 @@
232 Make all warnings into errors.
234 +@item -Werror-maybe-reset
235 +@opindex Werror-maybe-reset
236 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
237 +variable is set to anything other than 0 or empty.
239 +@item -fhonour-copts
240 +@opindex fhonour-copts
241 +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
242 +given at least once, and warn if it is given more than once.
243 +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
245 +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
246 +is not given exactly once.
247 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
248 +This flag and environment variable only affect the C language.
250 @item -Wstack-protector
251 This option is only active when @option{-fstack-protector} is active. It
252 warns about functions that will not be protected against stack smashing.
253 @@ -4679,7 +4695,7 @@
254 Perform the optimizations of loop strength reduction and
255 elimination of iteration variables.
257 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
258 +Enabled at levels @option{-O3}.
261 @opindex fthread-jumps
262 @@ -4826,7 +4842,7 @@
263 @option{-fno-delete-null-pointer-checks} to disable this optimization
264 for programs which depend on that behavior.
266 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
267 +Enabled at levels @option{-O3}.
269 @item -fexpensive-optimizations
270 @opindex fexpensive-optimizations
271 @@ -5234,7 +5250,7 @@
272 allowed to alias. For an example, see the C front-end function
273 @code{c_get_alias_set}.
275 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
276 +Enabled at levels @option{-O3}.
278 @item -falign-functions
279 @itemx -falign-functions=@var{n}
280 Index: gcc-4.1.2/gcc/java/jvspec.c
281 ===================================================================
282 --- gcc-4.1.2.orig/gcc/java/jvspec.c 2007-07-31 01:14:52.847982035 +0200
283 +++ gcc-4.1.2/gcc/java/jvspec.c 2007-07-31 01:15:32.454239068 +0200
285 class name. Append dummy `.c' that can be stripped by set_input so %b
287 set_input (concat (main_class_name, "main.c", NULL));
288 + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
289 err = do_spec (jvgenmain_spec);