We just have to add some small code [2] into the ggc_mark_roots routine of
gcc/ggc-common.c to add the scanning using this gt_ggc_r_gt_FOO_h. This is
not a big deal. We should simply add a routine
ggc_register_plugin_root_tab(const struct ggc_root_tab*) that adds its
argument to some (static variable in gcc/ggc-common.c which is a) linked
list or vector, and have ggc_mark_root scan that list or vector by adding a
few lines there. We require plugin initializers to call
ggc_register_plugin_root_tab appropriatly, exactly like they do already call
register_callback etc...
This is in fact exactly the solution I was using in the old plugin
branch (though I never submitted the code once it became clear that
the newer plug-in system was going to take over). I can send out the
patch if anyone is interested; it's as simple as it sounds.
With that extra bit of garbage collector support in place, I hacked up
a simple header file that provides macros to manually generate
ggc_add_plugin_root struct entries just like the ones gengtype would
generate (for a small set of types). So a plug-in author can declare
a vector of tree nodes like so:
static GC_ROOT_TREE_VEC (my_tree_vector);
Another macro (to be called from plugin_init()) lets the author
register that root with the garbage collector.
register_root (my_tree_vector);
This isn't an end-all solution, but it actually provides all the
support that I need for my plug-ins, and it is perhaps a useful
stepping stone.
The main reason I'm bringing this up is because I've got a handful of
plug-ins I'd like to make public. Without any support from the
garbage collector, I'll have to do some rewriting to get around the
issue. If other plug-in authors thinks this is a useful idea (would
it be sufficient to port MELT, for instance?), I'd be willing to
prepare some patches to add it in.