blob: 34de9f859495aeec9b4103ec1bfa99c57e77f6a1 [file] [log] [blame]
Duncan Sands8655b152008-02-14 17:53:22 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3<html>
4<head>
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>
8</head>
9<body>
10
11<div class="doc_title">
12 Building the LLVM GCC Front-End
13</div>
14
15<ol>
16 <li><a href="#instructions">Building llvm-gcc from Source</a></li>
17 <li><a href="#license">License Information</a></li>
18</ol>
19
20<div class="doc_author">
21 <p>Written by the LLVM Team</p>
22</div>
23
24<!-- *********************************************************************** -->
25<div class="doc_section">
26 <a name="instructions">Building llvm-gcc from Source</a>
27</div>
28<!-- *********************************************************************** -->
29
30<div class="doc_text">
31
Duncan Sands98301c02008-06-09 20:24:05 +000032<p>This section describes how to acquire and build llvm-gcc 4.2, which is based
33on the GCC 4.2.1 front-end. Supported languages are Ada, C, C++, Fortran,
34Objective-C and Objective-C++. Note that the instructions for building these
35front-ends are completely different (and much easier!) than those for building
36llvm-gcc3 in the past.</p>
Duncan Sands8655b152008-02-14 17:53:22 +000037
38<ol>
Misha Brukman0427f7a2008-12-29 21:20:51 +000039 <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
41 site</a>.</p>
Duncan Sands8655b152008-02-14 17:53:22 +000042
43 <p>It is also possible to download the sources of the llvm-gcc front end
Duncan Sands98301c02008-06-09 20:24:05 +000044 from a read-only mirror using subversion. To check out the 4.2 code
Duncan Sands8655b152008-02-14 17:53:22 +000045 for first time use:</p>
46
47<div class="doc_code">
48<pre>
Duncan Sands8655b152008-02-14 17:53:22 +000049svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk <i>dst-directory</i>
50</pre>
51</div>
52
53 <p>After that, the code can be be updated in the destination directory
54 using:</p>
55
56<div class="doc_code">
57<pre>svn update</pre>
58</div>
59
60 <p>The mirror is brought up to date every evening.</p></li>
61
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.
65</ol>
66
67</div>
68
69<!-- *********************************************************************** -->
70<div class="doc_section">
71 <a name="license">Building the Ada front-end</a>
72</div>
73
74<div class="doc_text">
75<p>Building with support for Ada amounts to following the directions in the
76top-level <tt>README.LLVM</tt> file, adding ",ada" to EXTRALANGS, for example:
77<tt>EXTRALANGS=,ada</tt></p>
78
79<p>There are some complications however:</p>
80
81<ol>
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
Duncan Sandsd918b7e2008-04-11 13:24:43 +000087 build it. Compilers known to work with the
Duncan Sandsb8ee8012008-12-10 14:24:58 +000088 <a href="http://llvm.org/releases/download.html">LLVM 2.4 release</a>
Duncan Sandsd918b7e2008-04-11 13:24:43 +000089 are <a href="http://gcc.gnu.org/releases.html">gcc-4.2</a> and the
Duncan Sands98301c02008-06-09 20:24:05 +000090 2005, 2006 and 2007 versions of the
91 <a href="http://libre.adacore.com/">GNAT GPL Edition</a>.
Duncan Sands17bcde92008-02-16 09:47:41 +000092 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.
Duncan Sands8655b152008-02-14 17:53:22 +000094 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
Duncan Sands98301c02008-06-09 20:24:05 +000098 <a href="http://libre.adacore.com/">2007 GNAT GPL Edition</a>)
Duncan Sands8655b152008-02-14 17:53:22 +000099 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
Duncan Sandsd918b7e2008-04-11 13:24:43 +0000101 compiler with checking enabled. This causes it to run much slower, but
Duncan Sands8655b152008-02-14 17:53:22 +0000102 helps catch mistakes in the compiler (please report any problems using
103 <a href="http://llvm.org/bugs">LLVM bugzilla</a>).</p></li>
104</ol>
105
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>
108
109<ol>
110 <li><p>Download the <a href="http://llvm.org/releases/download.html">LLVM source</a>
111 and unpack it:</p>
112
Misha Brukman0427f7a2008-12-29 21:20:51 +0000113<pre class="doc_code">
114wget http://llvm.org/releases/2.4/llvm-2.4.tar.gz
Duncan Sandsb8ee8012008-12-10 14:24:58 +0000115tar xzf llvm-2.4.tar.gz
Misha Brukman0427f7a2008-12-29 21:20:51 +0000116mv llvm-2.4 llvm
117</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000118
119 <p>or <a href="GettingStarted.html#checkout">check out the
120 latest version from subversion</a>:</p>
121
Misha Brukman0427f7a2008-12-29 21:20:51 +0000122<pre class="doc_code">svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</pre>
123
Duncan Sands8655b152008-02-14 17:53:22 +0000124 </li>
125
126 <li><p>Download the
127 <a href="http://llvm.org/releases/download.html">llvm-gcc-4.2 source</a>
128 and unpack it:</p>
129
Misha Brukman0427f7a2008-12-29 21:20:51 +0000130<pre class="doc_code">
131wget http://llvm.org/releases/2.4/llvm-gcc-4.2-2.4.source.tar.gz
Duncan Sandsb8ee8012008-12-10 14:24:58 +0000132tar xzf llvm-gcc-4.2-2.4.source.tar.gz
Misha Brukman0427f7a2008-12-29 21:20:51 +0000133mv llvm-gcc4.2-2.4.source llvm-gcc-4.2
134</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000135
136 <p>or <a href="GettingStarted.html#checkout">check out the
137 latest version from subversion</a>:</p>
138
Misha Brukman0427f7a2008-12-29 21:20:51 +0000139<pre class="doc_code">
140svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk llvm-gcc-4.2
141</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000142 </li>
143
144 <li><p>Make a build directory <tt>llvm-objects</tt> for llvm and make it the
145 current directory:</p>
146
Misha Brukman0427f7a2008-12-29 21:20:51 +0000147<pre class="doc_code">
148mkdir llvm-objects
149cd llvm-objects
150</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000151 </li>
152
153 <li><p>Configure LLVM (here it is configured to install into <tt>/usr/local</tt>):</p>
154
Misha Brukman0427f7a2008-12-29 21:20:51 +0000155<pre class="doc_code">
156../llvm/configure --prefix=<b>/usr/local</b>
157</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000158
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>
161
Misha Brukman0427f7a2008-12-29 21:20:51 +0000162<pre class="doc_code">
163CXX=<b>PATH_TO_C++_COMPILER</b> ../llvm/configure --prefix=<b>/usr/local</b>
164</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000165 </li>
166
167 <li><p>Build LLVM with checking enabled (use <tt>ENABLE_OPTIMIZED=1</tt> to
168 build without checking):</p>
169
Misha Brukman0427f7a2008-12-29 21:20:51 +0000170<pre class="doc_code">
171make ENABLE_OPTIMIZED=0
172</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000173 </li>
174
175 <li><p>Install LLVM (optional):</p>
176
Misha Brukman0427f7a2008-12-29 21:20:51 +0000177<pre class="doc_code">
178make ENABLE_OPTIMIZED=0 install
179</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000180 </li>
181
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>
184
Misha Brukman0427f7a2008-12-29 21:20:51 +0000185<pre class="doc_code">
Duncan Sands8655b152008-02-14 17:53:22 +0000186cd ..
187mkdir llvm-gcc-4.2-objects
Misha Brukman0427f7a2008-12-29 21:20:51 +0000188cd llvm-gcc-4.2-objects
189</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000190 </li>
191
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.
Duncan Sands98301c02008-06-09 20:24:05 +0000194 If you omit it then LLVM should be built with <tt>make ENABLE_OPTIMIZED=1</tt>.
Duncan Sands8655b152008-02-14 17:53:22 +0000195 Additional languages can be appended to the --enable-languages switch,
196 for example <tt>--enable-languages=ada,c,c++</tt>.</p>
197
Misha Brukman0427f7a2008-12-29 21:20:51 +0000198<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
200</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000201
202 <p>If you have a multi-compiler setup, then you can configure like this:</p>
Duncan Sands8655b152008-02-14 17:53:22 +0000203
Misha Brukman0427f7a2008-12-29 21:20:51 +0000204<pre class="doc_code">
Duncan Sands8655b152008-02-14 17:53:22 +0000205export CC=<b>PATH_TO_C_AND_ADA_COMPILER</b>
206export CXX=<b>PATH_TO_C++_COMPILER</b>
Misha Brukman0427f7a2008-12-29 21:20:51 +0000207../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
208</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000209 </li>
210
211 <li><p>Build and install the compiler:</p>
212
Misha Brukman0427f7a2008-12-29 21:20:51 +0000213<pre class="doc_code">
214make
215make install
216</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000217 </li>
218</ol>
219
220</div>
221
222<!-- *********************************************************************** -->
223<div class="doc_section">
224 <a name="license">Building the Fortran front-end</a>
225</div>
226
227<div class="doc_text">
228<p>
229To 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>
231
Misha Brukman0427f7a2008-12-29 21:20:51 +0000232<pre class="doc_code">
Duncan Sands8655b152008-02-14 17:53:22 +0000233EXTRALANGS=,fortran
234</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000235
236</div>
237
238<!-- *********************************************************************** -->
239<div class="doc_section">
240 <a name="license">License Information</a>
241</div>
242
243<div class="doc_text">
244<p>
245The LLVM GCC frontend is licensed to you under the GNU General Public License
246and the GNU Lesser General Public License. Please see the files COPYING and
247COPYING.LIB for more details.
248</p>
249
250<p>
251More information is <a href="FAQ.html#license">available in the FAQ</a>.
252</p>
253</div>
254
255<!-- *********************************************************************** -->
256
257<hr>
258<address>
259 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +0000260 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
Duncan Sands8655b152008-02-14 17:53:22 +0000261 <a href="http://validator.w3.org/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +0000262 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
Duncan Sands8655b152008-02-14 17:53:22 +0000263
264 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
265 Last modified: $Date$
266</address>
267
268</body>
269</html>