cflags.patch 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. diff -Nur gcc-4.4.7.orig/gcc/common.opt gcc-4.4.7/gcc/common.opt
  2. --- gcc-4.4.7.orig/gcc/common.opt 2009-03-28 18:28:45.000000000 +0100
  3. +++ gcc-4.4.7/gcc/common.opt 2014-09-09 19:50:59.000000000 +0200
  4. @@ -102,6 +102,10 @@
  5. Common Joined
  6. Treat specified warning as error
  7. +Werror-maybe-reset
  8. +Common
  9. +If environment variable GCC_NO_WERROR is set, act as -Wno-error
  10. +
  11. Wextra
  12. Common Warning
  13. Print extra (possibly unwanted) warnings
  14. @@ -573,6 +577,9 @@
  15. Common Report Var(flag_guess_branch_prob) Optimization
  16. Enable guessing of branch probabilities
  17. +fhonour-copts
  18. +Common RejectNegative
  19. +
  20. ; Nonzero means ignore `#ident' directives. 0 means handle them.
  21. ; Generate position-independent code for executables if possible
  22. ; On SVR4 targets, it also controls whether or not to emit a
  23. diff -Nur gcc-4.4.7.orig/gcc/c.opt gcc-4.4.7/gcc/c.opt
  24. --- gcc-4.4.7.orig/gcc/c.opt 2009-09-18 23:53:23.000000000 +0200
  25. +++ gcc-4.4.7/gcc/c.opt 2014-09-09 19:50:59.000000000 +0200
  26. @@ -215,6 +215,10 @@
  27. C ObjC RejectNegative Warning
  28. This switch is deprecated; use -Werror=implicit-function-declaration instead
  29. +Werror-maybe-reset
  30. +C ObjC C++ ObjC++
  31. +; Documented in common.opt
  32. +
  33. Wfloat-equal
  34. C ObjC C++ ObjC++ Var(warn_float_equal) Warning
  35. Warn if testing floating point numbers for equality
  36. @@ -613,6 +617,9 @@
  37. fhonor-std
  38. C++ ObjC++
  39. +fhonour-copts
  40. +C ObjC C++ ObjC++ RejectNegative
  41. +
  42. fhosted
  43. C ObjC
  44. Assume normal C execution environment
  45. diff -Nur gcc-4.4.7.orig/gcc/c-opts.c gcc-4.4.7/gcc/c-opts.c
  46. --- gcc-4.4.7.orig/gcc/c-opts.c 2009-02-18 03:16:03.000000000 +0100
  47. +++ gcc-4.4.7/gcc/c-opts.c 2014-09-09 19:50:59.000000000 +0200
  48. @@ -105,6 +105,9 @@
  49. /* Number of deferred options scanned for -include. */
  50. static size_t include_cursor;
  51. +/* Check if a port honours COPTS. */
  52. +static int honour_copts = 0;
  53. +
  54. static void set_Wimplicit (int);
  55. static void handle_OPT_d (const char *);
  56. static void set_std_cxx98 (int);
  57. @@ -454,6 +457,14 @@
  58. enable_warning_as_error ("implicit-function-declaration", value, CL_C | CL_ObjC);
  59. break;
  60. + case OPT_Werror_maybe_reset:
  61. + {
  62. + char *ev = getenv ("GCC_NO_WERROR");
  63. + if ((ev != NULL) && (*ev != '0'))
  64. + cpp_opts->warnings_are_errors = 0;
  65. + }
  66. + break;
  67. +
  68. case OPT_Wformat:
  69. set_Wformat (value);
  70. break;
  71. @@ -690,6 +701,12 @@
  72. flag_exceptions = value;
  73. break;
  74. + case OPT_fhonour_copts:
  75. + if (c_language == clk_c) {
  76. + honour_copts++;
  77. + }
  78. + break;
  79. +
  80. case OPT_fimplement_inlines:
  81. flag_implement_inlines = value;
  82. break;
  83. @@ -1209,6 +1226,47 @@
  84. return false;
  85. }
  86. + if (c_language == clk_c) {
  87. + char *ev = getenv ("GCC_HONOUR_COPTS");
  88. + int evv;
  89. + if (ev == NULL)
  90. + evv = -1;
  91. + else if ((*ev == '0') || (*ev == '\0'))
  92. + evv = 0;
  93. + else if (*ev == '1')
  94. + evv = 1;
  95. + else if (*ev == '2')
  96. + evv = 2;
  97. + else if (*ev == 's')
  98. + evv = -1;
  99. + else {
  100. + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
  101. + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
  102. + }
  103. + if (evv == 1) {
  104. + if (honour_copts == 0) {
  105. + error ("someone does not honour COPTS at all in lenient mode");
  106. + return false;
  107. + } else if (honour_copts != 1) {
  108. + warning (0, "someone does not honour COPTS correctly, passed %d times",
  109. + honour_copts);
  110. + }
  111. + } else if (evv == 2) {
  112. + if (honour_copts == 0) {
  113. + error ("someone does not honour COPTS at all in strict mode");
  114. + return false;
  115. + } else if (honour_copts != 1) {
  116. + error ("someone does not honour COPTS correctly, passed %d times",
  117. + honour_copts);
  118. + return false;
  119. + }
  120. + } else if (evv == 0) {
  121. + if (honour_copts != 1)
  122. + inform (0, "someone does not honour COPTS correctly, passed %d times",
  123. + honour_copts);
  124. + }
  125. + }
  126. +
  127. return true;
  128. }
  129. diff -Nur gcc-4.4.7.orig/gcc/doc/cppopts.texi gcc-4.4.7/gcc/doc/cppopts.texi
  130. --- gcc-4.4.7.orig/gcc/doc/cppopts.texi 2008-06-15 11:42:13.000000000 +0200
  131. +++ gcc-4.4.7/gcc/doc/cppopts.texi 2014-09-09 19:50:59.000000000 +0200
  132. @@ -164,6 +164,11 @@
  133. Make all warnings into hard errors. Source code which triggers warnings
  134. will be rejected.
  135. + at item -Werror-maybe-reset
  136. + at opindex Werror-maybe-reset
  137. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  138. +variable is set to anything other than 0 or empty.
  139. +
  140. @item -Wsystem-headers
  141. @opindex Wsystem-headers
  142. Issue warnings for code in system headers. These are normally unhelpful
  143. diff -Nur gcc-4.4.7.orig/gcc/doc/invoke.texi gcc-4.4.7/gcc/doc/invoke.texi
  144. --- gcc-4.4.7.orig/gcc/doc/invoke.texi 2011-03-23 23:02:12.000000000 +0100
  145. +++ gcc-4.4.7/gcc/doc/invoke.texi 2014-09-09 19:50:59.000000000 +0200
  146. @@ -234,7 +234,7 @@
  147. -Wconversion -Wcoverage-mismatch -Wno-deprecated @gol
  148. -Wno-deprecated-declarations -Wdisabled-optimization @gol
  149. -Wno-div-by-zero -Wempty-body -Wenum-compare -Wno-endif-labels @gol
  150. --Werror -Werror=* @gol
  151. +-Werror -Werror=* -Werror-maybe-reset @gol
  152. -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
  153. -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
  154. -Wformat-security -Wformat-y2k @gol
  155. @@ -4182,6 +4182,22 @@
  156. @option{-Wall} and by @option{-pedantic}, which can be disabled with
  157. @option{-Wno-pointer-sign}.
  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. + at item -fhonour-copts
  164. + at opindex fhonour-copts
  165. +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
  166. +given at least once, and warn if it is given more than once.
  167. +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
  168. +given exactly once.
  169. +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
  170. +is not given exactly once.
  171. +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
  172. +This flag and environment variable only affect the C language.
  173. +
  174. @item -Wstack-protector
  175. @opindex Wstack-protector
  176. @opindex Wno-stack-protector
  177. @@ -5721,7 +5737,7 @@
  178. second branch or a point immediately following it, depending on whether
  179. the condition is known to be true or false.
  180. -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
  181. +Enabled at levels @option{-O3}.
  182. @item -fsplit-wide-types
  183. @opindex fsplit-wide-types
  184. @@ -5866,7 +5882,7 @@
  185. @option{-fno-delete-null-pointer-checks} to disable this optimization
  186. for programs which depend on that behavior.
  187. -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
  188. +Enabled at levels @option{-O3}.
  189. @item -fexpensive-optimizations
  190. @opindex fexpensive-optimizations
  191. diff -Nur gcc-4.4.7.orig/gcc/java/jvspec.c gcc-4.4.7/gcc/java/jvspec.c
  192. --- gcc-4.4.7.orig/gcc/java/jvspec.c 2007-07-31 18:19:49.000000000 +0200
  193. +++ gcc-4.4.7/gcc/java/jvspec.c 2014-09-09 19:50:59.000000000 +0200
  194. @@ -670,6 +670,7 @@
  195. class name. Append dummy `.c' that can be stripped by set_input so %b
  196. is correct. */
  197. set_input (concat (main_class_name, "main.c", NULL));
  198. + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
  199. err = do_spec (jvgenmain_spec);
  200. if (err == 0)
  201. {
  202. diff -Nur gcc-4.4.7.orig/gcc/opts.c gcc-4.4.7/gcc/opts.c
  203. --- gcc-4.4.7.orig/gcc/opts.c 2009-11-27 12:34:32.000000000 +0100
  204. +++ gcc-4.4.7/gcc/opts.c 2014-09-09 19:50:59.000000000 +0200
  205. @@ -898,9 +898,6 @@
  206. flag_schedule_insns_after_reload = opt2;
  207. #endif
  208. flag_regmove = opt2;
  209. - flag_strict_aliasing = opt2;
  210. - flag_strict_overflow = opt2;
  211. - flag_delete_null_pointer_checks = opt2;
  212. flag_reorder_blocks = opt2;
  213. flag_reorder_functions = opt2;
  214. flag_tree_vrp = opt2;
  215. @@ -924,6 +921,9 @@
  216. /* -O3 optimizations. */
  217. opt3 = (optimize >= 3);
  218. + flag_strict_aliasing = opt3;
  219. + flag_strict_overflow = opt3;
  220. + flag_delete_null_pointer_checks = opt3;
  221. flag_predictive_commoning = opt3;
  222. flag_inline_functions = opt3;
  223. flag_unswitch_loops = opt3;
  224. @@ -1603,6 +1603,17 @@
  225. enable_warning_as_error (arg, value, lang_mask);
  226. break;
  227. + case OPT_Werror_maybe_reset:
  228. + {
  229. + char *ev = getenv ("GCC_NO_WERROR");
  230. + if ((ev != NULL) && (*ev != '0'))
  231. + warnings_are_errors = 0;
  232. + }
  233. + break;
  234. +
  235. + case OPT_fhonour_copts:
  236. + break;
  237. +
  238. case OPT_Wextra:
  239. set_Wextra (value);
  240. break;