public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* plugin issues to fix (or document) before 4.5 release
@ 2009-11-30  6:05 Basile STARYNKEVITCH
  2009-12-02 22:17 ` Rafael Espindola
  0 siblings, 1 reply; 7+ messages in thread
From: Basile STARYNKEVITCH @ 2009-11-30  6:05 UTC (permalink / raw)
  To: GCC Mailing List

Hello All,

I believe there are several plugin issues to fix before 4.5 releases:

1. use of libiberty from plugins.

   As several patches recently sent demonstrated, the current state of the trunk does not work with plugins calling some 
of the libiberty functions is IMHO not acceptable.

   we could take some of the following solutions

   a) explicitly document in plugins.texi that libiberty is not callable from plugins (e.g. functions like pex_execute 
or make_temp_file, which are not currently linked into cc1). This is the easiest to do. My feeling is that it would be 
very unfortunate. Libiberty is documented as a portability layer; if plugins cannot use it, that means that plugins will 
never be a way of experimenting code which might (much latter) be (partly) proposed into the trunk. So giving up 
libiberty in plugins is an important social decision; it discourage people coding plugins to try to propose (much 
latter, when their plugin has a big enough audience) their code into the trunk latter.

   b) use some tricks to ensure that libiberty remains usable from plugins (I proposed a very crude one in
http://gcc.gnu.org/ml/gcc-patches/2009-11/msg01413.html - it is very ugly, but it should be highly portable, which is 
the aim of libiberty).

   c) when plugins are enabled, link libiberty as a dynamic libiberty.so (this has been sadly rejected some time ago). 
My feeling is that when cc1 depends upon dlopen, we might reconsider that decision, and have the dynamic library 
libiberty.so linked into cc1 when gcc is configured with plugins enabled  (leaving cc1 linking statically libiberty.a 
when plugins are disabled at configure time). I do confess that not being a configure.ac guru, I am not able to propose 
a good patch for that, and I don't know anymore well enough non-linux systems offering dlopen (I used to know quite well 
old SunOS5.2 about dlopen stuff) to understand all the issues involved.


2. organizing the plugin/ directory (and hinting how plugins could be distributed)
AFAIK this directory is only mentionned in http://gcc.gnu.org/onlinedocs/gccint/Plugins.html#Plugins §23.7 Building GCC 
plugins as containing the include/ directory required to compile plugins. We don't tell anything about what other stuff 
it could (or not contain), and if we really think it should only contain header files, why do we call it this way (it 
should better be called plugins-include), and why do we put an include/ sub-directory inside?
My personal feeling is that some few plugins -probably the most complex ones- could need to have some additional files 
for them (default configuration files, extra parameters, ...), in particular plugins providing extra domain or 
application specific diagnostics [like those wished inside big graphical toolkits like Gtk or Qt, or inside the linux 
kernel, etc..] will probably want to add extra information about those functions they know about outside of system 
header files (so perhaps in some other files). Likewise, plugin providing application or library specific optimisations 
(a trivial simplistic example is transforming fprintf(stdout, ...) into printf(...), but I am sure most people could 
imagine better examples, e.g. specializing qsort calls depending upon the size of the sorted array, and the compare 
functions, ...) probably might be conplex enough to want to have some files for them accessible by plugins.

We could even define a convention for system installed plugins, which would help the average user. Instead of typing 
-fplugin=/a/long/complex/path/to/a/common/plugin/like/foo.so he would just type -fplugin=foo. This is quite easy to 
implement.

And "complex" plugins needing to access their files have so far no convention or function to assist them. We could

a. minimally document that plugins need to organize entirely themselves any additional resources (notably files) that 
they require, and that it is not the business of GCC to help organize that. This would lead to huge heterogenity, even 
between different but similar Linux distributions. In particular, a same common plugin provided by two different linux 
distributions would have to be invoked differently....

b. make the plugin directory accessible from plugins and provide a function (usable from plugins) to query that.
I proposed a buggy patch in http://gcc.gnu.org/ml/gcc-patches/2009-11/msg01403.html. By thinking more about it, I would 
believe that the gcc driver should actually explicitly pass to cc1 (and other) programs the path to the plugin 
directory, so that querying it from plugins would be much easier. So that apparently means mostly a gcc *.spec file 
patch (I am not very familiar with spec files).

All the above issues are motivated by my MELT experience. In the current state, I am able to overcome them, in 
particular by duplicating withing MELT as plugin some functionality already provided by gcc (but not accessible to 
plugins), and/or by having my own conventions. But all the issues involved are not specific to MELT, and any other big 
or complex enough plugin will encounter them. Again, I can live without, but painfully.


3. Internationalization of plugins. I don't know much about gettext & friends (and most importantly, I don't understand 
all of the localization issues inside GCC) but I am not sure we have enough features to localize the warnings emitted by 
plugins. Leaving that entirely to plugins might be a mistake (again, because different Linux distributions might provide 
different answers). I agree it is not that important today: 4.5 plugins could be restricted to the C locale in practice!


Maybe what is just missing are a few sentences in plugin.texi about the shortcomings identified in this message (and a 
mention that most issues would be fixed in 4.6).

As a whole, plugins are a very nice feature of 4.5 (the other nice feature of 4.5 is LTO), and in my view they are very 
positive and will bring more people interested in GCC internals, ultimately enforcing the GCC community. But I do know 
that some people disagree with that view, and are scared, or not interested in, plugins becoming a success and widely 
used. My feeling & hope is that maybe within a year, some few plugins might be successful enough to be commonly used.
And certainly, plugins will permit some specialized processing (library or domain specific diagnostic or optimisation) 
which probably will never go into the trunk - and this is a good point.

All the issues involved in this email are not theoretical in any sense: the MELT plugin do encounter them, and have 
naughty tricks to avoid (ie circumvent) them. It would be much better if it didn't had to avoid these issues.

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} ***

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-12-03 22:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-30  6:05 plugin issues to fix (or document) before 4.5 release Basile STARYNKEVITCH
2009-12-02 22:17 ` Rafael Espindola
2009-12-03  7:37   ` Arnaud Charlet
2009-12-03  8:42     ` Dave Korn
2009-12-03 21:03     ` Joseph S. Myers
2009-12-03 22:12       ` Dave Korn
2009-12-03 22:16         ` Kai Tietz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).