blob: 6eb409b79c278324024a5ca4891199bce0367e52 [file] [log] [blame]
Duncan Sands551d3e62008-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
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +000011<h1>
Duncan Sands551d3e62008-02-14 17:53:22 +000012 Building the LLVM GCC Front-End
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +000013</h1>
Duncan Sands551d3e62008-02-14 17:53:22 +000014
15<ol>
16 <li><a href="#instructions">Building llvm-gcc from Source</a></li>
Misha Brukmanfd609662008-12-29 21:33:30 +000017 <li><a href="#ada">Building the Ada front-end</a></li>
18 <li><a href="#fortran">Building the Fortran front-end</a></li>
Duncan Sands551d3e62008-02-14 17:53:22 +000019 <li><a href="#license">License Information</a></li>
20</ol>
21
22<div class="doc_author">
23 <p>Written by the LLVM Team</p>
24</div>
25
26<!-- *********************************************************************** -->
NAKAMURA Takumi64835132011-04-18 01:17:51 +000027<h2><a name="instructions">Building llvm-gcc from Source</a></h2>
Duncan Sands551d3e62008-02-14 17:53:22 +000028<!-- *********************************************************************** -->
29
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +000030<div>
Duncan Sands551d3e62008-02-14 17:53:22 +000031
Duncan Sands7192a542008-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 Sands551d3e62008-02-14 17:53:22 +000037
38<ol>
Misha Brukman8dab3032008-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 Sands551d3e62008-02-14 17:53:22 +000042
43 <p>It is also possible to download the sources of the llvm-gcc front end
Duncan Sands7192a542008-06-09 20:24:05 +000044 from a read-only mirror using subversion. To check out the 4.2 code
Duncan Sands551d3e62008-02-14 17:53:22 +000045 for first time use:</p>
46
47<div class="doc_code">
48<pre>
Duncan Sands551d3e62008-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<!-- *********************************************************************** -->
NAKAMURA Takumi64835132011-04-18 01:17:51 +000070<h2><a name="ada">Building the Ada front-end</a></h2>
Misha Brukmanfd609662008-12-29 21:33:30 +000071<!-- *********************************************************************** -->
Duncan Sands551d3e62008-02-14 17:53:22 +000072
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +000073<div>
Duncan Sands551d3e62008-02-14 17:53:22 +000074<p>Building with support for Ada amounts to following the directions in the
75top-level <tt>README.LLVM</tt> file, adding ",ada" to EXTRALANGS, for example:
76<tt>EXTRALANGS=,ada</tt></p>
77
78<p>There are some complications however:</p>
79
80<ol>
81 <li><p>The only platform for which the Ada front-end is known to build is
82 32 bit intel x86 running linux. It is unlikely to build for other
83 systems without some work.</p></li>
84 <li><p>The build requires having a compiler that supports Ada, C and C++.
85 The Ada front-end is written in Ada so an Ada compiler is needed to
Duncan Sands21285fc2008-04-11 13:24:43 +000086 build it. Compilers known to work with the
Duncan Sands11c23fc2010-08-31 19:40:21 +000087 <a href="http://llvm.org/releases/download.html">LLVM 2.7 release</a>
Duncan Sands21285fc2008-04-11 13:24:43 +000088 are <a href="http://gcc.gnu.org/releases.html">gcc-4.2</a> and the
Duncan Sands7192a542008-06-09 20:24:05 +000089 2005, 2006 and 2007 versions of the
90 <a href="http://libre.adacore.com/">GNAT GPL Edition</a>.
Duncan Sands78cd3e52009-07-05 12:01:44 +000091 <b>GNAT GPL 2008, gcc-4.3 and later will not work</b>.
Duncan Sands648e5d62008-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 Sands551d3e62008-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 Sands7192a542008-06-09 20:24:05 +000098 <a href="http://libre.adacore.com/">2007 GNAT GPL Edition</a>)
Duncan Sands551d3e62008-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 Sands21285fc2008-04-11 13:24:43 +0000101 compiler with checking enabled. This causes it to run much slower, but
Duncan Sands551d3e62008-02-14 17:53:22 +0000102 helps catch mistakes in the compiler (please report any problems using
NAKAMURA Takumica46f5a2011-04-09 02:13:37 +0000103 <a href="http://llvm.org/bugs/">LLVM bugzilla</a>).</p></li>
Duncan Sands61837e62009-03-24 21:16:39 +0000104 <li><p>The Ada front-end <a href="http://llvm.org/PR2007">fails to
105 bootstrap</a>, due to lack of LLVM support for
106 <tt>setjmp</tt>/<tt>longjmp</tt> style exception handling (used
107 internally by the compiler), so you must specify
108 <tt>--disable-bootstrap</tt>.</p></li>
Duncan Sands551d3e62008-02-14 17:53:22 +0000109</ol>
110
111<p>Supposing appropriate compilers are available, llvm-gcc with Ada support can
112 be built on an x86-32 linux box using the following recipe:</p>
113
114<ol>
115 <li><p>Download the <a href="http://llvm.org/releases/download.html">LLVM source</a>
116 and unpack it:</p>
117
Misha Brukman8dab3032008-12-29 21:20:51 +0000118<pre class="doc_code">
Duncan Sands11c23fc2010-08-31 19:40:21 +0000119wget http://llvm.org/releases/2.7/llvm-2.7.tgz
120tar xzf llvm-2.7.tgz
121mv llvm-2.7 llvm
Misha Brukman8dab3032008-12-29 21:20:51 +0000122</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000123
124 <p>or <a href="GettingStarted.html#checkout">check out the
125 latest version from subversion</a>:</p>
126
Misha Brukman8dab3032008-12-29 21:20:51 +0000127<pre class="doc_code">svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</pre>
128
Duncan Sands551d3e62008-02-14 17:53:22 +0000129 </li>
130
131 <li><p>Download the
132 <a href="http://llvm.org/releases/download.html">llvm-gcc-4.2 source</a>
133 and unpack it:</p>
134
Misha Brukman8dab3032008-12-29 21:20:51 +0000135<pre class="doc_code">
Duncan Sands11c23fc2010-08-31 19:40:21 +0000136wget http://llvm.org/releases/2.7/llvm-gcc-4.2-2.7.source.tgz
137tar xzf llvm-gcc-4.2-2.7.source.tgz
138mv llvm-gcc-4.2-2.7.source llvm-gcc-4.2
Misha Brukman8dab3032008-12-29 21:20:51 +0000139</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000140
141 <p>or <a href="GettingStarted.html#checkout">check out the
142 latest version from subversion</a>:</p>
143
Misha Brukman8dab3032008-12-29 21:20:51 +0000144<pre class="doc_code">
145svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk llvm-gcc-4.2
146</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000147 </li>
148
149 <li><p>Make a build directory <tt>llvm-objects</tt> for llvm and make it the
150 current directory:</p>
151
Misha Brukman8dab3032008-12-29 21:20:51 +0000152<pre class="doc_code">
153mkdir llvm-objects
154cd llvm-objects
155</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000156 </li>
157
158 <li><p>Configure LLVM (here it is configured to install into <tt>/usr/local</tt>):</p>
159
Misha Brukman8dab3032008-12-29 21:20:51 +0000160<pre class="doc_code">
Duncan Sands75bc2252009-04-27 11:21:35 +0000161../llvm/configure --prefix=<b>/usr/local</b> --enable-optimized --enable-assertions
Misha Brukman8dab3032008-12-29 21:20:51 +0000162</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000163
164 <p>If you have a multi-compiler setup and the C++ compiler is not the
165 default, then you can configure like this:</p>
166
Misha Brukman8dab3032008-12-29 21:20:51 +0000167<pre class="doc_code">
Duncan Sands75bc2252009-04-27 11:21:35 +0000168CXX=<b>PATH_TO_C++_COMPILER</b> ../llvm/configure --prefix=<b>/usr/local</b> --enable-optimized --enable-assertions
Misha Brukman8dab3032008-12-29 21:20:51 +0000169</pre>
Duncan Sands75bc2252009-04-27 11:21:35 +0000170
171 <p>To compile without checking (not recommended), replace
172 <tt>--enable-assertions</tt> with <tt>--disable-assertions</tt>.</p>
173
Duncan Sands551d3e62008-02-14 17:53:22 +0000174 </li>
175
Duncan Sands75bc2252009-04-27 11:21:35 +0000176 <li><p>Build LLVM:</p>
Duncan Sands551d3e62008-02-14 17:53:22 +0000177
Misha Brukman8dab3032008-12-29 21:20:51 +0000178<pre class="doc_code">
Duncan Sands75bc2252009-04-27 11:21:35 +0000179make
Misha Brukman8dab3032008-12-29 21:20:51 +0000180</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000181 </li>
182
183 <li><p>Install LLVM (optional):</p>
184
Misha Brukman8dab3032008-12-29 21:20:51 +0000185<pre class="doc_code">
Duncan Sands75bc2252009-04-27 11:21:35 +0000186make install
Misha Brukman8dab3032008-12-29 21:20:51 +0000187</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000188 </li>
189
190 <li><p>Make a build directory <tt>llvm-gcc-4.2-objects</tt> for llvm-gcc and make it the
191 current directory:</p>
192
Misha Brukman8dab3032008-12-29 21:20:51 +0000193<pre class="doc_code">
Duncan Sands551d3e62008-02-14 17:53:22 +0000194cd ..
195mkdir llvm-gcc-4.2-objects
Misha Brukman8dab3032008-12-29 21:20:51 +0000196cd llvm-gcc-4.2-objects
197</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000198 </li>
199
200 <li><p>Configure llvm-gcc (here it is configured to install into <tt>/usr/local</tt>).
201 The <tt>--enable-checking</tt> flag turns on sanity checks inside the compiler.
Duncan Sands75bc2252009-04-27 11:21:35 +0000202 To turn off these checks (not recommended), replace <tt>--enable-checking</tt>
203 with <tt>--disable-checking</tt>.
Misha Brukmanb5362352009-01-03 02:35:05 +0000204 Additional languages can be appended to the <tt>--enable-languages</tt> switch,
Duncan Sands551d3e62008-02-14 17:53:22 +0000205 for example <tt>--enable-languages=ada,c,c++</tt>.</p>
206
Misha Brukman8dab3032008-12-29 21:20:51 +0000207<pre class="doc_code">
Misha Brukmanb5362352009-01-03 02:35:05 +0000208../llvm-gcc-4.2/configure --prefix=<b>/usr/local</b> --enable-languages=ada,c \
209 --enable-checking --enable-llvm=$PWD/../llvm-objects \
210 --disable-bootstrap --disable-multilib
Misha Brukman8dab3032008-12-29 21:20:51 +0000211</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000212
213 <p>If you have a multi-compiler setup, then you can configure like this:</p>
Duncan Sands551d3e62008-02-14 17:53:22 +0000214
Misha Brukman8dab3032008-12-29 21:20:51 +0000215<pre class="doc_code">
Duncan Sands551d3e62008-02-14 17:53:22 +0000216export CC=<b>PATH_TO_C_AND_ADA_COMPILER</b>
217export CXX=<b>PATH_TO_C++_COMPILER</b>
Misha Brukmanb5362352009-01-03 02:35:05 +0000218../llvm-gcc-4.2/configure --prefix=<b>/usr/local</b> --enable-languages=ada,c \
219 --enable-checking --enable-llvm=$PWD/../llvm-objects \
220 --disable-bootstrap --disable-multilib
Misha Brukman8dab3032008-12-29 21:20:51 +0000221</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000222 </li>
223
224 <li><p>Build and install the compiler:</p>
225
Misha Brukman8dab3032008-12-29 21:20:51 +0000226<pre class="doc_code">
227make
228make install
229</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000230 </li>
231</ol>
232
233</div>
234
235<!-- *********************************************************************** -->
NAKAMURA Takumi64835132011-04-18 01:17:51 +0000236<h2><a name="fortran">Building the Fortran front-end</a></h2>
Misha Brukmanfd609662008-12-29 21:33:30 +0000237<!-- *********************************************************************** -->
Duncan Sands551d3e62008-02-14 17:53:22 +0000238
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000239<div>
Misha Brukmanfd609662008-12-29 21:33:30 +0000240<p>To build with support for Fortran, follow the directions in the top-level
Duncan Sands551d3e62008-02-14 17:53:22 +0000241<tt>README.LLVM</tt> file, adding ",fortran" to EXTRALANGS, for example:</p>
242
Misha Brukman8dab3032008-12-29 21:20:51 +0000243<pre class="doc_code">
Duncan Sands551d3e62008-02-14 17:53:22 +0000244EXTRALANGS=,fortran
245</pre>
Duncan Sands551d3e62008-02-14 17:53:22 +0000246
247</div>
248
249<!-- *********************************************************************** -->
NAKAMURA Takumi64835132011-04-18 01:17:51 +0000250<h2><a name="license">License Information</a></h2>
Misha Brukmanfd609662008-12-29 21:33:30 +0000251<!-- *********************************************************************** -->
Duncan Sands551d3e62008-02-14 17:53:22 +0000252
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000253<div>
Duncan Sands551d3e62008-02-14 17:53:22 +0000254<p>
255The LLVM GCC frontend is licensed to you under the GNU General Public License
256and the GNU Lesser General Public License. Please see the files COPYING and
257COPYING.LIB for more details.
258</p>
259
260<p>
261More information is <a href="FAQ.html#license">available in the FAQ</a>.
262</p>
263</div>
264
265<!-- *********************************************************************** -->
266
267<hr>
268<address>
269 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
Misha Brukman86242e12008-12-11 17:34:48 +0000270 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
Duncan Sands551d3e62008-02-14 17:53:22 +0000271 <a href="http://validator.w3.org/check/referer"><img
Misha Brukman86242e12008-12-11 17:34:48 +0000272 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
Duncan Sands551d3e62008-02-14 17:53:22 +0000273
NAKAMURA Takumica46f5a2011-04-09 02:13:37 +0000274 <a href="http://llvm.org/">LLVM Compiler Infrastructure</a><br>
Duncan Sands551d3e62008-02-14 17:53:22 +0000275 Last modified: $Date$
276</address>
277
278</body>
279</html>