blob: c9534095b66b35d5231f63efcc96709842e0b8be [file] [log] [blame]
Misha Brukman6a2b3102004-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 Brukman83bd33a2003-10-23 01:48:33 +00003<html>
4<head>
Misha Brukman6a2b3102004-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 Lattnerad85ba42007-02-14 07:42:12 +00007 <title>Building the LLVM C/C++ Front-End</title>
Misha Brukman83bd33a2003-10-23 01:48:33 +00008</head>
9<body>
Brian Gaeke46079d22003-10-21 21:58:38 +000010
Misha Brukman83bd33a2003-10-23 01:48:33 +000011<div class="doc_title">
Duncan Sandsd051f7a2008-02-12 21:22:58 +000012 Building the LLVM GCC Front-End
Misha Brukman83bd33a2003-10-23 01:48:33 +000013</div>
Brian Gaeke46079d22003-10-21 21:58:38 +000014
Brian Gaeke7af03e92003-11-12 20:47:30 +000015<ol>
Duncan Sandsd051f7a2008-02-12 21:22:58 +000016 <li><a href="#instructions">Building llvm-gcc from Source</a></li>
Chris Lattner6a615ad2004-06-01 18:13:05 +000017 <li><a href="#license">License Information</a></li>
Brian Gaeke7af03e92003-11-12 20:47:30 +000018</ol>
19
Chris Lattner7911ce22004-05-23 21:07:27 +000020<div class="doc_author">
Chris Lattnerad85ba42007-02-14 07:42:12 +000021 <p>Written by the LLVM Team</p>
Brian Gaeke7af03e92003-11-12 20:47:30 +000022</div>
23
24<!-- *********************************************************************** -->
25<div class="doc_section">
Duncan Sandsd051f7a2008-02-12 21:22:58 +000026 <a name="instructions">Building llvm-gcc from Source</a>
Misha Brukman83bd33a2003-10-23 01:48:33 +000027</div>
28<!-- *********************************************************************** -->
29
30<div class="doc_text">
Chris Lattner810ad8c2006-07-11 20:47:00 +000031
Duncan Sandsd051f7a2008-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 Lattnerad85ba42007-02-14 07:42:12 +000037the past.</p>
Chris Lattner810ad8c2006-07-11 20:47:00 +000038
Brian Gaeke46079d22003-10-21 21:58:38 +000039<ol>
Duncan Sandsd051f7a2008-02-12 21:22:58 +000040 <li><p>Retrieve the appropriate llvm-gcc4.x-y.z.source.tar.gz archive from the
Chris Lattnerad85ba42007-02-14 07:42:12 +000041 <a href="http://llvm.org/releases/">llvm web site</a>.</p>
Jim Laskeye9493d32006-06-16 23:34:49 +000042
Duncan Sandsd051f7a2008-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 Laskeye9493d32006-06-16 23:34:49 +000046
Bill Wendling0ca558f2006-11-16 09:31:19 +000047<div class="doc_code">
48<pre>
Bill Wendling0dafa8d2007-07-23 03:56:42 +000049svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.0/trunk <i>dst-directory</i>
Bill Wendling0ca558f2006-11-16 09:31:19 +000050</pre>
51</div>
Jim Laskeye9493d32006-06-16 23:34:49 +000052
Duncan Sandsd051f7a2008-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 Wendling0ca558f2006-11-16 09:31:19 +000061 <p>After that, the code can be be updated in the destination directory
62 using:</p>
Jim Laskeye9493d32006-06-16 23:34:49 +000063
Bill Wendling0ca558f2006-11-16 09:31:19 +000064<div class="doc_code">
65<pre>svn update</pre>
66</div>
Chris Lattner810ad8c2006-07-11 20:47:00 +000067
Bill Wendling0ca558f2006-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 Sandsd051f7a2008-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 Lattner810ad8c2006-07-11 20:47:00 +000073</ol>
Bill Wendling0ca558f2006-11-16 09:31:19 +000074
Chris Lattner810ad8c2006-07-11 20:47:00 +000075</div>
Duncan Sandsd051f7a2008-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 Sands15bfd892008-02-12 21:28:39 +000090 <li><p>The only platform for which the Ada front-end is known to build is
Duncan Sandsd051f7a2008-02-12 21:22:58 +000091 32 bit intel x86 running linux. It is unlikely to build for other
Duncan Sands15bfd892008-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 Sandsd051f7a2008-02-12 21:22:58 +000094 The Ada front-end is written in Ada so an Ada compiler is needed to
Duncan Sands20dcb4c2008-02-13 16:46:10 +000095 build it. What is more, the Ada compiler must not be more recent
96 than what it is trying to compile, otherwise the build will fail.
97 This rules out gcc-4.3 (but not gcc-4.2) and also the
98 <a href="http://libre.adacore.com/">2007 GNAT GPL Edition</a>.
99 The LLVM parts of llvm-gcc are written in C++ so a C++
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000100 compiler is needed to build them. The rest of gcc is written in C.
101 Some linux distributions provide a version of gcc that supports all
102 three languages (the Ada part often comes as an add-on package to
103 the rest of gcc). Otherwise it is possible to combine two versions
Duncan Sands20dcb4c2008-02-13 16:46:10 +0000104 of gcc, one that supports Ada and C (such as the
105 <a href="http://libre.adacore.com/">2006 GNAT GPL Edition</a>)
106 and another which supports C++, see below.</p></li>
107 <li><p>Because the Ada front-end is experimental, it is wise to build the
108 compiler with checking enabled. This causes it to run slower, but
109 helps catch mistakes in the compiler (please report any problems using
110 <a href="http://llvm.org/bugs">LLVM bugzilla</a>).</p></li>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000111</ol>
112
113<p>Supposing appropriate compilers are available, llvm-gcc with Ada support can
Duncan Sandscaf4fbd2008-02-12 21:40:21 +0000114 be built on an x86-32 linux box using the following recipe:</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000115
116<ol>
Duncan Sands15bfd892008-02-12 21:28:39 +0000117 <li><p>Download the <a href="http://llvm.org/releases/download.html">LLVM source</a>
118 and unpack it:</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000119
120<div class="doc_code">
121<pre>wget http://llvm.org/releases/2.2/llvm-2.2.tar.gz
122tar xzf llvm-2.2.tar.gz
123mv llvm-2.2 llvm</pre>
124</div>
125
Duncan Sands15bfd892008-02-12 21:28:39 +0000126 <p>or <a href="http://llvm.org/docs/GettingStarted.html#checkout">check out the
127 latest version from subversion</a>:</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000128
129<div class="doc_code">
130<pre>svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</pre>
131</div>
132 </li>
133
Duncan Sands15bfd892008-02-12 21:28:39 +0000134 <li><p>Download the
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000135 <a href="http://llvm.org/releases/download.html">llvm-gcc-4.2 source</a>
Duncan Sands15bfd892008-02-12 21:28:39 +0000136 and unpack it:</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000137
138<div class="doc_code">
139<pre>wget http://llvm.org/releases/2.2/llvm-gcc4.2-2.2.source.tar.gz
140tar xzf llvm-gcc4.2-2.2.source.tar.gz
141mv llvm-gcc4.2-2.2.source llvm-gcc-4.2</pre>
142</div>
143
Duncan Sands15bfd892008-02-12 21:28:39 +0000144 <p>or <a href="http://llvm.org/docs/GettingStarted.html#checkout">check out the
145 latest version from subversion</a>:</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000146
147<div class="doc_code">
148<pre>svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk llvm-gcc-4.2</pre>
149</div>
150 </li>
151
Duncan Sands15bfd892008-02-12 21:28:39 +0000152 <li><p>Make a build directory <tt>llvm-objects</tt> for llvm and make it the
153 current directory:</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000154
155<div class="doc_code">
156<pre>mkdir llvm-objects
157cd llvm-objects</pre>
158</div>
159 </li>
160
Duncan Sands15bfd892008-02-12 21:28:39 +0000161 <li><p>Configure LLVM (here it is configured to install into <tt>/usr/local</tt>):</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000162
163<div class="doc_code">
Duncan Sands20dcb4c2008-02-13 16:46:10 +0000164<pre>../llvm/configure --prefix=<b>/usr/local</b></pre>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000165</div>
166
Duncan Sands15bfd892008-02-12 21:28:39 +0000167 <p>If you have a multi-compiler setup and the C++ compiler is not the
168 default, then you can configure like this:</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000169
170<div class="doc_code">
Duncan Sands20dcb4c2008-02-13 16:46:10 +0000171<pre>CXX=<b>PATH_TO_C++_COMPILER</b> ../llvm/configure --prefix=<b>/usr/local</b></pre>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000172</div>
173 </li>
174
Duncan Sands20dcb4c2008-02-13 16:46:10 +0000175 <li><p>Build LLVM with checking enabled (use <tt>ENABLE_OPTIMIZED=1</tt> to
176 build without checking):</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000177
178<div class="doc_code">
Duncan Sands20dcb4c2008-02-13 16:46:10 +0000179<pre>make ENABLE_OPTIMIZED=0</pre>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000180</div>
181 </li>
182
Duncan Sands15bfd892008-02-12 21:28:39 +0000183 <li><p>Install LLVM (optional):</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000184
185<div class="doc_code">
186<pre>make install</pre>
187</div>
188 </li>
189
Duncan Sands15bfd892008-02-12 21:28:39 +0000190 <li><p>Make a build directory <tt>llvm-gcc-4.2-objects</tt> for llvm-gcc and make it the
191 current directory:</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000192
193<div class="doc_code">
194<pre>
195cd ..
196mkdir llvm-gcc-4.2-objects
197cd llvm-gcc-4.2-objects</pre>
198</div>
199 </li>
200
Duncan Sands15bfd892008-02-12 21:28:39 +0000201 <li><p>Configure llvm-gcc (here it is configured to install into <tt>/usr/local</tt>).
Duncan Sands20dcb4c2008-02-13 16:46:10 +0000202 The <tt>--enable-checking</tt> flag turns on sanity checks inside the compiler.
203 If you omit it then LLVM must be built with <tt>make ENABLE_OPTIMIZED=1</tt>.
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000204 Additional languages can be appended to the --enable-languages switch,
Duncan Sands15bfd892008-02-12 21:28:39 +0000205 for example <tt>--enable-languages=ada,c,c++</tt>.</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000206
207<div class="doc_code">
Duncan Sands20dcb4c2008-02-13 16:46:10 +0000208<pre>../llvm-gcc-4.2/configure --prefix=<b>/usr/local</b> --enable-languages=ada,c --enable-checking --enable-llvm=$PWD/../llvm-objects --disable-shared --disable-bootstrap --disable-multilib</pre>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000209</div>
210
Duncan Sands15bfd892008-02-12 21:28:39 +0000211 <p>If you have a multi-compiler setup, then you can configure like this:</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000212<div class="doc_code">
213
214<pre>
215export CC=<b>PATH_TO_C_AND_ADA_COMPILER</b>
216export CXX=<b>PATH_TO_C++_COMPILER</b>
Duncan Sands20dcb4c2008-02-13 16:46:10 +0000217../llvm-gcc-4.2/configure --prefix=<b>/usr/local</b> --enable-languages=ada,c --enable-checking --enable-llvm=$PWD/../llvm-objects --disable-shared --disable-bootstrap --disable-multilib</pre>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000218</div>
219 </li>
220
Duncan Sands15bfd892008-02-12 21:28:39 +0000221 <li><p>Build and install the compiler:</p>
Duncan Sandsd051f7a2008-02-12 21:22:58 +0000222
223<div class="doc_code">
224<pre>make
225make install</pre>
226</div>
227 </li>
228</ol>
229
230</div>
231
232<!-- *********************************************************************** -->
233<div class="doc_section">
234 <a name="license">Building the Fortran front-end</a>
235</div>
236
237<div class="doc_text">
238<p>
239To build with support for Fortran, follow the directions in the top-level
240<tt>README.LLVM</tt> file, adding ",fortran" to EXTRALANGS, for example:</p>
241
242<div class="doc_code">
243<pre>
244EXTRALANGS=,fortran
245</pre>
246</div>
247
248</div>
249
Brian Gaeke46079d22003-10-21 21:58:38 +0000250<!-- *********************************************************************** -->
John Criswelld000e1d2003-12-18 16:43:17 +0000251<div class="doc_section">
252 <a name="license">License Information</a>
253</div>
254
255<div class="doc_text">
256<p>
257The LLVM GCC frontend is licensed to you under the GNU General Public License
258and the GNU Lesser General Public License. Please see the files COPYING and
259COPYING.LIB for more details.
260</p>
261
262<p>
Chris Lattner810ad8c2006-07-11 20:47:00 +0000263More information is <a href="FAQ.html#license">available in the FAQ</a>.
John Criswelld000e1d2003-12-18 16:43:17 +0000264</p>
John Criswelld000e1d2003-12-18 16:43:17 +0000265</div>
266
267<!-- *********************************************************************** -->
Brian Gaeke46079d22003-10-21 21:58:38 +0000268
Misha Brukmanb9e57892003-10-28 21:09:29 +0000269<hr>
Misha Brukman6a2b3102004-05-12 18:49:47 +0000270<address>
271 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
272 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
273 <a href="http://validator.w3.org/check/referer"><img
274 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
275
Reid Spencer05fe4b02006-03-14 05:39:39 +0000276 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
Misha Brukmanb9e57892003-10-28 21:09:29 +0000277 Last modified: $Date$
Misha Brukman6a2b3102004-05-12 18:49:47 +0000278</address>
Brian Gaeke46079d22003-10-21 21:58:38 +0000279
Misha Brukman83bd33a2003-10-23 01:48:33 +0000280</body>
281</html>