public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* libiberty should be a shared library when cc1 has plugin enabled.
@ 2009-07-09  8:49 Basile Starynkevitch
  2009-07-09 11:41 ` Dave Korn
  2009-07-09 12:50 ` Daniel Jacobowitz
  0 siblings, 2 replies; 14+ messages in thread
From: Basile Starynkevitch @ 2009-07-09  8:49 UTC (permalink / raw)
  To: gcc

Hello All,

Perhaps libiberty should be a shared library, not a static one, linked from
cc1, when GCC has plugin enabled.

I noticed the following in the MELT branch (while trying to build MELT as a
GCC-Trunk plugin).

Some functions of libiberty.h are not linked in cc1 (because cc1 don't call
them, and libliberty.a is a static library, not a shared one). A concrete
example is make_temp_file. It is used in gcc.c but not in the entire cc1,
and one could imagine a plugin might want it. But if a plugin calls it, the
dlopen of that plugin fails with undefined symbol: make_temp_file.

Of course, for that simple case a workaround is possible (at least on
Linux): use a standard temporary file function like tmpfile() instead of
make_temp_file.

But it seems to me that a plugin can call a libliberty function only if that
function is already referenced (e.g. called) from cc1. This is not the case
of all libiberty functions.

We might also artificially add a reference to each libiberty function from
cc1. Or we should at least document (perhaps as a comment in libiberty.h)
that all these functions are not available from plugins.

Linking statically libiberty.a into a plugin is not recommended (because
*.so should not contain non PIC code on many platforms).

If we did link dynamically libiberty.so:

* execution time (of cc1) might suffer a bit, because perhaps calling a
function in a dynamic library could be slower than calling it in a static
library.

* every plugin could use all of libliberty.so

* the Makefile.in files should be changed.


Comments are welcome.

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] 14+ messages in thread

end of thread, other threads:[~2009-07-09 15:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-09  8:49 libiberty should be a shared library when cc1 has plugin enabled Basile Starynkevitch
2009-07-09 11:41 ` Dave Korn
2009-07-09 11:58   ` Basile STARYNKEVITCH
2009-07-09 12:17     ` Dave Korn
2009-07-09 12:38       ` Basile STARYNKEVITCH
2009-07-09 12:50 ` Daniel Jacobowitz
2009-07-09 13:01   ` Basile STARYNKEVITCH
2009-07-09 13:43     ` Daniel Jacobowitz
2009-07-09 13:46       ` Basile STARYNKEVITCH
2009-07-09 13:59         ` Daniel Jacobowitz
2009-07-09 14:06           ` Basile STARYNKEVITCH
2009-07-09 15:07       ` Ralf Wildenhues
2009-07-09 15:20         ` Basile STARYNKEVITCH
2009-07-09 13:07   ` Ralf Wildenhues

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).