1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6 <link rel="stylesheet" href="llvm.css" type="text/css" media="screen">
7 <title>Building the LLVM GCC Front-End</title>
11 <div class="doc_title">
12 Building the LLVM GCC Front-End
16 <li><a href="#instructions">Building llvm-gcc from Source</a></li>
17 <li><a href="#license">License Information</a></li>
20 <div class="doc_author">
21 <p>Written by the LLVM Team</p>
24 <!-- *********************************************************************** -->
25 <div class="doc_section">
26 <a name="instructions">Building llvm-gcc from Source</a>
28 <!-- *********************************************************************** -->
30 <div class="doc_text">
32 <p>This section describes how to acquire and build llvm-gcc 4.2, which is based
33 on the GCC 4.2.1 front-end. Supported languages are Ada, C, C++, Fortran,
34 Objective-C and Objective-C++. Note that the instructions for building these
35 front-ends are completely different (and much easier!) than those for building
36 llvm-gcc3 in the past.</p>
39 <li><p>Retrieve the appropriate llvm-gcc-4.2-<i>version</i>.source.tar.gz
40 archive from the <a href="http://llvm.org/releases/">LLVM web
43 <p>It is also possible to download the sources of the llvm-gcc front end
44 from a read-only mirror using subversion. To check out the 4.2 code
45 for first time use:</p>
47 <div class="doc_code">
49 svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk <i>dst-directory</i>
53 <p>After that, the code can be be updated in the destination directory
56 <div class="doc_code">
60 <p>The mirror is brought up to date every evening.</p></li>
62 <li>Follow the directions in the top-level <tt>README.LLVM</tt> file for
63 up-to-date instructions on how to build llvm-gcc. See below for building
64 with support for Ada or Fortran.
69 <!-- *********************************************************************** -->
70 <div class="doc_section">
71 <a name="license">Building the Ada front-end</a>
74 <div class="doc_text">
75 <p>Building with support for Ada amounts to following the directions in the
76 top-level <tt>README.LLVM</tt> file, adding ",ada" to EXTRALANGS, for example:
77 <tt>EXTRALANGS=,ada</tt></p>
79 <p>There are some complications however:</p>
82 <li><p>The only platform for which the Ada front-end is known to build is
83 32 bit intel x86 running linux. It is unlikely to build for other
84 systems without some work.</p></li>
85 <li><p>The build requires having a compiler that supports Ada, C and C++.
86 The Ada front-end is written in Ada so an Ada compiler is needed to
87 build it. Compilers known to work with the
88 <a href="http://llvm.org/releases/download.html">LLVM 2.4 release</a>
89 are <a href="http://gcc.gnu.org/releases.html">gcc-4.2</a> and the
90 2005, 2006 and 2007 versions of the
91 <a href="http://libre.adacore.com/">GNAT GPL Edition</a>.
92 The LLVM parts of llvm-gcc are written in C++ so a C++ compiler is
93 needed to build them. The rest of gcc is written in C.
94 Some linux distributions provide a version of gcc that supports all
95 three languages (the Ada part often comes as an add-on package to
96 the rest of gcc). Otherwise it is possible to combine two versions
97 of gcc, one that supports Ada and C (such as the
98 <a href="http://libre.adacore.com/">2007 GNAT GPL Edition</a>)
99 and another which supports C++, see below.</p></li>
100 <li><p>Because the Ada front-end is experimental, it is wise to build the
101 compiler with checking enabled. This causes it to run much slower, but
102 helps catch mistakes in the compiler (please report any problems using
103 <a href="http://llvm.org/bugs">LLVM bugzilla</a>).</p></li>
106 <p>Supposing appropriate compilers are available, llvm-gcc with Ada support can
107 be built on an x86-32 linux box using the following recipe:</p>
110 <li><p>Download the <a href="http://llvm.org/releases/download.html">LLVM source</a>
113 <pre class="doc_code">
114 wget http://llvm.org/releases/2.4/llvm-2.4.tar.gz
115 tar xzf llvm-2.4.tar.gz
119 <p>or <a href="GettingStarted.html#checkout">check out the
120 latest version from subversion</a>:</p>
122 <pre class="doc_code">svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</pre>
127 <a href="http://llvm.org/releases/download.html">llvm-gcc-4.2 source</a>
130 <pre class="doc_code">
131 wget http://llvm.org/releases/2.4/llvm-gcc-4.2-2.4.source.tar.gz
132 tar xzf llvm-gcc-4.2-2.4.source.tar.gz
133 mv llvm-gcc4.2-2.4.source llvm-gcc-4.2
136 <p>or <a href="GettingStarted.html#checkout">check out the
137 latest version from subversion</a>:</p>
139 <pre class="doc_code">
140 svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk llvm-gcc-4.2
144 <li><p>Make a build directory <tt>llvm-objects</tt> for llvm and make it the
145 current directory:</p>
147 <pre class="doc_code">
153 <li><p>Configure LLVM (here it is configured to install into <tt>/usr/local</tt>):</p>
155 <pre class="doc_code">
156 ../llvm/configure --prefix=<b>/usr/local</b>
159 <p>If you have a multi-compiler setup and the C++ compiler is not the
160 default, then you can configure like this:</p>
162 <pre class="doc_code">
163 CXX=<b>PATH_TO_C++_COMPILER</b> ../llvm/configure --prefix=<b>/usr/local</b>
167 <li><p>Build LLVM with checking enabled (use <tt>ENABLE_OPTIMIZED=1</tt> to
168 build without checking):</p>
170 <pre class="doc_code">
171 make ENABLE_OPTIMIZED=0
175 <li><p>Install LLVM (optional):</p>
177 <pre class="doc_code">
178 make ENABLE_OPTIMIZED=0 install
182 <li><p>Make a build directory <tt>llvm-gcc-4.2-objects</tt> for llvm-gcc and make it the
183 current directory:</p>
185 <pre class="doc_code">
187 mkdir llvm-gcc-4.2-objects
188 cd llvm-gcc-4.2-objects
192 <li><p>Configure llvm-gcc (here it is configured to install into <tt>/usr/local</tt>).
193 The <tt>--enable-checking</tt> flag turns on sanity checks inside the compiler.
194 If you omit it then LLVM should be built with <tt>make ENABLE_OPTIMIZED=1</tt>.
195 Additional languages can be appended to the --enable-languages switch,
196 for example <tt>--enable-languages=ada,c,c++</tt>.</p>
198 <pre class="doc_code">
199 ../llvm-gcc-4.2/configure --prefix=<b>/usr/local</b> --enable-languages=ada,c --enable-checking --enable-llvm=$PWD/../llvm-objects --disable-bootstrap --disable-multilib
202 <p>If you have a multi-compiler setup, then you can configure like this:</p>
204 <pre class="doc_code">
205 export CC=<b>PATH_TO_C_AND_ADA_COMPILER</b>
206 export CXX=<b>PATH_TO_C++_COMPILER</b>
207 ../llvm-gcc-4.2/configure --prefix=<b>/usr/local</b> --enable-languages=ada,c --enable-checking --enable-llvm=$PWD/../llvm-objects --disable-bootstrap --disable-multilib
211 <li><p>Build and install the compiler:</p>
213 <pre class="doc_code">
222 <!-- *********************************************************************** -->
223 <div class="doc_section">
224 <a name="license">Building the Fortran front-end</a>
227 <div class="doc_text">
229 To build with support for Fortran, follow the directions in the top-level
230 <tt>README.LLVM</tt> file, adding ",fortran" to EXTRALANGS, for example:</p>
232 <pre class="doc_code">
238 <!-- *********************************************************************** -->
239 <div class="doc_section">
240 <a name="license">License Information</a>
243 <div class="doc_text">
245 The LLVM GCC frontend is licensed to you under the GNU General Public License
246 and the GNU Lesser General Public License. Please see the files COPYING and
247 COPYING.LIB for more details.
251 More information is <a href="FAQ.html#license">available in the FAQ</a>.
255 <!-- *********************************************************************** -->
259 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
260 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
261 <a href="http://validator.w3.org/check/referer"><img
262 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
264 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
265 Last modified: $Date$