On Mon, May 30, 2011 at 5:53 PM, Pierre Vittet <pier...@pvittet.com> wrote:
> Hello,
>
> I try to use the plugin pragma-plugin.c which is given in the testsuite
> (gcc/testsuite/g++.dg/plugin/pragma_plugin.c), I have compiled it as a
> shared library.
>
> If I try it on a simple c file it works, however, if I use -flto it causes
> an error:
>
> gcc -fplugin=./pragma_plugin.so -flto test.c
>
> lto1: error: cannot load plugin ../pragma_plugin.so
> ../pragma_plugin.so: undefined symbol: c_register_pragma
> lto-wrapper: /usr/bin/gcc returned 1 exit status
> /usr/lib/gcc/i486-slackware-linux/4.7.0/../../../../i486-slackware-linux/bin/ld:
> lto-wrapper failed
> collect2: error: ld returned 1 exit status
>
> I don't know much about LTO but I guess it is important to be able to use
> langage specific function (such as c_register_pragma) in plugin even when
> using lto. I have this need in others plugins (I would like to have pragma
> support in MELT). Maybe a solution could be to define c_register_pragma and
> others related functions as weak references (however it mights not works for
> all plateform).
>
> What would be the better way to patch this?

You can't use language specific functions form a plugin that should be
usable at link time (from lto1) given that the sources can originate
from different frontends.

I suppose plugins could be tagged as to which language they are
tailored to and a more meaningful error could be emitted then.

Richard.

> Pierre Vittet
>

Reply via email to