cflags.patch 7.7 KB

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