I'm trying to register a pass in my gcc plugin code. To do so, I first declare the my_first_pass class which derives from gimple_opt_pass and, in turn, this class derives from opt_pass and so on...
class my_first_pass : public gimple_opt_pass
{
public:
my_first_pass(gcc::context * ctx) :
gimple_opt_pass(my_first_pass_data, ctx)
{}
};
Then, I try to instantiate a my_first_pass object like in the code below, while configuring the remaining fields of the register_pass_info structure.
struct register_pass_info pass_info;
pass_info.pass = new my_first_pass(g/*gcc related global variable*/);
...
To compile the above code, I generate a shared library which is then loaded by gcc. Whenever I run gcc I get the following error, which I know is caused by the creation of the my_first_pass object in the above code:
cc1plus: error: cannot load plugin ./plugin.so
./structsizes.so: undefined symbol: _ZTI8opt_pass
I'm following an online example, but if I run the $(GCC_SRC)/gcc/testsuite/gcc.dg/plugin/one_time_plugin.c I get the exact same problem.
(Using GCC 4.9.2 compiled from source)
Thanks in advance, Cheers.
Edit: Tried on GCC 6.3.0 and I have the same problem.
I found out what the problem was here.
I just need to add the following option when compiling the plugin: -fno-rtti