aboutsummaryrefslogtreecommitdiff
path: root/gcc/optc-gen.awk
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-11-18 22:10:26 +0100
committerJakub Jelinek <jakub@redhat.com>2020-11-18 22:10:26 +0100
commit84e0549ce206357dcd384cf8db14322c686d1eb2 (patch)
treeeafad226fade8d6adbd68099e80babaafb5be896 /gcc/optc-gen.awk
parentf3f312b535f57b5773953746f6ad0d890ce09b88 (diff)
downloadgcc-84e0549ce206357dcd384cf8db14322c686d1eb2.zip
gcc-84e0549ce206357dcd384cf8db14322c686d1eb2.tar.gz
gcc-84e0549ce206357dcd384cf8db14322c686d1eb2.tar.bz2
plugins: Allow plugins to handle global_options changes
Any time somebody adds or removes an option in some *.opt file (which e.g. on the 10 branch after branching off 11 happened 7 times already), many offsets in global_options variable change and so plugins that ever access GCC options or other global_options values are ABI dependent on it. It is true we don't guarantee ABI stability for plugins, but we change the most often used data structures on the release branches only very rarely and so the options changes are the most problematic for ABI stability of plugins. Annobin uses a way to remap accesses to some of the global_options.x_* by looking them up in the cl_options array where we have offsetof (struct gcc_options, x_flag_lto) etc. remembered, but sadly doesn't do it for all options (e.g. some flag_* etc. option accesses may be hidden in various macros like POINTER_SIZE), and more importantly some struct gcc_options offsets are not covered at all. E.g. there is no offsetof (struct gcc_options, x_optimize), offsetof (struct gcc_options, x_flag_sanitize) etc. Those are usually: Variable int optimize in the *.opt files. The following patch allows the plugins to deal with reshuffling of even the global_options fields that aren't tracked in cl_options by adding another array that describes those, which adds an 816 bytes long array and 1039 bytes in string literals, so 1855 .rodata bytes in total ATM. And adds it only if --enable-plugin (the default), with --disable-plugin it will not be compiled in. 2020-11-18 Jakub Jelinek <jakub@redhat.com> * opts.h (struct cl_var): New type. (cl_vars): Declare. * optc-gen.awk: Generate cl_vars array.
Diffstat (limited to 'gcc/optc-gen.awk')
-rw-r--r--gcc/optc-gen.awk24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index 9e7e997..be5566b 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -595,5 +595,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"
+
+}