910-mbsd_multi.patch 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. * Make -fno-strict-aliasing and -fno-delete-null-pointer-checks
  13. the default for -O2/-Os, because they trigger gcc bugs
  14. and can delete code with security implications.
  15. This patch was authored by Thorsten Glaser <tg at mirbsd.de>
  16. with copyright assignment to the FSF in effect.
  17. Index: gcc-4.3.0/gcc/c-opts.c
  18. ===================================================================
  19. --- gcc-4.3.0.orig/gcc/c-opts.c 2007-07-31 02:27:12.007256629 +0200
  20. +++ gcc-4.3.0/gcc/c-opts.c 2007-07-31 02:27:39.324813371 +0200
  21. @@ -108,6 +108,9 @@
  22. /* Number of deferred options scanned for -include. */
  23. static size_t include_cursor;
  24. +/* Check if a port honours COPTS. */
  25. +static int honour_copts = 0;
  26. +
  27. static void set_Wimplicit (int);
  28. static void handle_OPT_d (const char *);
  29. static void set_std_cxx98 (int);
  30. @@ -462,6 +465,14 @@
  31. enable_warning_as_error ("implicit-function-declaration", value, CL_C | CL_ObjC);
  32. break;
  33. + case OPT_Werror_maybe_reset:
  34. + {
  35. + char *ev = getenv ("GCC_NO_WERROR");
  36. + if ((ev != NULL) && (*ev != '0'))
  37. + cpp_opts->warnings_are_errors = 0;
  38. + }
  39. + break;
  40. +
  41. case OPT_Wformat:
  42. set_Wformat (value);
  43. break;
  44. @@ -708,6 +719,12 @@
  45. flag_exceptions = value;
  46. break;
  47. + case OPT_fhonour_copts:
  48. + if (c_language == clk_c) {
  49. + honour_copts++;
  50. + }
  51. + break;
  52. +
  53. case OPT_fimplement_inlines:
  54. flag_implement_inlines = value;
  55. break;
  56. @@ -1248,6 +1265,47 @@
  57. /* Has to wait until now so that cpplib has its hash table. */
  58. init_pragma ();
  59. + if (c_language == clk_c) {
  60. + char *ev = getenv ("GCC_HONOUR_COPTS");
  61. + int evv;
  62. + if (ev == NULL)
  63. + evv = -1;
  64. + else if ((*ev == '0') || (*ev == '\0'))
  65. + evv = 0;
  66. + else if (*ev == '1')
  67. + evv = 1;
  68. + else if (*ev == '2')
  69. + evv = 2;
  70. + else if (*ev == 's')
  71. + evv = -1;
  72. + else {
  73. + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
  74. + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
  75. + }
  76. + if (evv == 1) {
  77. + if (honour_copts == 0) {
  78. + error ("someone does not honour COPTS at all in lenient mode");
  79. + return false;
  80. + } else if (honour_copts != 1) {
  81. + warning (0, "someone does not honour COPTS correctly, passed %d times",
  82. + honour_copts);
  83. + }
  84. + } else if (evv == 2) {
  85. + if (honour_copts == 0) {
  86. + error ("someone does not honour COPTS at all in strict mode");
  87. + return false;
  88. + } else if (honour_copts != 1) {
  89. + error ("someone does not honour COPTS correctly, passed %d times",
  90. + honour_copts);
  91. + return false;
  92. + }
  93. + } else if (evv == 0) {
  94. + if (honour_copts != 1)
  95. + inform ("someone does not honour COPTS correctly, passed %d times",
  96. + honour_copts);
  97. + }
  98. + }
  99. +
  100. return true;
  101. }
  102. Index: gcc-4.3.0/gcc/c.opt
  103. ===================================================================
  104. --- gcc-4.3.0.orig/gcc/c.opt 2007-07-31 02:27:12.015257093 +0200
  105. +++ gcc-4.3.0/gcc/c.opt 2007-07-31 02:27:39.328813597 +0200
  106. @@ -207,6 +207,10 @@
  107. C ObjC RejectNegative Warning
  108. This switch is deprecated; use -Werror=implicit-function-declaration instead
  109. +Werror-maybe-reset
  110. +C ObjC C++ ObjC++
  111. +; Documented in common.opt
  112. +
  113. Wfloat-equal
  114. C ObjC C++ ObjC++ Var(warn_float_equal) Warning
  115. Warn if testing floating point numbers for equality
  116. @@ -590,6 +594,9 @@
  117. fhonor-std
  118. C++ ObjC++
  119. +fhonour-copts
  120. +C ObjC C++ ObjC++ RejectNegative
  121. +
  122. fhosted
  123. C ObjC
  124. Assume normal C execution environment
  125. Index: gcc-4.3.0/gcc/common.opt
  126. ===================================================================
  127. --- gcc-4.3.0.orig/gcc/common.opt 2007-07-31 02:27:12.023257546 +0200
  128. +++ gcc-4.3.0/gcc/common.opt 2007-07-31 02:27:39.360815422 +0200
  129. @@ -102,6 +102,10 @@
  130. Common Joined
  131. Treat specified warning as error
  132. +Werror-maybe-reset
  133. +Common
  134. +If environment variable GCC_NO_WERROR is set, act as -Wno-error
  135. +
  136. Wextra
  137. Common Warning
  138. Print extra (possibly unwanted) warnings
  139. @@ -528,6 +532,9 @@
  140. Common Report Var(flag_guess_branch_prob) Optimization
  141. Enable guessing of branch probabilities
  142. +fhonour-copts
  143. +Common RejectNegative
  144. +
  145. ; Nonzero means ignore `#ident' directives. 0 means handle them.
  146. ; Generate position-independent code for executables if possible
  147. ; On SVR4 targets, it also controls whether or not to emit a
  148. Index: gcc-4.3.0/gcc/opts.c
  149. ===================================================================
  150. --- gcc-4.3.0.orig/gcc/opts.c 2007-07-31 02:27:12.031257991 +0200
  151. +++ gcc-4.3.0/gcc/opts.c 2007-07-31 02:28:36.320061346 +0200
  152. @@ -830,9 +830,6 @@
  153. flag_schedule_insns_after_reload = 1;
  154. #endif
  155. flag_regmove = 1;
  156. - flag_strict_aliasing = 1;
  157. - flag_strict_overflow = 1;
  158. - flag_delete_null_pointer_checks = 1;
  159. flag_reorder_blocks = 1;
  160. flag_reorder_functions = 1;
  161. flag_tree_store_ccp = 1;
  162. @@ -850,6 +847,10 @@
  163. if (optimize >= 3)
  164. {
  165. + flag_strict_aliasing = 1;
  166. + flag_strict_overflow = 1;
  167. + flag_delete_null_pointer_checks = 1;
  168. +
  169. flag_predictive_commoning = 1;
  170. flag_inline_functions = 1;
  171. flag_unswitch_loops = 1;
  172. @@ -1441,6 +1442,17 @@
  173. enable_warning_as_error (arg, value, lang_mask);
  174. break;
  175. + case OPT_Werror_maybe_reset:
  176. + {
  177. + char *ev = getenv ("GCC_NO_WERROR");
  178. + if ((ev != NULL) && (*ev != '0'))
  179. + warnings_are_errors = 0;
  180. + }
  181. + break;
  182. +
  183. + case OPT_fhonour_copts:
  184. + break;
  185. +
  186. case OPT_Wextra:
  187. set_Wextra (value);
  188. break;
  189. Index: gcc-4.3.0/gcc/doc/cppopts.texi
  190. ===================================================================
  191. --- gcc-4.3.0.orig/gcc/doc/cppopts.texi 2007-07-31 02:27:12.039258455 +0200
  192. +++ gcc-4.3.0/gcc/doc/cppopts.texi 2007-07-31 02:27:39.408818157 +0200
  193. @@ -168,6 +168,11 @@
  194. Make all warnings into hard errors. Source code which triggers warnings
  195. will be rejected.
  196. + at item -Werror-maybe-reset
  197. + at opindex Werror-maybe-reset
  198. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  199. +variable is set to anything other than 0 or empty.
  200. +
  201. @item -Wsystem-headers
  202. @opindex Wsystem-headers
  203. Issue warnings for code in system headers. These are normally unhelpful
  204. Index: gcc-4.3.0/gcc/doc/invoke.texi
  205. ===================================================================
  206. --- gcc-4.3.0.orig/gcc/doc/invoke.texi 2007-07-31 02:27:12.047258920 +0200
  207. +++ gcc-4.3.0/gcc/doc/invoke.texi 2007-07-31 02:29:13.218164047 +0200
  208. @@ -233,7 +233,7 @@
  209. -Wconversion -Wcoverage-mismatch -Wno-deprecated-declarations @gol
  210. -Wdisabled-optimization -Wno-div-by-zero @gol
  211. -Wempty-body -Wno-endif-labels @gol
  212. --Werror -Werror=* @gol
  213. +-Werror -Werror=* -Werror-maybe-reset @gol
  214. -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
  215. -Wno-format-extra-args -Wformat-nonliteral @gol
  216. -Wformat-security -Wformat-y2k -Wignored-qualifiers @gol
  217. @@ -4030,6 +4030,22 @@
  218. @option{-Wall} and by @option{-pedantic}, which can be disabled with
  219. @option{-Wno-pointer-sign}.
  220. + at item -Werror-maybe-reset
  221. + at opindex Werror-maybe-reset
  222. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  223. +variable is set to anything other than 0 or empty.
  224. +
  225. + at item -fhonour-copts
  226. + at opindex fhonour-copts
  227. +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
  228. +given at least once, and warn if it is given more than once.
  229. +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
  230. +given exactly once.
  231. +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
  232. +is not given exactly once.
  233. +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
  234. +This flag and environment variable only affect the C language.
  235. +
  236. @item -Wstack-protector
  237. @opindex Wstack-protector
  238. @opindex Wno-stack-protector
  239. @@ -5490,7 +5806,7 @@
  240. second branch or a point immediately following it, depending on whether
  241. the condition is known to be true or false.
  242. -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
  243. +Enabled at levels @option{-O3}.
  244. @item -fsplit-wide-types
  245. @opindex fsplit-wide-types
  246. @@ -5635,7 +5514,7 @@
  247. @option{-fno-delete-null-pointer-checks} to disable this optimization
  248. for programs which depend on that behavior.
  249. -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
  250. +Enabled at levels @option{-O3}.
  251. @item -fexpensive-optimizations
  252. @opindex fexpensive-optimizations
  253. Index: gcc-4.3.0/gcc/java/jvspec.c
  254. ===================================================================
  255. --- gcc-4.3.0.orig/gcc/java/jvspec.c 2007-07-31 02:27:12.055259364 +0200
  256. +++ gcc-4.3.0/gcc/java/jvspec.c 2007-07-31 02:27:39.484822490 +0200
  257. @@ -670,6 +670,7 @@
  258. class name. Append dummy `.c' that can be stripped by set_input so %b
  259. is correct. */
  260. set_input (concat (main_class_name, "main.c", NULL));
  261. + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
  262. err = do_spec (jvgenmain_spec);
  263. if (err == 0)
  264. {