lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

910-mbsd_multi.patch (7285B)


      1 
      2 	This patch brings over a few features from MirBSD:
      3 	* -fhonour-copts
      4 	  If this option is not given, it's warned (depending
      5 	  on environment variables). This is to catch errors
      6 	  of misbuilt packages which override CFLAGS themselves.
      7 	* -Werror-maybe-reset
      8 	  Has the effect of -Wno-error if GCC_NO_WERROR is
      9 	  set and not '0', a no-operation otherwise. This is
     10 	  to be able to use -Werror in "make" but prevent
     11 	  GNU autoconf generated configure scripts from
     12 	  freaking out.
     13 
     14 	This patch was authored by Thorsten Glaser <tg at mirbsd.de>
     15 	with copyright assignment to the FSF in effect.
     16 
     17 --- a/gcc/c-family/c-opts.c
     18 +++ b/gcc/c-family/c-opts.c
     19 @@ -122,6 +122,9 @@ static int class_dump_flags;
     20  /* Whether any standard preincluded header has been preincluded.  */
     21  static bool done_preinclude;
     22  
     23 +/* Check if a port honours COPTS.  */
     24 +static int honour_copts = 0;
     25 +
     26  static void handle_OPT_d (const char *);
     27  static void set_std_cxx98 (int);
     28  static void set_std_cxx11 (int);
     29 @@ -449,6 +452,12 @@ c_common_handle_option (size_t scode, co
     30        flag_no_builtin = !value;
     31        break;
     32  
     33 +    case OPT_fhonour_copts:
     34 +      if (c_language == clk_c) {
     35 +        honour_copts++;
     36 +      }
     37 +      break;
     38 +
     39      case OPT_fconstant_string_class_:
     40        constant_string_class_name = arg;
     41        break;
     42 @@ -1034,6 +1043,47 @@ c_common_init (void)
     43        return false;
     44      }
     45  
     46 +  if (c_language == clk_c) {
     47 +    char *ev = getenv ("GCC_HONOUR_COPTS");
     48 +    int evv;
     49 +    if (ev == NULL)
     50 +      evv = -1;
     51 +    else if ((*ev == '0') || (*ev == '\0'))
     52 +      evv = 0;
     53 +    else if (*ev == '1')
     54 +      evv = 1;
     55 +    else if (*ev == '2')
     56 +      evv = 2;
     57 +    else if (*ev == 's')
     58 +      evv = -1;
     59 +    else {
     60 +      warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
     61 +      evv = 1; /* maybe depend this on something like MIRBSD_NATIVE?  */
     62 +    }
     63 +    if (evv == 1) {
     64 +      if (honour_copts == 0) {
     65 +        error ("someone does not honour COPTS at all in lenient mode");
     66 +        return false;
     67 +      } else if (honour_copts != 1) {
     68 +        warning (0, "someone does not honour COPTS correctly, passed %d times",
     69 +         honour_copts);
     70 +      }
     71 +    } else if (evv == 2) {
     72 +      if (honour_copts == 0) {
     73 +        error ("someone does not honour COPTS at all in strict mode");
     74 +        return false;
     75 +      } else if (honour_copts != 1) {
     76 +        error ("someone does not honour COPTS correctly, passed %d times",
     77 +         honour_copts);
     78 +        return false;
     79 +      }
     80 +    } else if (evv == 0) {
     81 +      if (honour_copts != 1)
     82 +        inform (0, "someone does not honour COPTS correctly, passed %d times",
     83 +         honour_copts);
     84 +    }
     85 +  }
     86 +
     87    return true;
     88  }
     89  
     90 --- a/gcc/c-family/c.opt
     91 +++ b/gcc/c-family/c.opt
     92 @@ -431,6 +431,10 @@ Wfloat-conversion
     93  C ObjC C++ ObjC++ Var(warn_float_conversion) LangEnabledBy(C ObjC C++ ObjC++,Wconversion)
     94  Warn for implicit type conversions that cause loss of floating point precision
     95  
     96 +Werror-maybe-reset
     97 +C ObjC C++ ObjC++
     98 +; Documented in common.opt
     99 +
    100  Wfloat-equal
    101  C ObjC C++ ObjC++ Var(warn_float_equal) Warning
    102  Warn if testing floating point numbers for equality
    103 @@ -1161,6 +1165,9 @@ C++ ObjC++ Optimization Alias(fexception
    104  fhonor-std
    105  C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
    106  
    107 +fhonour-copts
    108 +C ObjC C++ ObjC++ RejectNegative
    109 +
    110  fhosted
    111  C ObjC
    112  Assume normal C execution environment
    113 --- a/gcc/common.opt
    114 +++ b/gcc/common.opt
    115 @@ -561,6 +561,10 @@ Werror=
    116  Common Joined
    117  Treat specified warning as error
    118  
    119 +Werror-maybe-reset
    120 +Common
    121 +If environment variable GCC_NO_WERROR is set, act as -Wno-error
    122 +
    123  Wextra
    124  Common Var(extra_warnings) Warning
    125  Print extra (possibly unwanted) warnings
    126 @@ -1360,6 +1364,9 @@ fguess-branch-probability
    127  Common Report Var(flag_guess_branch_prob) Optimization
    128  Enable guessing of branch probabilities
    129  
    130 +fhonour-copts
    131 +Common RejectNegative
    132 +
    133  ; Nonzero means ignore `#ident' directives.  0 means handle them.
    134  ; Generate position-independent code for executables if possible
    135  ; On SVR4 targets, it also controls whether or not to emit a
    136 --- a/gcc/opts.c
    137 +++ b/gcc/opts.c
    138 @@ -1699,6 +1699,17 @@ common_handle_option (struct gcc_options
    139  			       opts, opts_set, loc, dc);
    140        break;
    141  
    142 +    case OPT_Werror_maybe_reset:
    143 +      {
    144 +        char *ev = getenv ("GCC_NO_WERROR");
    145 +        if ((ev != NULL) && (*ev != '0'))
    146 +          warnings_are_errors = 0;
    147 +      }
    148 +      break;
    149 +
    150 +    case OPT_fhonour_copts:
    151 +      break;
    152 +
    153      case OPT_Wlarger_than_:
    154        opts->x_larger_than_size = value;
    155        opts->x_warn_larger_than = value != -1;
    156 --- a/gcc/doc/cppopts.texi
    157 +++ b/gcc/doc/cppopts.texi
    158 @@ -163,6 +163,11 @@ in older programs.  This warning is on b
    159  Make all warnings into hard errors.  Source code which triggers warnings
    160  will be rejected.
    161  
    162 + at item -Werror-maybe-reset
    163 + at opindex Werror-maybe-reset
    164 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
    165 +variable is set to anything other than 0 or empty.
    166 +
    167  @item -Wsystem-headers
    168  @opindex Wsystem-headers
    169  Issue warnings for code in system headers.  These are normally unhelpful
    170 --- a/gcc/doc/invoke.texi
    171 +++ b/gcc/doc/invoke.texi
    172 @@ -251,7 +251,7 @@ Objective-C and Objective-C++ Dialects}.
    173  -Wdisabled-optimization @gol
    174  -Wno-discarded-qualifiers -Wno-discarded-array-qualifiers @gol
    175  -Wno-div-by-zero -Wdouble-promotion -Wempty-body  -Wenum-compare @gol
    176 --Wno-endif-labels -Werror  -Werror=* @gol
    177 +-Wno-endif-labels -Werror  -Werror=* -Werror-maybe-reset @gol
    178  -Wfatal-errors  -Wfloat-equal  -Wformat  -Wformat=2 @gol
    179  -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
    180  -Wformat-security  -Wformat-signedness  -Wformat-y2k @gol
    181 @@ -5382,6 +5382,22 @@ This option is only supported for C and
    182  @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
    183  @option{-Wno-pointer-sign}.
    184  
    185 + at item -Werror-maybe-reset
    186 + at opindex Werror-maybe-reset
    187 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
    188 +variable is set to anything other than 0 or empty.
    189 +
    190 + at item -fhonour-copts
    191 + at opindex fhonour-copts
    192 +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
    193 +given at least once, and warn if it is given more than once.
    194 +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
    195 +given exactly once.
    196 +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
    197 +is not given exactly once.
    198 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
    199 +This flag and environment variable only affect the C language.
    200 +
    201  @item -Wstack-protector
    202  @opindex Wstack-protector
    203  @opindex Wno-stack-protector
    204 @@ -7860,7 +7876,7 @@ so, the first branch is redirected to ei
    205  second branch or a point immediately following it, depending on whether
    206  the condition is known to be true or false.
    207  
    208 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
    209 +Enabled at levels @option{-O3}.
    210  
    211  @item -fsplit-wide-types
    212  @opindex fsplit-wide-types
    213 --- a/gcc/java/jvspec.c
    214 +++ b/gcc/java/jvspec.c
    215 @@ -629,6 +629,7 @@ lang_specific_pre_link (void)
    216       class name.  Append dummy `.c' that can be stripped by set_input so %b
    217       is correct.  */ 
    218    set_input (concat (main_class_name, "main.c", NULL));
    219 +  putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack!  */
    220    err = do_spec (jvgenmain_spec);
    221    if (err == 0)
    222      {