This is the mail archive of the 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: MELT tutorial on the wiki

Tom Tromey wrote:
"Basile" == Basile STARYNKEVITCH <> writes:

Hi Basile.

Basile> I added as a turorial on the wiki, a small MELT pass which warns
Basile> against fprintf(stdout, ...) in the compiled code.

Basile> For GCC hackers, is the page
Basile> clear enough?

A very big thanks to Tom for looking at the page & trying MELT. I would be very proud if Tom happens to use it.

I've been looking for a very simple way to do some kinds of static
analysis on gdb, so today I tried building the MELT branch in hopes it
would serve this need.  Unfortunately, it didn't compile.

My current belief is that MELT is easier built (and used) as a GCC-trunk (or future GCC-4.5) plugin The advantage for you is also to be better fit to your GCC (provided it is similar enough to a recent trunk and have plugins enabled).
See the

There are however a few caveats when building MELT as a plugin:

a) The patch (submitted to the trunk on gcc-patches@) which provides a gengtype usable for MELT as a plugin is required. I hope it will be reviewed & accepted for the trunk. The current gengtype (in recent trunk) is not good enough for complex plugins like MELT. Of course, you have the patched gengtype.c in the MELT branch.
Currently, this is the most annoying issue when building MELT as a plugin.

b) some more headers are needed to MELT. the PLUGIN_HEADERS in gcc/ is really incomplete. See footnote 9 of

c) you need to hack the MELT compile script (used to compile MELT generated C code into a shared library), that is, you should edit the file gcc/melt-cc-script.proto of MELT branch to suit your needs, and rename it appropriately.

d) you need the PPL library (version 0.10.2 at least; the 0.10 is not enough). This is also needed when graphite is enabled.

With C++ enabled, I got this failure:

/space/tromey/MELT/gcc/libstdc++-v3/include/precompiled/stdc++.h:98:18: fatal error: chrono: No such file or directory

My fault: I had a mysterious message from svnmerge a few days ago about this file. I just copied it manually (from trunk to MELT branch rev 150308 which I just commited).

With just C enabled, I got:

make[2]: *** No rule to make target `install-melt-headers', needed by `install'.  Stop.
make[2]: Leaving directory `/space/tromey/MELT/build/gcc'

In both cases I just configured with --disable-bootstrap --enable-melt, plus the appropriate --enable-langauges option. This is on x86 F11.

You probably missed some configure arguments. The MELT's gcc/ ends with
## Basile adds a notice if the MELT branch is configured without
## --enable-melt
if test "$enabled_melt" != "yes" ; then
[GCC MELT branch is configured WITHOUT enabling melt.
Are you sure to want that?])

So if you got the GCC MELT branch is configured WITHOUT enabling melt message, your configure is wrong.

Basile> (of course, the pass implementation is imperfect, but I have hard time
Basile> finding good *small* examples).

My gdb examples involve finding broken code that can't be diagnosed by
the compiler.  Most of my examples are simple, but also actually useful.

For example, gdb has function that in the past could return null, but
which now cannot.  So, I'd like to find all places where the return
result is checked.

Or, gdb has a TRY_CATCH macro which expands to a couple of nested loops.
It is not ok to 'return' or 'goto' from inside the inner loop, as this
causes hard-to-find bugs.  So, it would be nice to find any place that
tries this.

Or, there is a data type in gdb that used to be freed using 'xfree', but
which now requires a special function to be called instead.  So, it
would be nice to find any place where xfree is passed an argument of
this type.

Etc.  For my purposes, any kind of simple analysis pass that is simple
to hack and doesn't require me to learn too much would be ideal.


So Tom, be kind enough to try MELT again (preferably in plugin mode). I am on holidays without email access from august 3rd to august 26th.

Tom, you are definitely the best MELT user I could have, since you know much better than I do the internals of GCC! I hope to be able to help you.

You could need to extend MELT (mostly file gcc/melt/ana-base.melt) to add all the hooks to GCC that you need and that are not there yet. Ask me for help please!

A very big thanks for your message & efforts.


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]