1
0

cflags.patch 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. diff -Nur gcc-4.7.2.orig/gcc/c-family/c-opts.c gcc-4.7.2/gcc/c-family/c-opts.c
  2. --- gcc-4.7.2.orig/gcc/c-family/c-opts.c 2012-01-18 14:10:40.000000000 +0100
  3. +++ gcc-4.7.2/gcc/c-family/c-opts.c 2012-09-22 12:53:33.000000000 +0200
  4. @@ -108,6 +108,9 @@
  5. /* Number of deferred options scanned for -include. */
  6. static size_t include_cursor;
  7. +/* Check if a port honours COPTS. */
  8. +static int honour_copts = 0;
  9. +
  10. static void handle_OPT_d (const char *);
  11. static void set_std_cxx98 (int);
  12. static void set_std_cxx11 (int);
  13. @@ -449,6 +452,9 @@
  14. cpp_opts->warn_endif_labels = value;
  15. break;
  16. + case OPT_Werror_maybe_reset:
  17. + break;
  18. +
  19. case OPT_Wformat:
  20. set_Wformat (value);
  21. break;
  22. @@ -592,6 +598,12 @@
  23. flag_no_builtin = !value;
  24. break;
  25. + case OPT_fhonour_copts:
  26. + if (c_language == clk_c) {
  27. + honour_copts++;
  28. + }
  29. + break;
  30. +
  31. case OPT_fconstant_string_class_:
  32. constant_string_class_name = arg;
  33. break;
  34. @@ -1098,6 +1110,47 @@
  35. return false;
  36. }
  37. + if (c_language == clk_c) {
  38. + char *ev = getenv ("GCC_HONOUR_COPTS");
  39. + int evv;
  40. + if (ev == NULL)
  41. + evv = -1;
  42. + else if ((*ev == '0') || (*ev == '\0'))
  43. + evv = 0;
  44. + else if (*ev == '1')
  45. + evv = 1;
  46. + else if (*ev == '2')
  47. + evv = 2;
  48. + else if (*ev == 's')
  49. + evv = -1;
  50. + else {
  51. + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
  52. + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
  53. + }
  54. + if (evv == 1) {
  55. + if (honour_copts == 0) {
  56. + error ("someone does not honour COPTS at all in lenient mode");
  57. + return false;
  58. + } else if (honour_copts != 1) {
  59. + warning (0, "someone does not honour COPTS correctly, passed %d times",
  60. + honour_copts);
  61. + }
  62. + } else if (evv == 2) {
  63. + if (honour_copts == 0) {
  64. + error ("someone does not honour COPTS at all in strict mode");
  65. + return false;
  66. + } else if (honour_copts != 1) {
  67. + error ("someone does not honour COPTS correctly, passed %d times",
  68. + honour_copts);
  69. + return false;
  70. + }
  71. + } else if (evv == 0) {
  72. + if (honour_copts != 1)
  73. + inform (0, "someone does not honour COPTS correctly, passed %d times",
  74. + honour_copts);
  75. + }
  76. + }
  77. +
  78. return true;
  79. }
  80. diff -Nur gcc-4.7.2.orig/gcc/c-family/c.opt gcc-4.7.2/gcc/c-family/c.opt
  81. --- gcc-4.7.2.orig/gcc/c-family/c.opt 2012-02-06 11:31:18.000000000 +0100
  82. +++ gcc-4.7.2/gcc/c-family/c.opt 2012-09-22 12:53:33.000000000 +0200
  83. @@ -371,6 +371,10 @@
  84. C ObjC RejectNegative Warning Alias(Werror=, implicit-function-declaration)
  85. This switch is deprecated; use -Werror=implicit-function-declaration instead
  86. +Werror-maybe-reset
  87. +C ObjC C++ ObjC++
  88. +; Documented in common.opt
  89. +
  90. Wfloat-equal
  91. C ObjC C++ ObjC++ Var(warn_float_equal) Warning
  92. Warn if testing floating point numbers for equality
  93. @@ -830,6 +834,9 @@
  94. fhonor-std
  95. C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
  96. +fhonour-copts
  97. +C ObjC C++ ObjC++ RejectNegative
  98. +
  99. fhosted
  100. C ObjC
  101. Assume normal C execution environment
  102. diff -Nur gcc-4.7.2.orig/gcc/common.opt gcc-4.7.2/gcc/common.opt
  103. --- gcc-4.7.2.orig/gcc/common.opt 2012-08-06 16:34:27.000000000 +0200
  104. +++ gcc-4.7.2/gcc/common.opt 2012-09-22 12:53:33.000000000 +0200
  105. @@ -531,6 +531,10 @@
  106. Common Joined
  107. Treat specified warning as error
  108. +Werror-maybe-reset
  109. +Common
  110. +If environment variable GCC_NO_WERROR is set, act as -Wno-error
  111. +
  112. Wextra
  113. Common Var(extra_warnings) Warning
  114. Print extra (possibly unwanted) warnings
  115. @@ -1209,6 +1213,9 @@
  116. Common Report Var(flag_guess_branch_prob) Optimization
  117. Enable guessing of branch probabilities
  118. +fhonour-copts
  119. +Common RejectNegative
  120. +
  121. ; Nonzero means ignore `#ident' directives. 0 means handle them.
  122. ; Generate position-independent code for executables if possible
  123. ; On SVR4 targets, it also controls whether or not to emit a
  124. diff -Nur gcc-4.7.2.orig/gcc/doc/cppopts.texi gcc-4.7.2/gcc/doc/cppopts.texi
  125. --- gcc-4.7.2.orig/gcc/doc/cppopts.texi 2011-12-20 21:44:13.000000000 +0100
  126. +++ gcc-4.7.2/gcc/doc/cppopts.texi 2012-09-22 12:53:33.000000000 +0200
  127. @@ -164,6 +164,11 @@
  128. Make all warnings into hard errors. Source code which triggers warnings
  129. will be rejected.
  130. + at item -Werror-maybe-reset
  131. + at opindex Werror-maybe-reset
  132. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  133. +variable is set to anything other than 0 or empty.
  134. +
  135. @item -Wsystem-headers
  136. @opindex Wsystem-headers
  137. Issue warnings for code in system headers. These are normally unhelpful
  138. diff -Nur gcc-4.7.2.orig/gcc/doc/invoke.texi gcc-4.7.2/gcc/doc/invoke.texi
  139. --- gcc-4.7.2.orig/gcc/doc/invoke.texi 2012-09-14 22:45:27.000000000 +0200
  140. +++ gcc-4.7.2/gcc/doc/invoke.texi 2012-09-22 12:53:33.000000000 +0200
  141. @@ -242,7 +242,7 @@
  142. -Wconversion -Wcoverage-mismatch -Wno-cpp -Wno-deprecated @gol
  143. -Wno-deprecated-declarations -Wdisabled-optimization @gol
  144. -Wno-div-by-zero -Wdouble-promotion -Wempty-body -Wenum-compare @gol
  145. --Wno-endif-labels -Werror -Werror=* @gol
  146. +-Wno-endif-labels -Werror -Werror=* -Werror-maybe-reset @gol
  147. -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
  148. -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
  149. -Wformat-security -Wformat-y2k @gol
  150. @@ -4651,6 +4651,22 @@
  151. @option{-Wall} and by @option{-pedantic}, which can be disabled with
  152. @option{-Wno-pointer-sign}.
  153. + at item -Werror-maybe-reset
  154. + at opindex Werror-maybe-reset
  155. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  156. +variable is set to anything other than 0 or empty.
  157. +
  158. + at item -fhonour-copts
  159. + at opindex fhonour-copts
  160. +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
  161. +given at least once, and warn if it is given more than once.
  162. +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
  163. +given exactly once.
  164. +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
  165. +is not given exactly once.
  166. +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
  167. +This flag and environment variable only affect the C language.
  168. +
  169. @item -Wstack-protector
  170. @opindex Wstack-protector
  171. @opindex Wno-stack-protector
  172. @@ -6570,7 +6586,7 @@
  173. second branch or a point immediately following it, depending on whether
  174. the condition is known to be true or false.
  175. -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
  176. +Enabled at levels @option{-O3}.
  177. @item -fsplit-wide-types
  178. @opindex fsplit-wide-types
  179. diff -Nur gcc-4.7.2.orig/gcc/java/jvspec.c gcc-4.7.2/gcc/java/jvspec.c
  180. --- gcc-4.7.2.orig/gcc/java/jvspec.c 2011-02-13 20:20:01.000000000 +0100
  181. +++ gcc-4.7.2/gcc/java/jvspec.c 2012-09-22 12:53:33.000000000 +0200
  182. @@ -627,6 +627,7 @@
  183. class name. Append dummy `.c' that can be stripped by set_input so %b
  184. is correct. */
  185. set_input (concat (main_class_name, "main.c", NULL));
  186. + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
  187. err = do_spec (jvgenmain_spec);
  188. if (err == 0)
  189. {
  190. diff -Nur gcc-4.7.2.orig/gcc/opts.c gcc-4.7.2/gcc/opts.c
  191. --- gcc-4.7.2.orig/gcc/opts.c 2012-01-10 17:27:55.000000000 +0100
  192. +++ gcc-4.7.2/gcc/opts.c 2012-09-22 12:53:33.000000000 +0200
  193. @@ -470,8 +470,6 @@
  194. { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 },
  195. #endif
  196. { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 },
  197. - { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 },
  198. - { OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 },
  199. { OPT_LEVELS_2_PLUS, OPT_freorder_blocks, NULL, 1 },
  200. { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 },
  201. { OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 },
  202. @@ -489,6 +487,8 @@
  203. { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_foptimize_strlen, NULL, 1 },
  204. /* -O3 optimizations. */
  205. + { OPT_LEVELS_3_PLUS, OPT_fstrict_aliasing, NULL, 1 },
  206. + { OPT_LEVELS_3_PLUS, OPT_fstrict_overflow, NULL, 1 },
  207. { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
  208. { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 },
  209. /* Inlining of functions reducing size is a good idea with -Os
  210. @@ -1432,6 +1432,17 @@
  211. opts, opts_set, loc, dc);
  212. break;
  213. + case OPT_Werror_maybe_reset:
  214. + {
  215. + char *ev = getenv ("GCC_NO_WERROR");
  216. + if ((ev != NULL) && (*ev != '0'))
  217. + warnings_are_errors = 0;
  218. + }
  219. + break;
  220. +
  221. + case OPT_fhonour_copts:
  222. + break;
  223. +
  224. case OPT_Wlarger_than_:
  225. opts->x_larger_than_size = value;
  226. opts->x_warn_larger_than = value != -1;