GCC pass registration - opt_pass undefined symbol
Pedro Lopes
pedro.fraiao@gmail.com
Fri Mar 10 15:39:00 GMT 2017
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.
Tried with GCC 4.9.2 and 6.3.0 compiled from source. In both versions,
I tried the testsuite code which register a pass, obtaining the same
error.
Thanks in advance, Cheers.
More information about the Gcc-help
mailing list