source: trunk/toolchain/gcc/patches/4.4.1+cs/910-mbsd_multi.patch @ 22474

Last change on this file since 22474 was 22474, checked in by lars, 6 years ago

[toolchain] Add lost handling of -fhonour-copts to 4.4.x+cs/910-mbsd_multi.patch

File size: 4.7 KB
  • gcc/c-opts.c

    	This patch brings over a few features from MirBSD:
    	* -fhonour-copts
    	  If this option is not given, it's warned (depending
    	  on environment variables). This is to catch errors
    	  of misbuilt packages which override CFLAGS themselves.
    	* Make -fno-strict-aliasing and -fno-delete-null-pointer-checks
    	  the default for -O2/-Os, because they trigger gcc bugs
    	  and can delete code with security implications.
    
    	This patch was authored by Thorsten Glaser <tg at mirbsd.de>
    	with copyright assignment to the FSF in effect.
    
    a b  
    105105/* Number of deferred options scanned for -include.  */ 
    106106static size_t include_cursor; 
    107107 
     108/* Check if a port honours COPTS.  */ 
     109static int honour_copts = 0; 
     110 
    108111static void set_Wimplicit (int); 
    109112static void handle_OPT_d (const char *); 
    110113static void set_std_cxx98 (int); 
     
    690701      flag_exceptions = value; 
    691702      break; 
    692703 
     704    case OPT_fhonour_copts: 
     705      if (c_language == clk_c) { 
     706        honour_copts++; 
     707      } 
     708      break; 
     709 
    693710    case OPT_fimplement_inlines: 
    694711      flag_implement_inlines = value; 
    695712      break; 
     
    12091226      return false; 
    12101227    } 
    12111228 
     1229  if (c_language == clk_c) { 
     1230    char *ev = getenv ("GCC_HONOUR_COPTS"); 
     1231    int evv; 
     1232    if (ev == NULL) 
     1233      evv = -1; 
     1234    else if ((*ev == '0') || (*ev == '\0')) 
     1235      evv = 0; 
     1236    else if (*ev == '1') 
     1237      evv = 1; 
     1238    else if (*ev == '2') 
     1239      evv = 2; 
     1240    else if (*ev == 's') 
     1241      evv = -1; 
     1242    else { 
     1243      warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1"); 
     1244      evv = 1; /* maybe depend this on something like MIRBSD_NATIVE?  */ 
     1245    } 
     1246    if (evv == 1) { 
     1247      if (honour_copts == 0) { 
     1248        error ("someone does not honour COPTS at all in lenient mode"); 
     1249        return false; 
     1250      } else if (honour_copts != 1) { 
     1251        warning (0, "someone does not honour COPTS correctly, passed %d times", 
     1252         honour_copts); 
     1253      } 
     1254    } else if (evv == 2) { 
     1255      if (honour_copts == 0) { 
     1256        error ("someone does not honour COPTS at all in strict mode"); 
     1257        return false; 
     1258      } else if (honour_copts != 1) { 
     1259        error ("someone does not honour COPTS correctly, passed %d times", 
     1260         honour_copts); 
     1261        return false; 
     1262      } 
     1263    } else if (evv == 0) { 
     1264      if (honour_copts != 1) 
     1265        inform (0, "someone does not honour COPTS correctly, passed %d times", 
     1266         honour_copts); 
     1267    } 
     1268  } 
     1269 
    12121270  return true; 
    12131271} 
    12141272 
  • gcc/c.opt

    a b  
    609613fhonor-std 
    610614C++ ObjC++ 
    611615 
     616fhonour-copts 
     617C ObjC C++ ObjC++ RejectNegative 
     618 
    612619fhosted 
    613620C ObjC 
    614621Assume normal C execution environment 
  • gcc/common.opt

    a b  
    573577Common Report Var(flag_guess_branch_prob) Optimization 
    574578Enable guessing of branch probabilities 
    575579 
     580fhonour-copts 
     581Common RejectNegative 
     582 
    576583; Nonzero means ignore `#ident' directives.  0 means handle them. 
    577584; Generate position-independent code for executables if possible 
    578585; On SVR4 targets, it also controls whether or not to emit a 
  • gcc/opts.c

    a b  
    896896  flag_schedule_insns_after_reload = opt2; 
    897897#endif 
    898898  flag_regmove = opt2; 
    899   flag_strict_aliasing = opt2; 
    900   flag_strict_overflow = opt2; 
    901   flag_delete_null_pointer_checks = opt2; 
    902899  flag_reorder_blocks = opt2; 
    903900  flag_reorder_functions = opt2; 
    904901  flag_tree_vrp = opt2; 
     
    922919 
    923920  /* -O3 optimizations.  */ 
    924921  opt3 = (optimize >= 3); 
     922  flag_strict_aliasing = opt3; 
     923  flag_strict_overflow = opt3; 
     924  flag_delete_null_pointer_checks = opt3; 
    925925  flag_predictive_commoning = opt3; 
    926926  flag_inline_functions = opt3; 
    927927  flag_unswitch_loops = opt3; 
     
    16051605      enable_warning_as_error (arg, value, lang_mask); 
    16061606      break; 
    16071607 
     1608    case OPT_fhonour_copts: 
     1609      break; 
     1610 
    16081611    case OPT_Wextra: 
    16091612      set_Wextra (value); 
    16101613      break; 
  • gcc/doc/invoke.texi

    a b  
    56995715second branch or a point immediately following it, depending on whether 
    57005716the condition is known to be true or false. 
    57015717 
    5702 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. 
     5718Enabled at levels @option{-O3}. 
    57035719 
    57045720@item -fsplit-wide-types 
    57055721@opindex fsplit-wide-types 
     
    58445860@option{-fno-delete-null-pointer-checks} to disable this optimization 
    58455861for programs which depend on that behavior. 
    58465862 
    5847 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. 
     5863Enabled at levels @option{-O3}. 
    58485864 
    58495865@item -fexpensive-optimizations 
    58505866@opindex fexpensive-optimizations 
  • gcc/java/jvspec.c

    a b  
    670670     class name.  Append dummy `.c' that can be stripped by set_input so %b 
    671671     is correct.  */  
    672672  set_input (concat (main_class_name, "main.c", NULL)); 
     673  putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack!  */ 
    673674  err = do_spec (jvgenmain_spec); 
    674675  if (err == 0) 
    675676    { 
Note: See TracBrowser for help on using the repository browser.