blob: e3ade88c78732d276588c4bf28d56e98c254ddf6 [file] [log] [blame]
Misha Brukman4478f2b2004-05-12 18:49:47 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
Misha Brukman0ccf5192003-10-23 01:48:33 +00003<html>
4<head>
Misha Brukman4478f2b2004-05-12 18:49:47 +00005 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6 <link rel="stylesheet" href="llvm.css" type="text/css" media="screen">
Chris Lattner3009bcc2007-02-14 07:42:12 +00007 <title>Building the LLVM C/C++ Front-End</title>
Misha Brukman0ccf5192003-10-23 01:48:33 +00008</head>
9<body>
Brian Gaeke0142c1e2003-10-21 21:58:38 +000010
Misha Brukman0ccf5192003-10-23 01:48:33 +000011<div class="doc_title">
Duncan Sandseadf20d2008-02-12 21:22:58 +000012 Building the LLVM GCC Front-End
Misha Brukman0ccf5192003-10-23 01:48:33 +000013</div>
Brian Gaeke0142c1e2003-10-21 21:58:38 +000014
Brian Gaekee6406a82003-11-12 20:47:30 +000015<ol>
Duncan Sandseadf20d2008-02-12 21:22:58 +000016 <li><a href="#instructions">Building llvm-gcc from Source</a></li>
Chris Lattnerbbdec032004-06-01 18:13:05 +000017 <li><a href="#license">License Information</a></li>
Brian Gaekee6406a82003-11-12 20:47:30 +000018</ol>
19
Chris Lattner020e1fc2004-05-23 21:07:27 +000020<div class="doc_author">
Chris Lattner3009bcc2007-02-14 07:42:12 +000021 <p>Written by the LLVM Team</p>
Brian Gaekee6406a82003-11-12 20:47:30 +000022</div>
23
24<!-- *********************************************************************** -->
25<div class="doc_section">
Duncan Sandseadf20d2008-02-12 21:22:58 +000026 <a name="instructions">Building llvm-gcc from Source</a>
Misha Brukman0ccf5192003-10-23 01:48:33 +000027</div>
28<!-- *********************************************************************** -->
29
30<div class="doc_text">
Chris Lattnerfa289942006-07-11 20:47:00 +000031
Duncan Sandseadf20d2008-02-12 21:22:58 +000032<p>This section describes how to acquire and build llvm-gcc 4.0 and 4.2, which are
33based on the GCC 4.0.1/4.2.1 front-ends respectively. Both front-ends support C,
34C++, Objective-C and Objective-C++. The 4.2 front-end also supports Ada and
35Fortran to some extent. Note that the instructions for building these front-ends
36are completely different (and much easier!) than those for building llvm-gcc3 in
Chris Lattner3009bcc2007-02-14 07:42:12 +000037the past.</p>
Chris Lattnerfa289942006-07-11 20:47:00 +000038
Brian Gaeke0142c1e2003-10-21 21:58:38 +000039<ol>
Duncan Sandseadf20d2008-02-12 21:22:58 +000040 <li><p>Retrieve the appropriate llvm-gcc4.x-y.z.source.tar.gz archive from the
Chris Lattner3009bcc2007-02-14 07:42:12 +000041 <a href="http://llvm.org/releases/">llvm web site</a>.</p>
Jim Laskey6b6e3692006-06-16 23:34:49 +000042
Duncan Sandseadf20d2008-02-12 21:22:58 +000043 <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.0 code
45 for first time use:</p>
Jim Laskey6b6e3692006-06-16 23:34:49 +000046
Bill Wendlingae2a3092006-11-16 09:31:19 +000047<div class="doc_code">
48<pre>
Bill Wendlingd0c5c282007-07-23 03:56:42 +000049svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.0/trunk <i>dst-directory</i>
Bill Wendlingae2a3092006-11-16 09:31:19 +000050</pre>
51</div>
Jim Laskey6b6e3692006-06-16 23:34:49 +000052
Duncan Sandseadf20d2008-02-12 21:22:58 +000053<p>To check out the 4.2 code use:</p>
54
55<div class="doc_code">
56<pre>
57svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk <i>dst-directory</i>
58</pre>
59</div>
60
Bill Wendlingae2a3092006-11-16 09:31:19 +000061 <p>After that, the code can be be updated in the destination directory
62 using:</p>
Jim Laskey6b6e3692006-06-16 23:34:49 +000063
Bill Wendlingae2a3092006-11-16 09:31:19 +000064<div class="doc_code">
65<pre>svn update</pre>
66</div>
Chris Lattnerfa289942006-07-11 20:47:00 +000067
Bill Wendlingae2a3092006-11-16 09:31:19 +000068 <p>The mirror is brought up to date every evening.</p></li>
69
70 <li>Follow the directions in the top-level <tt>README.LLVM</tt> file for
Duncan Sandseadf20d2008-02-12 21:22:58 +000071 up-to-date instructions on how to build llvm-gcc. See below for building
72 with support for Ada or Fortran.
Chris Lattnerfa289942006-07-11 20:47:00 +000073</ol>
Bill Wendlingae2a3092006-11-16 09:31:19 +000074
Chris Lattnerfa289942006-07-11 20:47:00 +000075</div>
Duncan Sandseadf20d2008-02-12 21:22:58 +000076
77<!-- *********************************************************************** -->
78<div class="doc_section">
79 <a name="license">Building the Ada front-end</a>
80</div>
81
82<div class="doc_text">
83<p>Building with support for Ada amounts to following the directions in the
84top-level <tt>README.LLVM</tt> file, adding ",ada" to EXTRALANGS, for example:
85<tt>EXTRALANGS=,ada</tt></p>
86
87<p>There are some complications however:</p>
88
89<ol>
Duncan Sands2ae968a2008-02-12 21:28:39 +000090 <li><p>The only platform for which the Ada front-end is known to build is
Duncan Sandseadf20d2008-02-12 21:22:58 +000091 32 bit intel x86 running linux. It is unlikely to build for other
Duncan Sands2ae968a2008-02-12 21:28:39 +000092 systems without some work.</p></li>
93 <li><p>The build requires having a compiler that supports Ada, C and C++.
Duncan Sandseadf20d2008-02-12 21:22:58 +000094 The Ada front-end is written in Ada so an Ada compiler is needed to
95 build it. The LLVM parts of llvm-gcc are written in C++ so a C++
96 compiler is needed to build them. The rest of gcc is written in C.
97 Some linux distributions provide a version of gcc that supports all
98 three languages (the Ada part often comes as an add-on package to
99 the rest of gcc). Otherwise it is possible to combine two versions
100 of gcc, one that supports Ada and C (such as
101 <a href="http://libre.adacore.com/">GNAT GPL Edition</a>) and another
Duncan Sands2ae968a2008-02-12 21:28:39 +0000102 which supports C++, see below.</p></li>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000103</ol>
104
105<p>Supposing appropriate compilers are available, llvm-gcc with Ada support can
106 be built using the following recipe:</p>
107
108<ol>
Duncan Sands2ae968a2008-02-12 21:28:39 +0000109 <li><p>Download the <a href="http://llvm.org/releases/download.html">LLVM source</a>
110 and unpack it:</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000111
112<div class="doc_code">
113<pre>wget http://llvm.org/releases/2.2/llvm-2.2.tar.gz
114tar xzf llvm-2.2.tar.gz
115mv llvm-2.2 llvm</pre>
116</div>
117
Duncan Sands2ae968a2008-02-12 21:28:39 +0000118 <p>or <a href="http://llvm.org/docs/GettingStarted.html#checkout">check out the
119 latest version from subversion</a>:</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000120
121<div class="doc_code">
122<pre>svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</pre>
123</div>
124 </li>
125
Duncan Sands2ae968a2008-02-12 21:28:39 +0000126 <li><p>Download the
Duncan Sandseadf20d2008-02-12 21:22:58 +0000127 <a href="http://llvm.org/releases/download.html">llvm-gcc-4.2 source</a>
Duncan Sands2ae968a2008-02-12 21:28:39 +0000128 and unpack it:</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000129
130<div class="doc_code">
131<pre>wget http://llvm.org/releases/2.2/llvm-gcc4.2-2.2.source.tar.gz
132tar xzf llvm-gcc4.2-2.2.source.tar.gz
133mv llvm-gcc4.2-2.2.source llvm-gcc-4.2</pre>
134</div>
135
Duncan Sands2ae968a2008-02-12 21:28:39 +0000136 <p>or <a href="http://llvm.org/docs/GettingStarted.html#checkout">check out the
137 latest version from subversion</a>:</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000138
139<div class="doc_code">
140<pre>svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk llvm-gcc-4.2</pre>
141</div>
142 </li>
143
Duncan Sands2ae968a2008-02-12 21:28:39 +0000144 <li><p>Make a build directory <tt>llvm-objects</tt> for llvm and make it the
145 current directory:</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000146
147<div class="doc_code">
148<pre>mkdir llvm-objects
149cd llvm-objects</pre>
150</div>
151 </li>
152
Duncan Sands2ae968a2008-02-12 21:28:39 +0000153 <li><p>Configure LLVM (here it is configured to install into <tt>/usr/local</tt>):</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000154
155<div class="doc_code">
156<pre>../llvm/configure --prefix=/usr/local</pre>
157</div>
158
Duncan Sands2ae968a2008-02-12 21:28:39 +0000159 <p>If you have a multi-compiler setup and the C++ compiler is not the
160 default, then you can configure like this:</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000161
162<div class="doc_code">
163<pre>CXX=<b>PATH_TO_C++_COMPILER</b> ../llvm/configure --prefix=/usr/local</pre>
164</div>
165 </li>
166
Duncan Sands2ae968a2008-02-12 21:28:39 +0000167 <li><p>Build LLVM:</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000168
169<div class="doc_code">
170<pre>make</pre>
171</div>
172 </li>
173
Duncan Sands2ae968a2008-02-12 21:28:39 +0000174 <li><p>Install LLVM (optional):</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000175
176<div class="doc_code">
177<pre>make install</pre>
178</div>
179 </li>
180
Duncan Sands2ae968a2008-02-12 21:28:39 +0000181 <li><p>Make a build directory <tt>llvm-gcc-4.2-objects</tt> for llvm-gcc and make it the
182 current directory:</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000183
184<div class="doc_code">
185<pre>
186cd ..
187mkdir llvm-gcc-4.2-objects
188cd llvm-gcc-4.2-objects</pre>
189</div>
190 </li>
191
Duncan Sands2ae968a2008-02-12 21:28:39 +0000192 <li><p>Configure llvm-gcc (here it is configured to install into <tt>/usr/local</tt>).
Duncan Sandseadf20d2008-02-12 21:22:58 +0000193 Additional languages can be appended to the --enable-languages switch,
Duncan Sands2ae968a2008-02-12 21:28:39 +0000194 for example <tt>--enable-languages=ada,c,c++</tt>.</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000195
196<div class="doc_code">
197<pre>../llvm-gcc-4.2/configure --prefix=/usr/local --enable-languages=ada,c --enable-checking --enable-llvm=$PWD/../llvm-objects --disable-shared --disable-bootstrap --disable-multilib</pre>
198</div>
199
Duncan Sands2ae968a2008-02-12 21:28:39 +0000200 <p>If you have a multi-compiler setup, then you can configure like this:</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000201<div class="doc_code">
202
203<pre>
204export CC=<b>PATH_TO_C_AND_ADA_COMPILER</b>
205export CXX=<b>PATH_TO_C++_COMPILER</b>
206../llvm-gcc-4.2/configure --prefix=/usr/local --enable-languages=ada,c --enable-checking --enable-llvm=$PWD/../llvm-objects --disable-shared --disable-bootstrap --disable-multilib</pre>
207</div>
208 </li>
209
Duncan Sands2ae968a2008-02-12 21:28:39 +0000210 <li><p>Build and install the compiler:</p>
Duncan Sandseadf20d2008-02-12 21:22:58 +0000211
212<div class="doc_code">
213<pre>make
214make install</pre>
215</div>
216 </li>
217</ol>
218
219</div>
220
221<!-- *********************************************************************** -->
222<div class="doc_section">
223 <a name="license">Building the Fortran front-end</a>
224</div>
225
226<div class="doc_text">
227<p>
228To build with support for Fortran, follow the directions in the top-level
229<tt>README.LLVM</tt> file, adding ",fortran" to EXTRALANGS, for example:</p>
230
231<div class="doc_code">
232<pre>
233EXTRALANGS=,fortran
234</pre>
235</div>
236
237</div>
238
Brian Gaeke0142c1e2003-10-21 21:58:38 +0000239<!-- *********************************************************************** -->
John Criswell86a3a482003-12-18 16:43:17 +0000240<div class="doc_section">
241 <a name="license">License Information</a>
242</div>
243
244<div class="doc_text">
245<p>
246The LLVM GCC frontend is licensed to you under the GNU General Public License
247and the GNU Lesser General Public License. Please see the files COPYING and
248COPYING.LIB for more details.
249</p>
250
251<p>
Chris Lattnerfa289942006-07-11 20:47:00 +0000252More information is <a href="FAQ.html#license">available in the FAQ</a>.
John Criswell86a3a482003-12-18 16:43:17 +0000253</p>
John Criswell86a3a482003-12-18 16:43:17 +0000254</div>
255
256<!-- *********************************************************************** -->
Brian Gaeke0142c1e2003-10-21 21:58:38 +0000257
Misha Brukmanb7c3b6d2003-10-28 21:09:29 +0000258<hr>
Misha Brukman4478f2b2004-05-12 18:49:47 +0000259<address>
260 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
261 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
262 <a href="http://validator.w3.org/check/referer"><img
263 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
264
Reid Spencerca058542006-03-14 05:39:39 +0000265 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
Misha Brukmanb7c3b6d2003-10-28 21:09:29 +0000266 Last modified: $Date$
Misha Brukman4478f2b2004-05-12 18:49:47 +0000267</address>
Brian Gaeke0142c1e2003-10-21 21:58:38 +0000268
Misha Brukman0ccf5192003-10-23 01:48:33 +0000269</body>
270</html>