On Wed, Nov 18, 2020 at 10:39:46AM +0100, Richard Biener wrote: > We already have --{enable,disable}-plugin, so could remove it when > those are not enabled.
Here is a variant that does that: 2020-11-18 Jakub Jelinek <ja...@redhat.com> * opts.h (struct cl_var): New type. (cl_vars): Declare. * optc-gen.awk: Generate cl_vars array. --- gcc/opts.h.jj 2020-04-30 11:49:28.462900760 +0200 +++ gcc/opts.h 2020-08-24 10:21:08.563288412 +0200 @@ -124,6 +124,14 @@ struct cl_option int range_max; }; +struct cl_var +{ + /* Name of the variable. */ + const char *var_name; + /* Offset of field for this var in struct gcc_options. */ + unsigned short var_offset; +}; + /* Records that the state of an option consists of SIZE bytes starting at DATA. DATA might point to CH in some cases. */ struct cl_option_state { @@ -134,6 +142,9 @@ struct cl_option_state { extern const struct cl_option cl_options[]; extern const unsigned int cl_options_count; +#ifdef ENABLE_PLUGIN +extern const struct cl_var cl_vars[]; +#endif extern const char *const lang_names[]; extern const unsigned int cl_lang_count; --- gcc/optc-gen.awk.jj 2020-01-12 11:54:36.691409214 +0100 +++ gcc/optc-gen.awk 2020-08-24 10:19:49.410410288 +0200 @@ -592,5 +592,29 @@ for (i = 0; i < n_opts; i++) { } print "} " +split("", var_seen, ":") +print "\n#if !defined(GENERATOR_FILE) && defined(ENABLE_PLUGIN)" +print "DEBUG_VARIABLE const struct cl_var cl_vars[] =\n{" + +for (i = 0; i < n_opts; i++) { + name = var_name(flags[i]); + if (name == "") + continue; + var_seen[name] = 1; +} + +for (i = 0; i < n_extra_vars; i++) { + var = extra_vars[i] + sub(" *=.*", "", var) + name = var + sub("^.*[ *]", "", name) + sub("\\[.*\\]$", "", name) + if (name in var_seen) + continue; + print " { " quote name quote ", offsetof (struct gcc_options, x_" name ") }," + var_seen[name] = 1 } +print " { NULL, (unsigned short) -1 }\n};\n#endif" + +} Jakub