910-mbsd_multi.patch 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. This patch brings over a few features from MirBSD:
  2. * -fhonour-copts
  3. If this option is not given, it's warned (depending
  4. on environment variables). This is to catch errors
  5. of misbuilt packages which override CFLAGS themselves.
  6. * -Werror-maybe-reset
  7. Has the effect of -Wno-error if GCC_NO_WERROR is
  8. set and not '0', a no-operation otherwise. This is
  9. to be able to use -Werror in "make" but prevent
  10. GNU autoconf generated configure scripts from
  11. freaking out.
  12. This patch was authored by Thorsten Glaser <tg at mirbsd.de>
  13. with copyright assignment to the FSF in effect.
  14. --- a/gcc/c-family/c-opts.c
  15. +++ b/gcc/c-family/c-opts.c
  16. @@ -122,6 +122,9 @@ static int class_dump_flags;
  17. /* Whether any standard preincluded header has been preincluded. */
  18. static bool done_preinclude;
  19. +/* Check if a port honours COPTS. */
  20. +static int honour_copts = 0;
  21. +
  22. static void handle_OPT_d (const char *);
  23. static void set_std_cxx98 (int);
  24. static void set_std_cxx11 (int);
  25. @@ -449,6 +452,12 @@ c_common_handle_option (size_t scode, co
  26. flag_no_builtin = !value;
  27. break;
  28. + case OPT_fhonour_copts:
  29. + if (c_language == clk_c) {
  30. + honour_copts++;
  31. + }
  32. + break;
  33. +
  34. case OPT_fconstant_string_class_:
  35. constant_string_class_name = arg;
  36. break;
  37. @@ -1034,6 +1043,47 @@ c_common_init (void)
  38. return false;
  39. }
  40. + if (c_language == clk_c) {
  41. + char *ev = getenv ("GCC_HONOUR_COPTS");
  42. + int evv;
  43. + if (ev == NULL)
  44. + evv = -1;
  45. + else if ((*ev == '0') || (*ev == '\0'))
  46. + evv = 0;
  47. + else if (*ev == '1')
  48. + evv = 1;
  49. + else if (*ev == '2')
  50. + evv = 2;
  51. + else if (*ev == 's')
  52. + evv = -1;
  53. + else {
  54. + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
  55. + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
  56. + }
  57. + if (evv == 1) {
  58. + if (honour_copts == 0) {
  59. + error ("someone does not honour COPTS at all in lenient mode");
  60. + return false;
  61. + } else if (honour_copts != 1) {
  62. + warning (0, "someone does not honour COPTS correctly, passed %d times",
  63. + honour_copts);
  64. + }
  65. + } else if (evv == 2) {
  66. + if (honour_copts == 0) {
  67. + error ("someone does not honour COPTS at all in strict mode");
  68. + return false;
  69. + } else if (honour_copts != 1) {
  70. + error ("someone does not honour COPTS correctly, passed %d times",
  71. + honour_copts);
  72. + return false;
  73. + }
  74. + } else if (evv == 0) {
  75. + if (honour_copts != 1)
  76. + inform (0, "someone does not honour COPTS correctly, passed %d times",
  77. + honour_copts);
  78. + }
  79. + }
  80. +
  81. return true;
  82. }
  83. --- a/gcc/c-family/c.opt
  84. +++ b/gcc/c-family/c.opt
  85. @@ -431,6 +431,10 @@ Wfloat-conversion
  86. C ObjC C++ ObjC++ Var(warn_float_conversion) LangEnabledBy(C ObjC C++ ObjC++,Wconversion)
  87. Warn for implicit type conversions that cause loss of floating point precision
  88. +Werror-maybe-reset
  89. +C ObjC C++ ObjC++
  90. +; Documented in common.opt
  91. +
  92. Wfloat-equal
  93. C ObjC C++ ObjC++ Var(warn_float_equal) Warning
  94. Warn if testing floating point numbers for equality
  95. @@ -1161,6 +1165,9 @@ C++ ObjC++ Optimization Alias(fexception
  96. fhonor-std
  97. C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
  98. +fhonour-copts
  99. +C ObjC C++ ObjC++ RejectNegative
  100. +
  101. fhosted
  102. C ObjC
  103. Assume normal C execution environment
  104. --- a/gcc/common.opt
  105. +++ b/gcc/common.opt
  106. @@ -561,6 +561,10 @@ Werror=
  107. Common Joined
  108. Treat specified warning as error
  109. +Werror-maybe-reset
  110. +Common
  111. +If environment variable GCC_NO_WERROR is set, act as -Wno-error
  112. +
  113. Wextra
  114. Common Var(extra_warnings) Warning
  115. Print extra (possibly unwanted) warnings
  116. @@ -1360,6 +1364,9 @@ fguess-branch-probability
  117. Common Report Var(flag_guess_branch_prob) Optimization
  118. Enable guessing of branch probabilities
  119. +fhonour-copts
  120. +Common RejectNegative
  121. +
  122. ; Nonzero means ignore `#ident' directives. 0 means handle them.
  123. ; Generate position-independent code for executables if possible
  124. ; On SVR4 targets, it also controls whether or not to emit a
  125. --- a/gcc/opts.c
  126. +++ b/gcc/opts.c
  127. @@ -1699,6 +1699,17 @@ common_handle_option (struct gcc_options
  128. opts, opts_set, loc, dc);
  129. break;
  130. + case OPT_Werror_maybe_reset:
  131. + {
  132. + char *ev = getenv ("GCC_NO_WERROR");
  133. + if ((ev != NULL) && (*ev != '0'))
  134. + warnings_are_errors = 0;
  135. + }
  136. + break;
  137. +
  138. + case OPT_fhonour_copts:
  139. + break;
  140. +
  141. case OPT_Wlarger_than_:
  142. opts->x_larger_than_size = value;
  143. opts->x_warn_larger_than = value != -1;
  144. --- a/gcc/doc/cppopts.texi
  145. +++ b/gcc/doc/cppopts.texi
  146. @@ -163,6 +163,11 @@ in older programs. This warning is on b
  147. Make all warnings into hard errors. Source code which triggers warnings
  148. will be rejected.
  149. + at item -Werror-maybe-reset
  150. + at opindex Werror-maybe-reset
  151. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  152. +variable is set to anything other than 0 or empty.
  153. +
  154. @item -Wsystem-headers
  155. @opindex Wsystem-headers
  156. Issue warnings for code in system headers. These are normally unhelpful
  157. --- a/gcc/doc/invoke.texi
  158. +++ b/gcc/doc/invoke.texi
  159. @@ -251,7 +251,7 @@ Objective-C and Objective-C++ Dialects}.
  160. -Wdisabled-optimization @gol
  161. -Wno-discarded-qualifiers -Wno-discarded-array-qualifiers @gol
  162. -Wno-div-by-zero -Wdouble-promotion -Wempty-body -Wenum-compare @gol
  163. --Wno-endif-labels -Werror -Werror=* @gol
  164. +-Wno-endif-labels -Werror -Werror=* -Werror-maybe-reset @gol
  165. -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
  166. -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
  167. -Wformat-security -Wformat-signedness -Wformat-y2k @gol
  168. @@ -5371,6 +5371,22 @@ This option is only supported for C and
  169. @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
  170. @option{-Wno-pointer-sign}.
  171. + at item -Werror-maybe-reset
  172. + at opindex Werror-maybe-reset
  173. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  174. +variable is set to anything other than 0 or empty.
  175. +
  176. + at item -fhonour-copts
  177. + at opindex fhonour-copts
  178. +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
  179. +given at least once, and warn if it is given more than once.
  180. +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
  181. +given exactly once.
  182. +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
  183. +is not given exactly once.
  184. +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
  185. +This flag and environment variable only affect the C language.
  186. +
  187. @item -Wstack-protector
  188. @opindex Wstack-protector
  189. @opindex Wno-stack-protector
  190. @@ -7845,7 +7861,7 @@ so, the first branch is redirected to ei
  191. second branch or a point immediately following it, depending on whether
  192. the condition is known to be true or false.
  193. -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
  194. +Enabled at levels @option{-O3}.
  195. @item -fsplit-wide-types
  196. @opindex fsplit-wide-types
  197. --- a/gcc/java/jvspec.c
  198. +++ b/gcc/java/jvspec.c
  199. @@ -629,6 +629,7 @@ lang_specific_pre_link (void)
  200. class name. Append dummy `.c' that can be stripped by set_input so %b
  201. is correct. */
  202. set_input (concat (main_class_name, "main.c", NULL));
  203. + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
  204. err = do_spec (jvgenmain_spec);
  205. if (err == 0)
  206. {