286cfadae7064086b8c3ae9f949631cca4f400e7
[openwrt/staging/chunkeey.git] / toolchain / gcc / patches / arc-2017.09-release / 910-mbsd_multi.patch
1 commit 99368862e44740ff4fd33760893f04e14f9dbdf1
2 Author: Felix Fietkau <nbd@openwrt.org>
3 Date: Tue Jul 31 00:52:27 2007 +0000
4
5 Port the mbsd_multi patch from freewrt, which adds -fhonour-copts. This will emit warnings in packages that don't use our target cflags properly
6
7 SVN-Revision: 8256
8
9 This patch brings over a feature from MirBSD:
10 * -fhonour-copts
11 If this option is not given, it's warned (depending
12 on environment variables). This is to catch errors
13 of misbuilt packages which override CFLAGS themselves.
14
15 This patch was authored by Thorsten Glaser <tg at mirbsd.de>
16 with copyright assignment to the FSF in effect.
17
18 --- a/gcc/c-family/c-opts.c
19 +++ b/gcc/c-family/c-opts.c
20 @@ -108,6 +108,9 @@ static int class_dump_flags;
21 /* Whether any standard preincluded header has been preincluded. */
22 static bool done_preinclude;
23
24 +/* Check if a port honours COPTS. */
25 +static int honour_copts = 0;
26 +
27 static void handle_OPT_d (const char *);
28 static void set_std_cxx98 (int);
29 static void set_std_cxx11 (int);
30 @@ -456,6 +459,12 @@ c_common_handle_option (size_t scode, co
31 flag_no_builtin = !value;
32 break;
33
34 + case OPT_fhonour_copts:
35 + if (c_language == clk_c) {
36 + honour_copts++;
37 + }
38 + break;
39 +
40 case OPT_fconstant_string_class_:
41 constant_string_class_name = arg;
42 break;
43 @@ -1084,6 +1093,47 @@ c_common_init (void)
44 return false;
45 }
46
47 + if (c_language == clk_c) {
48 + char *ev = getenv ("GCC_HONOUR_COPTS");
49 + int evv;
50 + if (ev == NULL)
51 + evv = -1;
52 + else if ((*ev == '0') || (*ev == '\0'))
53 + evv = 0;
54 + else if (*ev == '1')
55 + evv = 1;
56 + else if (*ev == '2')
57 + evv = 2;
58 + else if (*ev == 's')
59 + evv = -1;
60 + else {
61 + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
62 + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
63 + }
64 + if (evv == 1) {
65 + if (honour_copts == 0) {
66 + error ("someone does not honour COPTS at all in lenient mode");
67 + return false;
68 + } else if (honour_copts != 1) {
69 + warning (0, "someone does not honour COPTS correctly, passed %d times",
70 + honour_copts);
71 + }
72 + } else if (evv == 2) {
73 + if (honour_copts == 0) {
74 + error ("someone does not honour COPTS at all in strict mode");
75 + return false;
76 + } else if (honour_copts != 1) {
77 + error ("someone does not honour COPTS correctly, passed %d times",
78 + honour_copts);
79 + return false;
80 + }
81 + } else if (evv == 0) {
82 + if (honour_copts != 1)
83 + inform (0, "someone does not honour COPTS correctly, passed %d times",
84 + honour_copts);
85 + }
86 + }
87 +
88 return true;
89 }
90
91 --- a/gcc/c-family/c.opt
92 +++ b/gcc/c-family/c.opt
93 @@ -1412,6 +1412,9 @@ C++ ObjC++ Optimization Alias(fexception
94 fhonor-std
95 C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
96
97 +fhonour-copts
98 +C ObjC C++ ObjC++ RejectNegative
99 +
100 fhosted
101 C ObjC
102 Assume normal C execution environment.
103 --- a/gcc/common.opt
104 +++ b/gcc/common.opt
105 @@ -1510,6 +1510,9 @@ fguess-branch-probability
106 Common Report Var(flag_guess_branch_prob) Optimization
107 Enable guessing of branch probabilities.
108
109 +fhonour-copts
110 +Common RejectNegative
111 +
112 ; Nonzero means ignore `#ident' directives. 0 means handle them.
113 ; Generate position-independent code for executables if possible
114 ; On SVR4 targets, it also controls whether or not to emit a
115 --- a/gcc/opts.c
116 +++ b/gcc/opts.c
117 @@ -1928,6 +1928,9 @@ common_handle_option (struct gcc_options
118 opts, opts_set, loc, dc);
119 break;
120
121 + case OPT_fhonour_copts:
122 + break;
123 +
124 case OPT_Wlarger_than_:
125 opts->x_larger_than_size = value;
126 opts->x_warn_larger_than = value != -1;
127 --- a/gcc/doc/invoke.texi
128 +++ b/gcc/doc/invoke.texi
129 @@ -6567,6 +6567,17 @@ This option is only supported for C and
130 @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
131 @option{-Wno-pointer-sign}.
132
133 +@item -fhonour-copts
134 +@opindex fhonour-copts
135 +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
136 +given at least once, and warn if it is given more than once.
137 +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
138 +given exactly once.
139 +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
140 +is not given exactly once.
141 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
142 +This flag and environment variable only affect the C language.
143 +
144 @item -Wstack-protector
145 @opindex Wstack-protector
146 @opindex Wno-stack-protector