Index: gcc/doc/options.texi =================================================================== --- gcc/doc/options.texi (revision 119231) +++ gcc/doc/options.texi (working copy) @@ -221,4 +221,21 @@ The option should only be accepted if pr option will be present even if @var{cond} is false; @var{cond} simply controls whether the option is accepted and whether it is printed in the @option{--help} output. + +@strong{Warning:} @emph{this option @samp{Condition} is rarely used and +may become obsolete.} + +@item CppCondition(@var{cond}) +The option should only be accepted if preprocessor condition +@var{cond} -which should be an identifier optionally defined at +configuration time- is defined and true. In contrast to the obsolete +@samp{Condition} option, any C declarations associated with this +option @samp{CppCondition} will be skipped by preprocessing when the +preprocessor condition @var{cond} is false or missing, and more +generally no GCC runtime flag and no (generated in GCC) code are +available (not even help messages) when this preprocessor @var{cond} +is false or missing. With this @samp{CppCondition}, some compilation +features can be entirely disabled (and won't even be recognized) at +configuration time. + @end table Index: gcc/optc-gen.awk =================================================================== --- gcc/optc-gen.awk (revision 119231) +++ gcc/optc-gen.awk (working copy) @@ -54,7 +54,7 @@ BEGIN { # Dump that array of options into a C file. END { -print "/* This file is auto-generated by opts.sh. */" +print "/* This file is auto-generated by awk with optc-gen.awk. */" print "" n_headers = split(header_name, headers, " ") for (i = 1; i <= n_headers; i++) @@ -87,6 +87,11 @@ for (i = 0; i < n_opts; i++) { continue; gcc_driver = 0 } + + # add handling of CppCondition option + cppcond = opt_args("CppCondition", flags[i]) + if (cppcond != "") + print "\n#if defined(" cppcond ") && " cppcond " != 0 /*cppcond*/"; if (gcc_driver == 1) print "#ifdef GCC_DRIVER" @@ -95,6 +100,10 @@ for (i = 0; i < n_opts; i++) { print var_type(flags[i]) name init ";" if (gcc_driver == 1) print "#endif /* GCC_DRIVER */" + + if (cppcond != "") + print "#endif /*cppcond: " cppcond " */\n" + print "" var_seen[name] = 1; @@ -188,6 +197,11 @@ for (i = 0; i < n_opts; i++) { idx = -1; } } + # add handling of CppCondition option + cppcond = opt_args("CppCondition", flags[i]) + if (cppcond != "") + print "\n#if defined(" cppcond ") && " cppcond " != 0 /*cppcond*/"; + printf(" { %c-%s%c,\n %s,\n %s, %u, %d,\n", quote, opts[i], quote, hlp, back_chain[i], len, idx) condition = opt_args("Condition", flags[i]) @@ -203,6 +217,8 @@ for (i = 0; i < n_opts; i++) { printf(" %s,\n", cl_flags) printf(" %s, %s }%s\n", var_ref(opts[i], flags[i]), var_set(flags[i]), comma) + if (cppcond != "") + print "#endif /*cppcond: " cppcond " */\n" } print "};" Index: gcc/opth-gen.awk =================================================================== --- gcc/opth-gen.awk (revision 119231) +++ gcc/opth-gen.awk (working copy) @@ -55,7 +55,7 @@ BEGIN { # Dump out an enumeration into a .h file. # Combine the flags of duplicate options. END { -print "/* This file is auto-generated by opts.sh. */" +print "/* This file is auto-generated by awk with opth-gen.awk */" print "" print "#ifndef OPTIONS_H" print "#define OPTIONS_H" @@ -67,8 +67,15 @@ for (i = 0; i < n_opts; i++) { name = var_name(flags[i]); if (name == "") continue; + # add handling of CppCondition option + cppcond = opt_args("CppCondition", flags[i]) + if (cppcond != "") + print "\n#if defined(" cppcond ") && " cppcond " != 0 /*cppcond*/"; print "extern " var_type(flags[i]) name ";" + + if (cppcond != "") + print "#endif /*cppcond: " cppcond " */\n" } print "" @@ -76,11 +83,17 @@ for (i = 0; i < n_opts; i++) { name = opt_args("Mask", flags[i]) vname = var_name(flags[i]) mask = "MASK_" + cppcond = opt_args("CppCondition", flags[i]) if (vname != "") { mask = "OPTION_MASK_" } - if (name != "" && !flag_set_p("MaskExists", flags[i])) - print "#define " mask name " (1 << " masknum[vname]++ ")" + if (name != "" && !flag_set_p("MaskExists", flags[i])) { + if (cppcond != "") + print "\n#if defined(" cppcond ") && " cppcond " != 0 /*cppcond*/"; + print "#define " mask name " (1 << " masknum[vname]++ ")"; + if (cppcond != "") + print "#endif /*cppcond: " cppcond " */\n" + } } for (i = 0; i < n_extra_masks; i++) { print "#define MASK_" extra_masks[i] " (1 << " masknum[""]++ ")" @@ -99,6 +112,8 @@ print "" for (i = 0; i < n_opts; i++) { name = opt_args("Mask", flags[i]) vname = var_name(flags[i]) + # add handling of CppCondition option + cppcond = opt_args("CppCondition", flags[i]) macro = "OPTION_" mask = "OPTION_MASK_" if (vname == "") { @@ -106,9 +121,14 @@ for (i = 0; i < n_opts; i++) { macro = "TARGET_" mask = "MASK_" } - if (name != "" && !flag_set_p("MaskExists", flags[i])) - print "#define " macro name \ - " ((" vname " & " mask name ") != 0)" + if (name != "" && !flag_set_p("MaskExists", flags[i])) { + if (cppcond != "") + print "\n#if defined(" cppcond ") && " cppcond " != 0 /*cppcond*/"; + print "#define " macro name \ + " ((" vname " & " mask name ") != 0)"; + if (cppcond != "") + print "#endif /*cppcond: " cppcond " */\n" + } } for (i = 0; i < n_extra_masks; i++) { print "#define TARGET_" extra_masks[i] \ @@ -183,8 +203,14 @@ for (i = 0; i < n_opts; i++) { hlp = "0" else hlp = "N_(\"" help[i] "\")"; + # add handling of CppCondition option + cppcond = opt_args("CppCondition", flags[i]) + if (cppcond != "") + print "\n#if defined(" cppcond ") && " cppcond " != 0 /*cppcond*/"; - print " " enum "," s "/* -" opts[i] " */" + print " " enum "," s "/* -" opts[i] " */"; + if (cppcond != "") + print "#endif /*cppcond: " cppcond " */\n" } print " N_OPTS"