|
|

03-11-2010, 06:13 AM
|
|
|
packaging GCC plugins using gengtype (e.g. MELT)?
Hello All,
I am not a Debian Developper, and I am not very familiar with the
internals of dpkg, or with GCC packages inside Debian. However, I am a
GCC contributor [maintainer in GCC speak], and the proud author of MELT:
http://gcc.gnu.org/wiki/MiddleEndLispTranslator
Sylvestre Ledru nicely proposed me to try to package MELT for Debian. I
want to help him as much as I can (but I really want MELT to be packaged
when gcc-4.5 is available in Debian, avoiding waiting for gcc-4.6!).
See also the http://gcc.gnu.org/ml/gcc/2010-03/msg00120.html message.
In a few words, MELT (a GPLv3+ licensed, FSF copyrighted software) is an
"infrastructure" to code GCC extensions (like plugins) in a higher
level, domain specific, lisp-like language (called also MELT) which
provide useful features (functional programming, OO programming,
pattern-matching, ...) when coding GCC extensions (i.e. specific passes
in "plugins"). MELT generates C code (that is, it translates the MELT
lispy dialect into C code suitable for GCC, and #include-ing most of GCC
headers).
MELT should be compilable either as a self-contained GCC branch, or as a
plugin to an *unmodified* GCC 4.5 installation. These are two separate
ways of building MELT (either as an entire GCC branch -which is the way
I daily build MELT- or as a melt.so plugin for gcc 4.5; the melt.so
plugin is compiled from gcc/melt-runtime.c of the MELT branch. The
building procedure are somehow documented on the GCC wiki, notably
http://gcc.gnu.org/wiki/MELT%20tutorial and other pages). I suppose that
MELT users would prefer a melt.so module to an unmodified gcc 4.5
MELT has several peculiarities which makes it perhaps difficult to
package (but hopefully useful):
1. MELT dynamically generates C code, which is compiled into a shared
object (that I call a MELT module, not a plugin, because the convention
& API involved are not those of GCC plugins). which is itself dlopen-ed
(and then running). So an execution of a MELT extended GCC compilation
gcc -fplugin=melt.so -fplugin-arg-melt-init=runfile
-fplugin-arg-melt-arg=user-pass.melt
-O2 -c user-code-to-be-compiled.c
proceeds as follow:
a. GCC is started with the melt.so plugin and appropriate flags. the
gcc driver forks cc1, which dlopen-s melt.so; then several MELT modules
are dlopen-ed, notably warmelt*.so [which are the MELT translator] by
code inside melt.so. Notice that MELT does use many GCC plugin hooks,
http://gcc.gnu.org/onlinedocs/gccint/Plugins.html#Plugins and notably
PLUGIN_GGC_MARKING & PLUGIN_REGISTER_GGC_ROOTS & many others. So
building melt.so needs to run gengtype. Notice also that the GCC plugin
documentation strongly warns that "plugins needing to use gengtype
require a GCC build directory for the same version of GCC that they will
be linked against".
b. the melt.so plugin & the MELT modules warmelt*.so read some
[user-provided] user-pass.melt source file (in the MELT lispy dialect).
The cc1 + melt.so + warmelt*.so process generates several C files
[usually in some temporary directory], like user-pass.c & user-pass+01.c
c. The same cc1 + melt.so + warmelt*.so process forks a make -f
melt-module.mk command to build the user-pass.so MELT module from
user-pass.c & user-pass+01.c; this make command obviously requires
gcc-plugins-dev package & needs the
d. that dynamically generated user-pass.so MELT module is itself
dlopen-ed by the same cc1 + melt.so + warmelt*.so process, the
start_module_melt routine is dlsym-ed by melt.so inside user-pass.so, it
indirectly calls code to install a new GCC pass coded in MELT inside
user-pass.so
e. The cc1 compilation proceeds as usual, but the newly installed
GCC pass (coded in MELT in file user-pass.melt) do something useful when
compiling the user-code-to-be-compiled.c
Of course, the five steps above are quite an extreme case of MELT usage.
The user has the ability (thru -fplugin-arg-melt-init=translatefile)
to generate his user-pass.c & user-pass+01.c files from user-pass.melt
separately, and then build his user-pass.so MELT module, and have it
loaded in subsequent GCC invocations, without requiring
cc1+melt.so+warmelt*.so+user-pass.so to fork a make -f melt-module.mk
process.
Notice also that MELT is bootstrapped: the MELT translator is coded in
MELT, and the subversion repository contains also old
gcc/melt/generated/warmelt*.c files generated from
gcc/melt/warmelt*.melt. A MELT installation procedure usually build two
stages of the MELT translator (independently of GCC stages).
Now, one of the issues about MELT & Debian packaging is the fact that
melt-runtime.c (the source of melt.so plugin) uses GTY
http://gcc.gnu.org/onlinedocs/gccint/Type-Information.html#Type-Information
& register GGC roots thru PLUGIN_REGISTER_GGC_ROOTS ... Hence, it needs
gengtype (from GCC 4.5 build tree) to generate gt-melt-runtime.h
[#include-ed from melt-runtime.c] so the entire GCC 4.5 source & build
trees are needed to build melt.so (or any other gengtyp-ing GCC plugin).
I am not familiar enough with dpkg & debian packaging, but I believe
this hurts quite a lot and could be difficult to implement. Improving
gengtype to avoid that could be difficult, and definitely out of
question for the gcc-4.5 time frame (and probably painful for gcc-4.6).
An ugly solution might be to include that generated gt-melt-runtime.h
file inside the source package of the MELT module, but then any big
manual edits in melt-runtime.[ch] won't be propagated into
gt-melt-runtime.h. However, I could easily svn add the generated
gt-melt-runtime.h into GCC MELT svn tree (perhaps under contrib/) if
that helps Debian to package it.
Comments are welcome (but beware that I Basile am not very familiar with
Debian packaging, and even that I am still scared by the complexity of
GCC building procedures, notably Makefile.in & configure.ac files).
Thanks for reading.
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} ***
--
To UNSUBSCRIBE, email to debian-gcc-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4B989833.70705@starynkevitch.net">http://lists.debian.org/4B989833.70705@starynkevitch.net
|
|

03-14-2010, 11:15 AM
|
|
|
packaging GCC plugins using gengtype (e.g. MELT)?
Basile Starynkevitch wrote in
http://lists.debian.org/debian-gcc/2010/03/msg00047.html
Now, one of the issues about MELT & Debian packaging is the fact that
melt-runtime.c (the source of melt.so plugin) uses GTY
http://gcc.gnu.org/onlinedocs/gccint/Type-Information.html#Type-Information
& register GGC roots thru PLUGIN_REGISTER_GGC_ROOTS ... Hence, it needs
gengtype (from GCC 4.5 build tree) to generate gt-melt-runtime.h
[#include-ed from melt-runtime.c] so the entire GCC 4.5 source & build
trees are needed to build melt.so (or any other gengtyp-ing GCC plugin).
See also http://gcc.gnu.org/ml/gcc/2010-03/msg00120.html &
http://gcc.gnu.org/ml/gcc/2010-03/msg00129.html
I did wrote a script to build the GCC MELT plugin, and I even made a
tarball snapshot of it -but it is much preferable to retrieve it thru
subversion from the GCC MELT branch-
I also updated the instructions to build GCC MELT as a plugin on
http://gcc.gnu.org/wiki/MELT%20tutorial which contains a link to the
snapshot tarball. I will probably update that link when useful.
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} ***
--
To UNSUBSCRIBE, email to debian-gcc-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4B9CD369.3060500@starynkevitch.net">http://lists.debian.org/4B9CD369.3060500@starynkevitch.net
|
|

03-14-2010, 07:48 PM
|
|
|
packaging GCC plugins using gengtype (e.g. MELT)?
On 14.03.2010 13:15, Basile Starynkevitch wrote:
Basile Starynkevitch wrote in
http://lists.debian.org/debian-gcc/2010/03/msg00047.html
Now, one of the issues about MELT & Debian packaging is the fact that
melt-runtime.c (the source of melt.so plugin) uses GTY
http://gcc.gnu.org/onlinedocs/gccint/Type-Information.html#Type-Information
& register GGC roots thru PLUGIN_REGISTER_GGC_ROOTS ... Hence, it
needs gengtype (from GCC 4.5 build tree) to generate gt-melt-runtime.h
[#include-ed from melt-runtime.c] so the entire GCC 4.5 source & build
trees are needed to build melt.so (or any other gengtyp-ing GCC plugin).
there was another request to add the gengtype binary to the package, required by
the dragonegg plugin. details at:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=562882#13
Is the binary all, which would need to be added?
Matthias
--
To UNSUBSCRIBE, email to debian-gcc-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4B9D4B8D.9050509@debian.org">http://lists.debian.org/4B9D4B8D.9050509@debian.org
|
|

03-14-2010, 08:40 PM
|
|
|
packaging GCC plugins using gengtype (e.g. MELT)?
Matthias Klose wrote:
[posted on both gcc@ & debian-gcc@ lists]
On 14.03.2010 13:15, Basile Starynkevitch wrote:
See also http://gcc.gnu.org/ml/gcc/2010-03/msg00129.html &
http://gcc.gnu.org/ml/gcc/2010-03/msg00132.html - for those new to MELT see
http://gcc.gnu.org/wiki/MiddleEndLispTranslator and other MELT related
pages on GCC wiki.
Basile Starynkevitch wrote in
http://lists.debian.org/debian-gcc/2010/03/msg00047.html
Now, one of the issues about MELT & Debian packaging is the fact that
melt-runtime.c (the source of melt.so plugin) uses GTY
http://gcc.gnu.org/onlinedocs/gccint/Type-Information.html#Type-Information
& register GGC roots thru PLUGIN_REGISTER_GGC_ROOTS ... Hence, it
needs gengtype (from GCC 4.5 build tree) to generate gt-melt-runtime.h
[#include-ed from melt-runtime.c] so the entire GCC 4.5 source & build
trees are needed to build melt.so (or any other gengtyp-ing GCC plugin).
there was another request to add the gengtype binary to the package,
required by the dragonegg plugin. details at:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=562882#13
Is the binary all, which would need to be added?
No, to run gengtype for a plugin, you need gcc/gtyp-input.list and all
the files listed inside, which means a significant part of GCC source &
build trees (you need the gengtype binary from the build tree, but you
also need several *.h header files from that build tree, and perhaps
even some generated *.c files also there).
I have no idea if that is feasible within Debian. In other words, how
badly does that hurt the usual Debian package machinery?
Actually, the gengtype for plugin is somehow a kludge. It definitely
should be improved. But within GCC, we probably don't have time to do
that before 4.5. See also my message
http://gcc.gnu.org/ml/gcc/2010-03/msg00140.html
I hope that for 4.6, gengtype will be improved (I hope to contribute a
bit on that), but for 4.5 my feeling is that gengtype is sadly frozen. I
actually don't understand the current state of GCC trunk (i.e. soon to
be released 4.5) w.r.t. plugins [including gengtype]. What does stage 4
[bug fixes only] means for the newly born plugin infrastructure inside
GCC trunk?
And for the MELT plugin, I just made a tar snapshot referenced on
http://gcc.gnu.org/wiki/MELT%20tutorial (and I intend to update that
snapshot quite often) what I do there is ugly but works: I did generate
my gt-melt-runtime.h file (which is generated by gengtype in plugin
mode) and put it in the tar ball as
melt/generated/gt-melt-runtime-plugin.h hence ordinary users wanting to
compile MELT as a plugin don't need all the gengtype & related files
(which practically means a lot of the GCC source & build trees) but
could copy the gt-melt-runtime-plugin.h as gt-melt-runtime.h (hence
avoiding the need to generate that file). Of course, this won't work if
one want to edit MELT runtime source files melt-runtime.[ch] . In
practical terms, one can build MELT plugin (and use it, and even edit
the *.melt files which are the bulk of the work) without the GCC build &
source trees, but if you want to really edit & enhance the MELT runtime,
you better work on MELT as a branch (MELT as a branch is GCC trunk +
MELT specific files; it is mostly identical to GCC trunk + MELT plugin).
For what it worth, the ""generated but provided""
gt-melt-runtime-plugin.h file ends with
a comment to help to check, perhaps in a Debian installation procedure,
that it matches the source files its depends of (i.e.
melt-runtime.[hc]). It is ending with:
/* gt-melt-runtime-plugin.h file generated Sun 14 Mar 2010 10:08:18 AM CET
682216b6c67b29e5ba8082df0bfaad5e melt-runtime.h
265573514c86a89d8b8956afe5b8058c melt-runtime.c
*/
So if packaged plainly in the melt plugin package, there is at least a
way to warn the user if he changed melt-runtime.h. I am ashamed & hate
that, it is some kind of unvoluntary "Tivo"-isation of free software (in
the sense that you cannot arbitrarily edit all files of the MELT plugin
without the MELT branch) but you definitely can edit & build MELT as a
GCC branch, and once you did build that GCC MELT branch, you can quite
easily built the melt.so GCC plugin.
I have absolutely no idea if a Debian package can be defined as
depending upon both the source and the build tree of another package
(GCC 4.5). To Debian people: is that possible at all?
BTW, how some other bootstrapped software (perhaps Chicken Scheme
compiler, Ocaml compiler, ...) are packaged under Debian? Maybe it could
give some insights?
And today's URL of MELT plugin snapshot is
http://starynkevitch.net/Basile/GCC-MELT-plugin--snapshot-rev157446-2010-march-14.tgz
but please don't remember that long URL. I will change it quite often,
and update its reference in http://gcc.gnu.org/wiki/MELT%20tutorial
Besides, MELT is still quite buggy, so I hope that if some kind Debian
developer manage to package it as a plugin (Sylvestre Ledru offered
that help; I am grateful to him, but he is on a trip this week-end) he
will upload the MELT snapshot regularly, e.g. from SubVersion of the
MELT branch (I will make the first MELT release when gcc-4.5 will be
released, and when I will have corrected a few important bugs inside).
Cheers.
--
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} ***
--
To UNSUBSCRIBE, email to debian-gcc-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4B9D57B4.50904@starynkevitch.net">http://lists.debian.org/4B9D57B4.50904@starynkevitch.net
|
|
|
All times are GMT. The time now is 01:55 PM.
VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org
|