<HTML>

<TITLE>The Mercury Project: Mercury front-end for GCC</TITLE>
<BODY bgcolor="#ABCDEF" text="#000000">

<TABLE border="0" cellpadding="5" cellspacing="0" width="100%">
<TR>
    <TD>
    <CENTER><H1>The Mercury Project<br>
    Mercury front-end for GCC    </H1></CENTER>
    </TD>

    <TD width="10%">
        <IMG SRC="../images/merclogo_small.jpg" border="2"
        hspace="10" width="147" height="130"      ALT="[Mercury Logo]">
    </TD>
</TR>
</TABLE>

<TABLE border="0" cellpadding="5" cellspacing="0" width="100%">
<TR>
    <TD valign="top" bgcolor="#fcf4d4" width="15%">
    <B><a href="../index.html">Home</a></B>

<P>

<B><a href="../news.html">News</a></B>

<P>

<B><a href="../information.html">Information</a></B><BR>

<P>

<B><a href="../information/documentation.html">Documentation</a>
</B><BR>

<P>

<B><a href="../mailing-lists/mailing-lists.html">Mailing Lists</a></B><BR>

<P>

<B><a href="../backends.html">Back-ends</a></B><BR>
<SMALL>
    <a href="../backends.html#low_level_c">Low-level C</a><BR>
    <a href="../download/release-0.10.html#hlc">High-level C</a><BR>
    <a href="../dotnet.html">Microsoft .NET</a><BR>
    <a href="../download/gcc-backend.html">Native code</a><BR>
    <a href="http://www.cs.mu.oz.au/research/aditi/">Aditi</a><BR>
    <a href="../backends.html#java">Java</a><BR>
    <a href="../backends.html#bytecode">Mercury Bytecode</a><BR>
</SMALL>

<P>

<B><a href="../download.html">Download</a></B><BR>

<P>

<B><a href="../information/related.html">Related</a></B><BR>

<P>

<B><a href="../contact.html">Contact</a></B><BR>

<P>

<B><a href="../search.html">Search</a></B><BR>
    </TD>
    <TD valign="top">
    <H2>Native code compiler</H2>

The Mercury compiler can now generate assembler directly, rather than
compiling to assembler via C.  This is implemented by linking the
Mercury compiler front-end with the GNU Compiler Collection back-end.
The GNU Compiler Collection back-end is a fairly portable,
relatively language-independent, and mostly target-independent
optimizing compiler that has been ported to a very wide variety of
platforms, and which has front-ends for a variety of languages,
including C, C++, Ada, Fortran, Java, and now Mercury.

<p>
<H3>Status</H3>

The version of the native code compiler in our CVS repository and our
release-of-the-day distributions is based on GCC 3.0.
It bootstraps, and passes all of the appropriate tests in our test suite.
It is essentially ready for an official release.

However, currently it has only been tested on
i686-pc-linux-gnu (Intel x86 PCs running GNU/Linux).
We have don't know if it works on other systems.

<p>

The version of the Mercury native code compiler that was included in
Mercury 0.10.1 should be considered a beta release.  It does not support
nested modules or tabled evaluation.  It was based on an
unreleased snapshot version of the GCC back-end, and it does not
work if you use it with GCC 3.0 instead. 

<p>

The version of the GCC back-end interface included in Mercury 0.10
was also a beta release.  As well as the issues with 0.10.1, it also
had a bug that often caused the compiler to abort.  The work-around
for that is to compile with `--no-optimize-initializations'.
This was fixed in Mercury 0.10.1.

<p>

For more information, see the file gcc/mercury/README
in the mercury-gcc distribution (see below).

<p>
<H3>Sources</H3>

The sources for the Mercury native code compiler come in three parts:

<ul>
<li>
The first part is the usual <b>mercury-compiler</b> distribution.
This contains the Mercury compiler front-end (about 225,000 lines
of Mercury), as well as the Mercury standard library (about 50,000
lines of Mercury), runtime system (about 30,000 lines of C), etc.
You'll need version 0.10, version 0.10.1,
or (preferably) a release-of-the-day version dated 2001-07-30 or later.
You can get this from the <a href="../download.html">Download</a> section of the Mercury web site.
Or you can use
<a href="../information/developers/remote_cvs.html">CVS</a>.

<li>
The second part is the <b>gcc</b> distribution (about 450,000 lines of C).
The gcc distribution is available from the <A HREF="http://gcc.gnu.org">
GCC web site</A>.  Or you can get it from the
<A HREF="ftp://ftp.mercury.cs.mu.OZ.AU/pub/mercury/">
Mercury ftp site</A>.
For current release-of-the-day versions of Mercury, you'll need GCC 3.0.
One small
<A HREF="ftp://ftp.mercury.cs.mu.OZ.AU/pub/mercury/gcc-3.0.patch-for-mercury">
patch</a> must be applied to the GCC 3.0 sources
to make them work with the Mercury compiler.
For Mercury 0.10 or 0.10.1,
you'll need the 20010129 shapshot of gcc,
which you can get from the GCC cvs repository
(use the option `-rgcc_ss_20010129' when checking it out),
or from the
<A HREF="ftp://ftp.mercury.cs.mu.OZ.AU/pub/mercury/beta-releases/">
Mercury ftp site</A>.
A slightly different
<A HREF="http://gcc.gnu.org/ml/gcc-patches/2001-01/msg00577.html">
patch</a> must be applied to this snapshot of the GCC sources
to make them work with the Mercury compiler.

<li>
The third part is the <b>mercury-gcc</b> distribution, which provides
some C code that interfaces between the Mercury compiler front-end
and the GCC back-end.  We hope to eventually make this part of
the GCC distribution, but currently it is distributed separately,
via the <A HREF="ftp://ftp.mercury.cs.mu.OZ.AU/pub/mercury/beta-releases/">
Mercury ftp site</A>.
For Mercury 0.10 or 0.10.1, get mercury-gcc-0.10.1.tar.gz.
For release-of-the-day distributions, get mercury-gcc-rotd-20010731.tar.gz.
Alternatively, you can also get this using
<a href="../information/developers/remote_cvs.html">CVS</a>.
</ul>

Unfortunately the interface to the GCC back-end changes quite frequently,
so you need to be careful that you get matching versions of all of the
above.

<H3>Binaries</H3>

The native-code compiler is included in some of our binary distributions
for 0.10, 0.10.1, and the release-of-the-day releases.
The distributions that include the native-code compiler are
the ones named "*i686-pc-linux-gnu-O4*"
(but NOT the ones named "*i686-pc-linux-gnu-O4-hlc").

    </TD>
</TR>
</TABLE>

</BODY>
</HTML>