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 --- a/gcc/c-family/c-opts.c
21 +++ b/gcc/c-family/c-opts.c
22 @@ -103,6 +103,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 handle_OPT_d (const char *);
30 static void set_std_cxx98 (int);
31 static void set_std_cxx0x (int);
32 @@ -441,6 +444,9 @@ c_common_handle_option (size_t scode, co
33 global_dc->warning_as_error_requested = value;
36 + case OPT_Werror_maybe_reset:
42 @@ -584,6 +590,12 @@ c_common_handle_option (size_t scode, co
43 flag_no_builtin = !value;
46 + case OPT_fhonour_copts:
47 + if (c_language == clk_c) {
52 case OPT_fconstant_string_class_:
53 constant_string_class_name = arg;
55 @@ -1058,6 +1070,47 @@ c_common_init (void)
59 + if (c_language == clk_c) {
60 + char *ev = getenv ("GCC_HONOUR_COPTS");
64 + else if ((*ev == '0') || (*ev == '\0'))
66 + else if (*ev == '1')
68 + else if (*ev == '2')
70 + else if (*ev == 's')
73 + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
74 + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
77 + if (honour_copts == 0) {
78 + error ("someone does not honour COPTS at all in lenient mode");
80 + } else if (honour_copts != 1) {
81 + warning (0, "someone does not honour COPTS correctly, passed %d times",
84 + } else if (evv == 2) {
85 + if (honour_copts == 0) {
86 + error ("someone does not honour COPTS at all in strict mode");
88 + } else if (honour_copts != 1) {
89 + error ("someone does not honour COPTS correctly, passed %d times",
93 + } else if (evv == 0) {
94 + if (honour_copts != 1)
95 + inform (0, "someone does not honour COPTS correctly, passed %d times",
103 --- a/gcc/c-family/c.opt
104 +++ b/gcc/c-family/c.opt
105 @@ -363,6 +363,10 @@ Werror-implicit-function-declaration
106 C ObjC RejectNegative Warning Alias(Werror=, implicit-function-declaration)
107 This switch is deprecated; use -Werror=implicit-function-declaration instead
111 +; Documented in common.opt
114 C ObjC C++ ObjC++ Var(warn_float_equal) Warning
115 Warn if testing floating point numbers for equality
116 @@ -794,6 +798,9 @@ C++ ObjC++ Optimization Alias(fexception
118 C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
121 +C ObjC C++ ObjC++ RejectNegative
125 Assume normal C execution environment
128 @@ -520,6 +520,10 @@ Werror=
130 Treat specified warning as error
134 +If environment variable GCC_NO_WERROR is set, act as -Wno-error
137 Common Var(extra_warnings) Warning
138 Print extra (possibly unwanted) warnings
139 @@ -1156,6 +1160,9 @@ fguess-branch-probability
140 Common Report Var(flag_guess_branch_prob) Optimization
141 Enable guessing of branch probabilities
144 +Common RejectNegative
146 ; Nonzero means ignore `#ident' directives. 0 means handle them.
147 ; Generate position-independent code for executables if possible
148 ; On SVR4 targets, it also controls whether or not to emit a
151 @@ -477,8 +477,6 @@ static const struct default_options defa
152 { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 },
154 { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 },
155 - { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 },
156 - { OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 },
157 { OPT_LEVELS_2_PLUS, OPT_freorder_blocks, NULL, 1 },
158 { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 },
159 { OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 },
160 @@ -494,6 +492,8 @@ static const struct default_options defa
161 { OPT_LEVELS_2_PLUS, OPT_falign_functions, NULL, 1 },
163 /* -O3 optimizations. */
164 + { OPT_LEVELS_3_PLUS, OPT_fstrict_aliasing, NULL, 1 },
165 + { OPT_LEVELS_3_PLUS, OPT_fstrict_overflow, NULL, 1 },
166 { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
167 { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 },
168 /* Inlining of functions reducing size is a good idea with -Os
169 @@ -1399,6 +1399,17 @@ common_handle_option (struct gcc_options
170 opts, opts_set, loc, dc);
173 + case OPT_Werror_maybe_reset:
175 + char *ev = getenv ("GCC_NO_WERROR");
176 + if ((ev != NULL) && (*ev != '0'))
177 + warnings_are_errors = 0;
181 + case OPT_fhonour_copts:
184 case OPT_Wlarger_than_:
185 opts->x_larger_than_size = value;
186 opts->x_warn_larger_than = value != -1;
187 --- a/gcc/doc/cppopts.texi
188 +++ b/gcc/doc/cppopts.texi
189 @@ -164,6 +164,11 @@ in older programs. This warning is on b
190 Make all warnings into hard errors. Source code which triggers warnings
193 + at item -Werror-maybe-reset
194 + at opindex Werror-maybe-reset
195 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
196 +variable is set to anything other than 0 or empty.
198 @item -Wsystem-headers
199 @opindex Wsystem-headers
200 Issue warnings for code in system headers. These are normally unhelpful
201 --- a/gcc/doc/invoke.texi
202 +++ b/gcc/doc/invoke.texi
203 @@ -240,7 +240,7 @@ Objective-C and Objective-C++ Dialects}.
204 -Wconversion -Wcoverage-mismatch -Wno-cpp -Wno-deprecated @gol
205 -Wno-deprecated-declarations -Wdisabled-optimization @gol
206 -Wno-div-by-zero -Wdouble-promotion -Wempty-body -Wenum-compare @gol
207 --Wno-endif-labels -Werror -Werror=* @gol
208 +-Wno-endif-labels -Werror -Werror=* -Werror-maybe-reset @gol
209 -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
210 -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
211 -Wformat-security -Wformat-y2k @gol
212 @@ -4497,6 +4497,22 @@ This option is only supported for C and
213 @option{-Wall} and by @option{-pedantic}, which can be disabled with
214 @option{-Wno-pointer-sign}.
216 + at item -Werror-maybe-reset
217 + at 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 + at item -fhonour-copts
222 + at opindex fhonour-copts
223 +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
224 +given at least once, and warn if it is given more than once.
225 +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
227 +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
228 +is not given exactly once.
229 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
230 +This flag and environment variable only affect the C language.
232 @item -Wstack-protector
233 @opindex Wstack-protector
234 @opindex Wno-stack-protector
235 @@ -6319,7 +6335,7 @@ so, the first branch is redirected to ei
236 second branch or a point immediately following it, depending on whether
237 the condition is known to be true or false.
239 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
240 +Enabled at levels @option{-O3}.
242 @item -fsplit-wide-types
243 @opindex fsplit-wide-types
244 --- a/gcc/java/jvspec.c
245 +++ b/gcc/java/jvspec.c
246 @@ -627,6 +627,7 @@ lang_specific_pre_link (void)
247 class name. Append dummy `.c' that can be stripped by set_input so %b
249 set_input (concat (main_class_name, "main.c", NULL));
250 + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
251 err = do_spec (jvgenmain_spec);