This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [plugins] [patch] Initial implementation of GCC plugin support
- From: Basile STARYNKEVITCH <basile at starynkevitch dot net>
- To: Le-Chun Wu <lcwu at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Diego Novillo <dnovillo at google dot com>, Taras Glek <tglek at mozilla dot com>, Grigori Fursin <grigori dot fursin at inria dot fr>, Zbigniew Chamski <zbigniew dot chamski at gmail dot com>, Sean Callanan <spyffe at cs dot sunysb dot edu>, Cupertino Miranda <cupertinomiranda at gmail dot com>
- Date: Sat, 21 Feb 2009 03:45:23 +0100
- Subject: Re: [plugins] [patch] Initial implementation of GCC plugin support
- References: <82091ad70902201351y79d58552nf90b2359d8b40e0a@mail.gmail.com>
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} ***