910-mbsd_multi.patch 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. @@ -105,6 +105,9 @@ static size_t include_cursor;
  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. @@ -384,6 +387,9 @@ c_common_handle_option (size_t scode, co
  26. cpp_opts->warn_endif_labels = value;
  27. break;
  28. + case OPT_Werror_maybe_reset:
  29. + break;
  30. +
  31. case OPT_Winvalid_pch:
  32. cpp_opts->warn_invalid_pch = value;
  33. break;
  34. @@ -492,6 +498,12 @@ c_common_handle_option (size_t scode, co
  35. flag_no_builtin = !value;
  36. break;
  37. + case OPT_fhonour_copts:
  38. + if (c_language == clk_c) {
  39. + honour_copts++;
  40. + }
  41. + break;
  42. +
  43. case OPT_fconstant_string_class_:
  44. constant_string_class_name = arg;
  45. break;
  46. @@ -1048,6 +1060,47 @@ c_common_init (void)
  47. return false;
  48. }
  49. + if (c_language == clk_c) {
  50. + char *ev = getenv ("GCC_HONOUR_COPTS");
  51. + int evv;
  52. + if (ev == NULL)
  53. + evv = -1;
  54. + else if ((*ev == '0') || (*ev == '\0'))
  55. + evv = 0;
  56. + else if (*ev == '1')
  57. + evv = 1;
  58. + else if (*ev == '2')
  59. + evv = 2;
  60. + else if (*ev == 's')
  61. + evv = -1;
  62. + else {
  63. + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
  64. + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
  65. + }
  66. + if (evv == 1) {
  67. + if (honour_copts == 0) {
  68. + error ("someone does not honour COPTS at all in lenient mode");
  69. + return false;
  70. + } else if (honour_copts != 1) {
  71. + warning (0, "someone does not honour COPTS correctly, passed %d times",
  72. + honour_copts);
  73. + }
  74. + } else if (evv == 2) {
  75. + if (honour_copts == 0) {
  76. + error ("someone does not honour COPTS at all in strict mode");
  77. + return false;
  78. + } else if (honour_copts != 1) {
  79. + error ("someone does not honour COPTS correctly, passed %d times",
  80. + honour_copts);
  81. + return false;
  82. + }
  83. + } else if (evv == 0) {
  84. + if (honour_copts != 1)
  85. + inform (0, "someone does not honour COPTS correctly, passed %d times",
  86. + honour_copts);
  87. + }
  88. + }
  89. +
  90. return true;
  91. }
  92. --- a/gcc/c-family/c.opt
  93. +++ b/gcc/c-family/c.opt
  94. @@ -391,6 +391,10 @@ Wfloat-conversion
  95. C ObjC C++ ObjC++ Var(warn_float_conversion) LangEnabledBy(C ObjC C++ ObjC++,Wconversion)
  96. Warn for implicit type conversions that cause loss of floating point precision
  97. +Werror-maybe-reset
  98. +C ObjC C++ ObjC++
  99. +; Documented in common.opt
  100. +
  101. Wfloat-equal
  102. C ObjC C++ ObjC++ Var(warn_float_equal) Warning
  103. Warn if testing floating point numbers for equality
  104. @@ -972,6 +976,9 @@ C++ ObjC++ Optimization Alias(fexception
  105. fhonor-std
  106. C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
  107. +fhonour-copts
  108. +C ObjC C++ ObjC++ RejectNegative
  109. +
  110. fhosted
  111. C ObjC
  112. Assume normal C execution environment
  113. --- a/gcc/common.opt
  114. +++ b/gcc/common.opt
  115. @@ -549,6 +549,10 @@ Werror=
  116. Common Joined
  117. Treat specified warning as error
  118. +Werror-maybe-reset
  119. +Common
  120. +If environment variable GCC_NO_WERROR is set, act as -Wno-error
  121. +
  122. Wextra
  123. Common Var(extra_warnings) Warning
  124. Print extra (possibly unwanted) warnings
  125. @@ -1287,6 +1291,9 @@ fguess-branch-probability
  126. Common Report Var(flag_guess_branch_prob) Optimization
  127. Enable guessing of branch probabilities
  128. +fhonour-copts
  129. +Common RejectNegative
  130. +
  131. ; Nonzero means ignore `#ident' directives. 0 means handle them.
  132. ; Generate position-independent code for executables if possible
  133. ; On SVR4 targets, it also controls whether or not to emit a
  134. --- a/gcc/opts.c
  135. +++ b/gcc/opts.c
  136. @@ -1572,6 +1572,17 @@ common_handle_option (struct gcc_options
  137. opts, opts_set, loc, dc);
  138. break;
  139. + case OPT_Werror_maybe_reset:
  140. + {
  141. + char *ev = getenv ("GCC_NO_WERROR");
  142. + if ((ev != NULL) && (*ev != '0'))
  143. + warnings_are_errors = 0;
  144. + }
  145. + break;
  146. +
  147. + case OPT_fhonour_copts:
  148. + break;
  149. +
  150. case OPT_Wlarger_than_:
  151. opts->x_larger_than_size = value;
  152. opts->x_warn_larger_than = value != -1;
  153. --- a/gcc/doc/cppopts.texi
  154. +++ b/gcc/doc/cppopts.texi
  155. @@ -163,6 +163,11 @@ in older programs. This warning is on b
  156. Make all warnings into hard errors. Source code which triggers warnings
  157. will be rejected.
  158. + at item -Werror-maybe-reset
  159. + at opindex Werror-maybe-reset
  160. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  161. +variable is set to anything other than 0 or empty.
  162. +
  163. @item -Wsystem-headers
  164. @opindex Wsystem-headers
  165. Issue warnings for code in system headers. These are normally unhelpful
  166. --- a/gcc/doc/invoke.texi
  167. +++ b/gcc/doc/invoke.texi
  168. @@ -243,7 +243,7 @@ Objective-C and Objective-C++ Dialects}.
  169. -Wconversion -Wcoverage-mismatch -Wdate-time -Wdelete-incomplete -Wno-cpp @gol
  170. -Wno-deprecated -Wno-deprecated-declarations -Wdisabled-optimization @gol
  171. -Wno-div-by-zero -Wdouble-promotion -Wempty-body -Wenum-compare @gol
  172. --Wno-endif-labels -Werror -Werror=* @gol
  173. +-Wno-endif-labels -Werror -Werror=* -Werror-maybe-reset @gol
  174. -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
  175. -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
  176. -Wformat-security -Wformat-y2k @gol
  177. @@ -5042,6 +5042,22 @@ This option is only supported for C and
  178. @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
  179. @option{-Wno-pointer-sign}.
  180. + at item -Werror-maybe-reset
  181. + at opindex Werror-maybe-reset
  182. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  183. +variable is set to anything other than 0 or empty.
  184. +
  185. + at item -fhonour-copts
  186. + at opindex fhonour-copts
  187. +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
  188. +given at least once, and warn if it is given more than once.
  189. +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
  190. +given exactly once.
  191. +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
  192. +is not given exactly once.
  193. +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
  194. +This flag and environment variable only affect the C language.
  195. +
  196. @item -Wstack-protector
  197. @opindex Wstack-protector
  198. @opindex Wno-stack-protector
  199. @@ -7194,7 +7210,7 @@ so, the first branch is redirected to ei
  200. second branch or a point immediately following it, depending on whether
  201. the condition is known to be true or false.
  202. -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
  203. +Enabled at levels @option{-O3}.
  204. @item -fsplit-wide-types
  205. @opindex fsplit-wide-types
  206. --- a/gcc/java/jvspec.c
  207. +++ b/gcc/java/jvspec.c
  208. @@ -626,6 +626,7 @@ lang_specific_pre_link (void)
  209. class name. Append dummy `.c' that can be stripped by set_input so %b
  210. is correct. */
  211. set_input (concat (main_class_name, "main.c", NULL));
  212. + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
  213. err = do_spec (jvgenmain_spec);
  214. if (err == 0)
  215. {