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.
22 @@ -109,6 +109,9 @@ static size_t deferred_count;
23 /* Number of deferred options scanned for -include. */
24 static size_t include_cursor;
26 +/* Check if a port honours COPTS. */
27 +static int honour_copts = 0;
29 static void set_Wimplicit (int);
30 static void handle_OPT_d (const char *);
31 static void set_std_cxx98 (int);
32 @@ -502,6 +505,14 @@ c_common_handle_option (size_t scode, co
33 mesg_implicit_function_declaration = 2;
36 + case OPT_Werror_maybe_reset:
38 + char *ev = getenv ("GCC_NO_WERROR");
39 + if ((ev != NULL) && (*ev != '0'))
40 + cpp_opts->warnings_are_errors = 0;
47 @@ -778,6 +789,12 @@ c_common_handle_option (size_t scode, co
48 flag_exceptions = value;
51 + case OPT_fhonour_copts:
52 + if (c_language == clk_c) {
57 case OPT_fimplement_inlines:
58 flag_implement_inlines = value;
60 @@ -1295,6 +1312,47 @@ c_common_init (void)
61 /* Has to wait until now so that cpplib has its hash table. */
64 + if (c_language == clk_c) {
65 + char *ev = getenv ("GCC_HONOUR_COPTS");
69 + else if ((*ev == '0') || (*ev == '\0'))
71 + else if (*ev == '1')
73 + else if (*ev == '2')
75 + else if (*ev == 's')
78 + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
79 + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
82 + if (honour_copts == 0) {
83 + error ("someone does not honour COPTS at all in lenient mode");
85 + } else if (honour_copts != 1) {
86 + warning (0, "someone does not honour COPTS correctly, passed %d times",
89 + } else if (evv == 2) {
90 + if (honour_copts == 0) {
91 + error ("someone does not honour COPTS at all in strict mode");
93 + } else if (honour_copts != 1) {
94 + error ("someone does not honour COPTS correctly, passed %d times",
98 + } else if (evv == 0) {
99 + if (honour_copts != 1)
100 + inform ("someone does not honour COPTS correctly, passed %d times",
110 @@ -220,6 +220,10 @@ C ObjC C++ ObjC++
111 Warn about extra tokens at the end of prepreprocessor directives
112 ; APPLE LOCAL end -Wextra-tokens
116 +; Documented in common.opt
119 C ObjC C++ ObjC++ Var(warn_float_equal)
120 Warn if testing floating point numbers for equality
121 @@ -675,6 +679,9 @@ C++ ObjC++
126 +C ObjC C++ ObjC++ RejectNegative
130 Assume normal C execution environment
133 @@ -81,6 +81,10 @@ Werror=
135 Treat specified warning as error
139 +If environment variable GCC_NO_WERROR is set, act as -Wno-error
143 Print extra (possibly unwanted) warnings
144 @@ -607,6 +611,9 @@ Common Report Var(flag_guess_branch_prob
145 Enable guessing of branch probabilities
146 ; APPLE LOCAL end optimization pragmas 3124235/3420242
149 +Common RejectNegative
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
156 @@ -507,9 +507,6 @@ void set_flags_from_O (unsigned int cmdl
159 /* APPLE LOCAL optimization pragmas 3124235/3420242 */
160 - if (cmdline) flag_strict_aliasing = 1;
161 - flag_strict_overflow = 1;
162 - flag_delete_null_pointer_checks = 1;
163 flag_reorder_blocks = 1;
164 /* APPLE LOCAL optimization pragmas 3124235/3420242 */
165 if (cmdline) flag_reorder_functions = 1;
166 @@ -536,6 +533,9 @@ void set_flags_from_O (unsigned int cmdl
170 + if (cmdline) flag_strict_aliasing = 1;
171 + flag_strict_overflow = 1;
172 + flag_delete_null_pointer_checks = 1;
174 flag_inline_functions = 1;
175 flag_unswitch_loops = 1;
176 @@ -873,6 +873,17 @@ common_handle_option (size_t scode, cons
180 + case OPT_Werror_maybe_reset:
182 + char *ev = getenv ("GCC_NO_WERROR");
183 + if ((ev != NULL) && (*ev != '0'))
184 + warnings_are_errors = 0;
188 + case OPT_fhonour_copts:
194 --- a/gcc/doc/cppopts.texi
195 +++ b/gcc/doc/cppopts.texi
196 @@ -166,6 +166,11 @@ in older programs. This warning is on b
197 Make all warnings into hard errors. Source code which triggers warnings
200 +@item -Werror-maybe-reset
201 +@opindex Werror-maybe-reset
202 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
203 +variable is set to anything other than 0 or empty.
205 @item -Wsystem-headers
206 @opindex Wsystem-headers
207 Issue warnings for code in system headers. These are normally unhelpful
208 --- a/gcc/doc/invoke.texi
209 +++ b/gcc/doc/invoke.texi
210 @@ -282,7 +282,7 @@ Objective-C and Objective-C++ Dialects}.
211 -Wc++-compat -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
212 -Wconversion -Wno-deprecated-declarations @gol
213 -Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels @gol
214 --Werror -Werror=* -Werror-implicit-function-declaration @gol
215 +-Werror -Werror-maybe-reset -Werror=* -Werror-implicit-function-declaration @gol
216 @c APPLE LOCAL default to Wformat-security 5764921
217 -Wfatal-errors -Wfloat-equal -Wno-format -Wformat=2 @gol
218 -Wno-format-extra-args -Wformat-nonliteral @gol
219 @@ -4031,6 +4031,22 @@ Note that specifying @option{-Werror=}@v
220 @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
223 +@item -Werror-maybe-reset
224 +@opindex Werror-maybe-reset
225 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
226 +variable is set to anything other than 0 or empty.
228 +@item -fhonour-copts
229 +@opindex fhonour-copts
230 +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
231 +given at least once, and warn if it is given more than once.
232 +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
234 +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
235 +is not given exactly once.
236 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
237 +This flag and environment variable only affect the C language.
239 @item -Wstack-protector
240 @opindex Wstack-protector
241 This option is only active when @option{-fstack-protector} is active. It
242 @@ -5533,7 +5549,7 @@ second branch or a point immediately fol
243 the condition is known to be true or false.
245 @c APPLE LOCAL 4231761 -Oz
246 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, @option{-Oz} (APPLE ONLY).
247 +Enabled at levels @option{-O3}, @option{-Oz} (APPLE ONLY).
249 @item -fcse-follow-jumps
250 @opindex fcse-follow-jumps
251 @@ -5659,7 +5675,7 @@ safely dereference null pointers. Use
252 for programs which depend on that behavior.
254 @c APPLE LOCAL 4231761 -Oz
255 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, @option{-Oz} (APPLE ONLY).
256 +Enabled at levels @option{-O3}, @option{-Oz} (APPLE ONLY).
258 @item -fexpensive-optimizations
259 @opindex fexpensive-optimizations
260 @@ -6103,7 +6119,7 @@ allowed to alias. For an example, see t
261 @code{c_get_alias_set}.
263 @c APPLE LOCAL 4231761 -Oz
264 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, @option{-Oz} (APPLE ONLY).
265 +Enabled at levels @option{-O3}, @option{-Oz} (APPLE ONLY).
267 @item -fstrict-overflow
268 @opindex fstrict-overflow
269 --- a/gcc/java/jvspec.c
270 +++ b/gcc/java/jvspec.c
271 @@ -632,6 +632,7 @@ lang_specific_pre_link (void)
272 class name. Append dummy `.c' that can be stripped by set_input so %b
274 set_input (concat (main_class_name, "main.c", NULL));
275 + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
276 err = do_spec (jvgenmain_spec);