This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [plugins] [patch] Initial implementation of GCC plugin support


Le-Chun Wu wrote:
Hi,

This patch for the plugins branch contains the initial implementation
of GCC plugin support based on the APIs described in the following
wiki page:

http://gcc.gnu.org/wiki/GCC_PluginAPI
        * plugin.c: New source file.

+static int
+init_one_plugin (void **slot, void * ARG_UNUSED (info))
+{
+ struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
+ void *dl_handle;
+ plugin_init_func plugin_init;
+ char *err;
+
+ dl_handle = dlopen (plugin->full_name, RTLD_LAZY);
+ if (!dl_handle)
+ {
+ error (G_("Cannot load plugin %s\n%s"), plugin->full_name, dlerror());
+ return 1;


I would suggest using RTLD_NOW instead of RTLD_LAZY when calling dlopen.
If the dynamic load is lazy, undefined references are caught later (and crash the compiler). This is really annoying for GCC plugins. We don't dlopen often (only at start up time), and we would prefer a strict load (even if it is a bit slower) which catch more errors.


One could also imagine that GCC plugins could define a
const char gcc_version_expected_by_plugin[]="4.4.0";
and some additional code just after the dlopen to warn against plugin incompatibility. This could be implemented later (but I definitely believe it is very useful).


Also, one could imagine that there would be some standard plugin directory in which we seek the plugins *.so files. This could be implemented later.

In gcc/tree-pass.h
+extern void register_one_dump_file (struct opt_pass *);
I would suggest adding a small comment before.

A big thanks to Le-Chun for his efforts.

Regards.

--
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]