blob: cc0d584cecba712065b6298e7c53c55b9b1324b2 [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>
Misha Brukman8722a2c2008-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 Sands8655b152008-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<!-- *********************************************************************** -->
Misha Brukman8722a2c2008-12-29 21:33:30 +000027<h1><a name="instructions">Building llvm-gcc from Source</a></h1>
Duncan Sands8655b152008-02-14 17:53:22 +000028<!-- *********************************************************************** -->
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<!-- *********************************************************************** -->
Misha Brukman8722a2c2008-12-29 21:33:30 +000070<h1><a name="ada">Building the Ada front-end</a></h1>
71<!-- *********************************************************************** -->
Duncan Sands8655b152008-02-14 17:53:22 +000072
73<div class="doc_text">
74<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 Sandsd918b7e2008-04-11 13:24:43 +000086 build it. Compilers known to work with the
Duncan Sandsd9c9bf72009-03-13 13:42:20 +000087 <a href="http://llvm.org/releases/download.html">LLVM 2.5 release</a>
Duncan Sandsd918b7e2008-04-11 13:24:43 +000088 are <a href="http://gcc.gnu.org/releases.html">gcc-4.2</a> and the
Duncan Sands98301c02008-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 Sands17bcde92008-02-16 09:47:41 +000091 The LLVM parts of llvm-gcc are written in C++ so a C++ compiler is
92 needed to build them. The rest of gcc is written in C.
Duncan Sands8655b152008-02-14 17:53:22 +000093 Some linux distributions provide a version of gcc that supports all
94 three languages (the Ada part often comes as an add-on package to
95 the rest of gcc). Otherwise it is possible to combine two versions
96 of gcc, one that supports Ada and C (such as the
Duncan Sands98301c02008-06-09 20:24:05 +000097 <a href="http://libre.adacore.com/">2007 GNAT GPL Edition</a>)
Duncan Sands8655b152008-02-14 17:53:22 +000098 and another which supports C++, see below.</p></li>
99 <li><p>Because the Ada front-end is experimental, it is wise to build the
Duncan Sandsd918b7e2008-04-11 13:24:43 +0000100 compiler with checking enabled. This causes it to run much slower, but
Duncan Sands8655b152008-02-14 17:53:22 +0000101 helps catch mistakes in the compiler (please report any problems using
102 <a href="http://llvm.org/bugs">LLVM bugzilla</a>).</p></li>
Duncan Sandsabc061c2009-03-24 21:16:39 +0000103 <li><p>The Ada front-end <a href="http://llvm.org/PR2007">fails to
104 bootstrap</a>, due to lack of LLVM support for
105 <tt>setjmp</tt>/<tt>longjmp</tt> style exception handling (used
106 internally by the compiler), so you must specify
107 <tt>--disable-bootstrap</tt>.</p></li>
Duncan Sands8655b152008-02-14 17:53:22 +0000108</ol>
109
110<p>Supposing appropriate compilers are available, llvm-gcc with Ada support can
111 be built on an x86-32 linux box using the following recipe:</p>
112
113<ol>
114 <li><p>Download the <a href="http://llvm.org/releases/download.html">LLVM source</a>
115 and unpack it:</p>
116
Misha Brukman0427f7a2008-12-29 21:20:51 +0000117<pre class="doc_code">
Duncan Sandsd9c9bf72009-03-13 13:42:20 +0000118wget http://llvm.org/releases/2.5/llvm-2.5.tar.gz
119tar xzf llvm-2.5.tar.gz
120mv llvm-2.5 llvm
Misha Brukman0427f7a2008-12-29 21:20:51 +0000121</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000122
123 <p>or <a href="GettingStarted.html#checkout">check out the
124 latest version from subversion</a>:</p>
125
Misha Brukman0427f7a2008-12-29 21:20:51 +0000126<pre class="doc_code">svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</pre>
127
Duncan Sands8655b152008-02-14 17:53:22 +0000128 </li>
129
130 <li><p>Download the
131 <a href="http://llvm.org/releases/download.html">llvm-gcc-4.2 source</a>
132 and unpack it:</p>
133
Misha Brukman0427f7a2008-12-29 21:20:51 +0000134<pre class="doc_code">
Duncan Sandsd9c9bf72009-03-13 13:42:20 +0000135wget http://llvm.org/releases/2.5/llvm-gcc-4.2-2.5.source.tar.gz
136tar xzf llvm-gcc-4.2-2.5.source.tar.gz
137mv llvm-gcc4.2-2.5.source llvm-gcc-4.2
Misha Brukman0427f7a2008-12-29 21:20:51 +0000138</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000139
140 <p>or <a href="GettingStarted.html#checkout">check out the
141 latest version from subversion</a>:</p>
142
Misha Brukman0427f7a2008-12-29 21:20:51 +0000143<pre class="doc_code">
144svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk llvm-gcc-4.2
145</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000146 </li>
147
148 <li><p>Make a build directory <tt>llvm-objects</tt> for llvm and make it the
149 current directory:</p>
150
Misha Brukman0427f7a2008-12-29 21:20:51 +0000151<pre class="doc_code">
152mkdir llvm-objects
153cd llvm-objects
154</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000155 </li>
156
157 <li><p>Configure LLVM (here it is configured to install into <tt>/usr/local</tt>):</p>
158
Misha Brukman0427f7a2008-12-29 21:20:51 +0000159<pre class="doc_code">
160../llvm/configure --prefix=<b>/usr/local</b>
161</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000162
163 <p>If you have a multi-compiler setup and the C++ compiler is not the
164 default, then you can configure like this:</p>
165
Misha Brukman0427f7a2008-12-29 21:20:51 +0000166<pre class="doc_code">
167CXX=<b>PATH_TO_C++_COMPILER</b> ../llvm/configure --prefix=<b>/usr/local</b>
168</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000169 </li>
170
171 <li><p>Build LLVM with checking enabled (use <tt>ENABLE_OPTIMIZED=1</tt> to
172 build without checking):</p>
173
Misha Brukman0427f7a2008-12-29 21:20:51 +0000174<pre class="doc_code">
175make ENABLE_OPTIMIZED=0
176</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000177 </li>
178
179 <li><p>Install LLVM (optional):</p>
180
Misha Brukman0427f7a2008-12-29 21:20:51 +0000181<pre class="doc_code">
182make ENABLE_OPTIMIZED=0 install
183</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000184 </li>
185
186 <li><p>Make a build directory <tt>llvm-gcc-4.2-objects</tt> for llvm-gcc and make it the
187 current directory:</p>
188
Misha Brukman0427f7a2008-12-29 21:20:51 +0000189<pre class="doc_code">
Duncan Sands8655b152008-02-14 17:53:22 +0000190cd ..
191mkdir llvm-gcc-4.2-objects
Misha Brukman0427f7a2008-12-29 21:20:51 +0000192cd llvm-gcc-4.2-objects
193</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000194 </li>
195
196 <li><p>Configure llvm-gcc (here it is configured to install into <tt>/usr/local</tt>).
197 The <tt>--enable-checking</tt> flag turns on sanity checks inside the compiler.
Duncan Sands98301c02008-06-09 20:24:05 +0000198 If you omit it then LLVM should be built with <tt>make ENABLE_OPTIMIZED=1</tt>.
Misha Brukmanb0fa4302009-01-03 02:35:05 +0000199 Additional languages can be appended to the <tt>--enable-languages</tt> switch,
Duncan Sands8655b152008-02-14 17:53:22 +0000200 for example <tt>--enable-languages=ada,c,c++</tt>.</p>
201
Misha Brukman0427f7a2008-12-29 21:20:51 +0000202<pre class="doc_code">
Misha Brukmanb0fa4302009-01-03 02:35:05 +0000203../llvm-gcc-4.2/configure --prefix=<b>/usr/local</b> --enable-languages=ada,c \
204 --enable-checking --enable-llvm=$PWD/../llvm-objects \
205 --disable-bootstrap --disable-multilib
Misha Brukman0427f7a2008-12-29 21:20:51 +0000206</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000207
208 <p>If you have a multi-compiler setup, then you can configure like this:</p>
Duncan Sands8655b152008-02-14 17:53:22 +0000209
Misha Brukman0427f7a2008-12-29 21:20:51 +0000210<pre class="doc_code">
Duncan Sands8655b152008-02-14 17:53:22 +0000211export CC=<b>PATH_TO_C_AND_ADA_COMPILER</b>
212export CXX=<b>PATH_TO_C++_COMPILER</b>
Misha Brukmanb0fa4302009-01-03 02:35:05 +0000213../llvm-gcc-4.2/configure --prefix=<b>/usr/local</b> --enable-languages=ada,c \
214 --enable-checking --enable-llvm=$PWD/../llvm-objects \
215 --disable-bootstrap --disable-multilib
Misha Brukman0427f7a2008-12-29 21:20:51 +0000216</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000217 </li>
218
219 <li><p>Build and install the compiler:</p>
220
Misha Brukman0427f7a2008-12-29 21:20:51 +0000221<pre class="doc_code">
222make
223make install
224</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000225 </li>
226</ol>
227
228</div>
229
230<!-- *********************************************************************** -->
Misha Brukman8722a2c2008-12-29 21:33:30 +0000231<h1><a name="fortran">Building the Fortran front-end</a></h1>
232<!-- *********************************************************************** -->
Duncan Sands8655b152008-02-14 17:53:22 +0000233
234<div class="doc_text">
Misha Brukman8722a2c2008-12-29 21:33:30 +0000235<p>To build with support for Fortran, follow the directions in the top-level
Duncan Sands8655b152008-02-14 17:53:22 +0000236<tt>README.LLVM</tt> file, adding ",fortran" to EXTRALANGS, for example:</p>
237
Misha Brukman0427f7a2008-12-29 21:20:51 +0000238<pre class="doc_code">
Duncan Sands8655b152008-02-14 17:53:22 +0000239EXTRALANGS=,fortran
240</pre>
Duncan Sands8655b152008-02-14 17:53:22 +0000241
242</div>
243
244<!-- *********************************************************************** -->
Misha Brukman8722a2c2008-12-29 21:33:30 +0000245<h1><a name="license">License Information</a></h1>
246<!-- *********************************************************************** -->
Duncan Sands8655b152008-02-14 17:53:22 +0000247
248<div class="doc_text">
249<p>
250The LLVM GCC frontend is licensed to you under the GNU General Public License
251and the GNU Lesser General Public License. Please see the files COPYING and
252COPYING.LIB for more details.
253</p>
254
255<p>
256More information is <a href="FAQ.html#license">available in the FAQ</a>.
257</p>
258</div>
259
260<!-- *********************************************************************** -->
261
262<hr>
263<address>
264 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +0000265 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
Duncan Sands8655b152008-02-14 17:53:22 +0000266 <a href="http://validator.w3.org/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +0000267 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
Duncan Sands8655b152008-02-14 17:53:22 +0000268
269 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
270 Last modified: $Date$
271</address>
272
273</body>
274</html>