|Search in this site:||
Executive Summary: (printable)
Customizing your GCC compiler with MELT extensions (2 pages / one sheet, PDF, in english).
Votre compilateur GCC sur mesure avec MELT (1 page, PDF, in french - en français)
NEW! january, 31st, 2015: talk at FOSDEM2015 (Lisp devroom): slides Customizing GCC with MELT (a Lispy dialect) (PDF)
NEW! (july 24th, 2015) MELT 1.2.0 plugin release for GCC 4.9 and 5.* downloadable, please ugrade.
GCC MELT is a high-level domain specific language for extending or
customizing the Gnu Compiler
Collection (i.e. gcc,
g++, gfortran, gnat, gccgo, gobjc, ...). It
is implemented as a GCC plugin (for GNU/Linux systems, with
GCC 4.7, 4.8 or later) in a free software (under GPLv3+
license and FSF copyright).
GCC MELT targets advanced GCC users developing, compiling, improving, evaluating, maintaining, or designing important software (coded in C, C++, Fortran, Ada, Go, Objective C or any language supported by a recent straight- or cross- GCC compiler). For such power users, spending a few days or weeks to customize or extend their compiler for their specific needs is worthwhile, and GCC MELT should lower the required effort, because coding in MELT a GCC extension is much easier than manually developping a GCC plugin in C or C++ (these are efficient languages, but not well fit to easily work on compiler's internal representations).
GCC MELT (since MELT 1.0) can also be used to explore the internal representations of the GCC compiler when it is working on your files, see here. For example, you could find all calls to malloc with a constant size greater than 48 bytes, or all assignments to some next fields of struct-ure whose name contains point (and such searches are not possible with textual tools like grep; they have to be made at the Gimple level inside the compiler).
GCC MELT (that is, your daily GCC [cross-] compiler augmented with the MELT [meta-] plugin and your own extensions) could be the foundational block of some Industry Specific Software Development Kit for e.g. embedded, GUI, or low-level software. Please contact us for more information.
GCC MELT uses existing GCC plugin hooks to work on GCC internal middle-end representations, notably GCC Generic Trees and GCC Gimples, and the control flow graph. These powerful internal representations are common to all source languages accepted by GCC, so your extension coded in MELT will be able to handle any source code compiled by GCC.
Probably, GCC MELT won't be very useful to casual GCC users working on tiny programming projects, unless they simply use some existing GCC extensions already developed with GCC MELT.
The GCC compiler can be customized or extended (with plugins or MELT extensions) for:
json_packin Jansson library, or
g_object_setin GTK toolkit), or checking some properties at every call of some given function;
pthread_mutex_unlockare balanced in the same function, or that every
fopengets its resulted tested);
CFLAGS += -fplugin=melt -fplugin-arg-melt-extra=extension -fplugin-arg-melt-mode=modein a
Makefile), but don't need to change workflow habits.
MELT is a domain-specific language specifically designed to ease the extension (or customization) of GCC because of the following features:
loop-s in a statically typed manner
The emitted C or C++ code is carefully generated to fit into what your GCC plugin interface expects (GCC switched from C to C++ in its 4.7 version, and GCC MELT is careful to generate a code acceptable by your version of GCC).
A practical way to understand more on main GCC internal representations is to have a relevant (small) source code (e.g. in C, C++, Fortran, or Ada, etc), then compile it with the
For instance (assuming you have
example.cc in some playground directory) compile
g++ -fdump-tree-all -O -c example.cc. This produce
hundreds of dump files, such as
example.cc.073t.phiopt1 which might contain (like dump files suffixed
(Static Single Assignment) statements, that you can browse using an editor or pager (e.g.
less example.cc.073t.phiopt1 or
GCC MELT is downloadable here (under GPLv3 license, for GNU/Linux systems with a recent GCC), where you can get installation instructions, and also examples of code written in MELT.
Please download and install GCC MELT before reading other material.
GCC MELT has some documentation here , where you can get tutorial, and also reference about MELT, with publications and slides of talks given on it.
GCC MELT is an improvement to GCC itself, so follows the same contribution policies as the GCC compiler. In particular, it demands the same legal prerequisites (which take a lot of time). We cannot accept even small patches without your contribution belonging legally to the FSF (as GCC MELT does).
Thanks to (in alphabetical order) Romain Geissler, Emmanuel Haucourt, Alexandre Lissy, Jérémie Salvucci, Pierre Vittet for their contributions to GCC MELT.
MELT is mostly made in France, because its main contributors happen to be French. Of course we welcome any contributor (from any country).
In ChangeLog.MELT entries and in messages, we will refer to these tickets as MELT-SFT (for MELT -Source Forge Ticket).
I am interested in participating to any projects where extending GCC thru MELT is worthwhile.
(non-exhaustive list of references to related tools)
An English-speaking low-traffic technical group (no flamewars, no spam) about GCC MELT is available on
|Subscribe to email@example.com|
|Visit this group|
The old page on GCC MELT is available here.
Thanks to Julia Duong, a translation by the Coupofy team of some previous version of this page is available in Vietnamese.
Thanks to some people from Couponmachine, a translation of some previous version of this page is available in Polish.
Thanks to Karina Sheludenko, a translation by Everycloudtech of some previous version of this page is available in Russian.
Thanks to Vicky Rotarova, a translation of some previous version of this page is available in Belarussian.
Thanks to Patricia Motosan, a translation of some previous version of this page is available in Bosnian.
Please refer to the original gcc-melt.org site.