910-mbsd_multi.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. This patch brings over a feature 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. This patch was authored by Thorsten Glaser <tg at mirbsd.de>
  7. with copyright assignment to the FSF in effect.
  8. --- a/gcc/c-family/c-opts.c
  9. +++ b/gcc/c-family/c-opts.c
  10. @@ -108,6 +108,9 @@ static int class_dump_flags;
  11. /* Whether any standard preincluded header has been preincluded. */
  12. static bool done_preinclude;
  13. +/* Check if a port honours COPTS. */
  14. +static int honour_copts = 0;
  15. +
  16. static void handle_OPT_d (const char *);
  17. static void set_std_cxx98 (int);
  18. static void set_std_cxx11 (int);
  19. @@ -456,6 +459,12 @@ c_common_handle_option (size_t scode, co
  20. flag_no_builtin = !value;
  21. break;
  22. + case OPT_fhonour_copts:
  23. + if (c_language == clk_c) {
  24. + honour_copts++;
  25. + }
  26. + break;
  27. +
  28. case OPT_fconstant_string_class_:
  29. constant_string_class_name = arg;
  30. break;
  31. @@ -1084,6 +1093,47 @@ c_common_init (void)
  32. return false;
  33. }
  34. + if (c_language == clk_c) {
  35. + char *ev = getenv ("GCC_HONOUR_COPTS");
  36. + int evv;
  37. + if (ev == NULL)
  38. + evv = -1;
  39. + else if ((*ev == '0') || (*ev == '\0'))
  40. + evv = 0;
  41. + else if (*ev == '1')
  42. + evv = 1;
  43. + else if (*ev == '2')
  44. + evv = 2;
  45. + else if (*ev == 's')
  46. + evv = -1;
  47. + else {
  48. + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
  49. + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
  50. + }
  51. + if (evv == 1) {
  52. + if (honour_copts == 0) {
  53. + error ("someone does not honour COPTS at all in lenient mode");
  54. + return false;
  55. + } else if (honour_copts != 1) {
  56. + warning (0, "someone does not honour COPTS correctly, passed %d times",
  57. + honour_copts);
  58. + }
  59. + } else if (evv == 2) {
  60. + if (honour_copts == 0) {
  61. + error ("someone does not honour COPTS at all in strict mode");
  62. + return false;
  63. + } else if (honour_copts != 1) {
  64. + error ("someone does not honour COPTS correctly, passed %d times",
  65. + honour_copts);
  66. + return false;
  67. + }
  68. + } else if (evv == 0) {
  69. + if (honour_copts != 1)
  70. + inform (0, "someone does not honour COPTS correctly, passed %d times",
  71. + honour_copts);
  72. + }
  73. + }
  74. +
  75. return true;
  76. }
  77. --- a/gcc/c-family/c.opt
  78. +++ b/gcc/c-family/c.opt
  79. @@ -1412,6 +1412,9 @@ C++ ObjC++ Optimization Alias(fexception
  80. fhonor-std
  81. C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
  82. +fhonour-copts
  83. +C ObjC C++ ObjC++ RejectNegative
  84. +
  85. fhosted
  86. C ObjC
  87. Assume normal C execution environment.
  88. --- a/gcc/common.opt
  89. +++ b/gcc/common.opt
  90. @@ -1510,6 +1510,9 @@ fguess-branch-probability
  91. Common Report Var(flag_guess_branch_prob) Optimization
  92. Enable guessing of branch probabilities.
  93. +fhonour-copts
  94. +Common RejectNegative
  95. +
  96. ; Nonzero means ignore `#ident' directives. 0 means handle them.
  97. ; Generate position-independent code for executables if possible
  98. ; On SVR4 targets, it also controls whether or not to emit a
  99. --- a/gcc/opts.c
  100. +++ b/gcc/opts.c
  101. @@ -1921,6 +1921,9 @@ common_handle_option (struct gcc_options
  102. opts, opts_set, loc, dc);
  103. break;
  104. + case OPT_fhonour_copts:
  105. + break;
  106. +
  107. case OPT_Wlarger_than_:
  108. opts->x_larger_than_size = value;
  109. opts->x_warn_larger_than = value != -1;
  110. --- a/gcc/doc/invoke.texi
  111. +++ b/gcc/doc/invoke.texi
  112. @@ -6565,6 +6565,17 @@ This option is only supported for C and
  113. @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
  114. @option{-Wno-pointer-sign}.
  115. +@item -fhonour-copts
  116. +@opindex fhonour-copts
  117. +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
  118. +given at least once, and warn if it is given more than once.
  119. +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
  120. +given exactly once.
  121. +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
  122. +is not given exactly once.
  123. +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
  124. +This flag and environment variable only affect the C language.
  125. +
  126. @item -Wstack-protector
  127. @opindex Wstack-protector
  128. @opindex Wno-stack-protector