On Tue, 2020-05-12 at 11:12 +0200, Sebastian Kürten wrote: > Hi everybody, > > I'm trying to adapt an existing, open source GCC plugin so that it > will > work with more recent versions of GCC (it is currently working with > 4.7 > only). During my research I came across your suggestion on the > Wiki[1] > to get in touch if one has any questions concerning developing > plugins, > so I'll try this and see if anybody would be so kind to give me a > little > guidance! > > The plugin is GCC-Bridge of the Renjin project which has been > discussed > on this mailing list before[2]. It is part of an effort to create a > JVM > runtime for the R language. The GCC-Brigde plugin compiles Gimple to > JVM > bytecode to make that runtime possible. The original project lives > here[3], however, I have created a fork[4] that concentrates on just > the part that compiles C code to JVM bytecode. The plugin is > currently > written using the plugin API of GCC 4.7. Since 4.7 is not available > on > my current Ubuntu-based system any longer, I would like to migrate to > a > newer version. 4.8 is available on my system, so migrating to that > version would suffice as a first step. I tried that, however > compilation fails using gcc-4.8 and after some reading the docs and > going through the GCC source code history it seems that 4.7 to 4.8 > was > a rather big evolution. > > If anyone wants to take a look at the error messages, I created a > branch[5] that has everything set up so that you can just run the > compiler and see what happens; the README[6] file contains the > necessary compilation instructions. It also shows the current output > of > gcc-4.8 and the error messages it produces. The plugin consists of a > single file[7]. It seems that a global variable called > "varpool_nodes" > is not available anymore and also the members of the struct > varpool_node changed.
4.8 is rather ancient at this point. Looking at gcc/ChangeLog-2012 I see a change 2012-04-16 Jan Hubicka <j...@suse.cz> in which, if I'm reading it right, varpool_nodes was removed in favor of a symtab_nodes function (combining both variables and callgraph nodes). In later releases (I think) they got encapsulated into a symbtab class. There's also a FOR_EACH_VARIABLE macro that might give you what you need. > I haven't been able to figure out a way to > traverse the Gimple tree and data structures the way the plugin did > with the older API. If anyone here is familiar with the changes to > the > plugin API from 4.7 to 4.8, maybe you have a few hints for me? > Pointers > to a different plugin that went through a migration from 4.7 to a > newer > version could also be very very helpful. Any ideas? My gcc-python-plugin attempts to support gcc 4.6 onwards from one source tree, so has a lot of nasty compatibility cruft: https://github.com/davidmalcolm/gcc-python-plugin which might be helpful (or might not). Hope this is constructive Dave > > Thank you! > Sebastian > > [1] https://gcc.gnu.org/wiki/plugins > [2] https://gcc.gnu.org/legacy-ml/gcc/2016-02/msg00004.html > [3] https://github.com/bedatadriven/renjin/ > [4] https://github.com/mobanisto/gcc-bridge > [5] https://github.com/mobanisto/gcc-bridge/tree/gcc-4.8 > [6] https://github.com/mobanisto/gcc-bridge/blob/gcc-4.8/README.md > [7] > https://github.com/mobanisto/gcc-bridge/blob/gcc-4.8/compiler/src/main/resources/org/renjin/gcc/plugin.c >