2 This patch brings over a feature 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 This patch was authored by Thorsten Glaser <tg at mirbsd.de>
9 with copyright assignment to the FSF in effect.
11 --- a/gcc/c-family/c-opts.c
12 +++ b/gcc/c-family/c-opts.c
13 @@ -108,6 +108,9 @@ static int class_dump_flags;
14 /* Whether any standard preincluded header has been preincluded. */
15 static bool done_preinclude;
17 +/* Check if a port honours COPTS. */
18 +static int honour_copts = 0;
20 static void handle_OPT_d (const char *);
21 static void set_std_cxx98 (int);
22 static void set_std_cxx11 (int);
23 @@ -456,6 +459,12 @@ c_common_handle_option (size_t scode, co
24 flag_no_builtin = !value;
27 + case OPT_fhonour_copts:
28 + if (c_language == clk_c) {
33 case OPT_fconstant_string_class_:
34 constant_string_class_name = arg;
36 @@ -1084,6 +1093,47 @@ c_common_init (void)
40 + if (c_language == clk_c) {
41 + char *ev = getenv ("GCC_HONOUR_COPTS");
45 + else if ((*ev == '0') || (*ev == '\0'))
47 + else if (*ev == '1')
49 + else if (*ev == '2')
51 + else if (*ev == 's')
54 + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
55 + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
58 + if (honour_copts == 0) {
59 + error ("someone does not honour COPTS at all in lenient mode");
61 + } else if (honour_copts != 1) {
62 + warning (0, "someone does not honour COPTS correctly, passed %d times",
65 + } else if (evv == 2) {
66 + if (honour_copts == 0) {
67 + error ("someone does not honour COPTS at all in strict mode");
69 + } else if (honour_copts != 1) {
70 + error ("someone does not honour COPTS correctly, passed %d times",
74 + } else if (evv == 0) {
75 + if (honour_copts != 1)
76 + inform (0, "someone does not honour COPTS correctly, passed %d times",
84 --- a/gcc/c-family/c.opt
85 +++ b/gcc/c-family/c.opt
86 @@ -1412,6 +1412,9 @@ C++ ObjC++ Optimization Alias(fexception
88 C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
91 +C ObjC C++ ObjC++ RejectNegative
95 Assume normal C execution environment.
98 @@ -1510,6 +1510,9 @@ fguess-branch-probability
99 Common Report Var(flag_guess_branch_prob) Optimization
100 Enable guessing of branch probabilities.
103 +Common RejectNegative
105 ; Nonzero means ignore `#ident' directives. 0 means handle them.
106 ; Generate position-independent code for executables if possible
107 ; On SVR4 targets, it also controls whether or not to emit a
110 @@ -1921,6 +1921,9 @@ common_handle_option (struct gcc_options
111 opts, opts_set, loc, dc);
114 + case OPT_fhonour_copts:
117 case OPT_Wlarger_than_:
118 opts->x_larger_than_size = value;
119 opts->x_warn_larger_than = value != -1;
120 --- a/gcc/doc/invoke.texi
121 +++ b/gcc/doc/invoke.texi
122 @@ -6565,6 +6565,17 @@ This option is only supported for C and
123 @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
124 @option{-Wno-pointer-sign}.
126 +@item -fhonour-copts
127 +@opindex fhonour-copts
128 +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
129 +given at least once, and warn if it is given more than once.
130 +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
132 +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
133 +is not given exactly once.
134 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
135 +This flag and environment variable only affect the C language.
137 @item -Wstack-protector
138 @opindex Wstack-protector
139 @opindex Wno-stack-protector