Update the build instructions.
[oota-llvm.git] / docs / GCCFEBuildInstrs.html
1 <!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
32 <p>This section describes how to acquire and build llvm-gcc 4.2, which is based
33 on the GCC 4.2.1 front-end.  Supported languages are Ada, C, C++, Fortran,
34 Objective-C and Objective-C++.  Note that the instructions for building these
35 front-ends are completely different (and much easier!) than those for building
36 llvm-gcc3 in the past.</p>
37
38 <ol>
39   <li><p>Retrieve the appropriate llvm-gcc-4.2-x.y.source.tar.gz archive from the
40          <a href="http://llvm.org/releases/">llvm web site</a>.</p>
41
42       <p>It is also possible to download the sources of the llvm-gcc front end
43          from a read-only mirror using subversion.  To check out the 4.2 code
44          for first time use:</p>
45
46 <div class="doc_code">
47 <pre>
48 svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk <i>dst-directory</i>
49 </pre>
50 </div>
51
52       <p>After that, the code can be be updated in the destination directory
53          using:</p>
54
55 <div class="doc_code">
56 <pre>svn update</pre>
57 </div>
58
59       <p>The mirror is brought up to date every evening.</p></li>
60
61   <li>Follow the directions in the top-level <tt>README.LLVM</tt> file for
62       up-to-date instructions on how to build llvm-gcc.  See below for building
63       with support for Ada or Fortran.
64 </ol>
65
66 </div>
67
68 <!-- *********************************************************************** -->
69 <div class="doc_section">
70   <a name="license">Building the Ada front-end</a>
71 </div>
72
73 <div class="doc_text">
74 <p>Building with support for Ada amounts to following the directions in the
75 top-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
86       build it.  Compilers known to work with the
87       <a href="http://llvm.org/releases/download.html">LLVM 2.3 release</a>
88       are <a href="http://gcc.gnu.org/releases.html">gcc-4.2</a> and the
89       2005, 2006 and 2007 versions of the
90       <a href="http://libre.adacore.com/">GNAT GPL Edition</a>.
91       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.
93       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
97       <a href="http://libre.adacore.com/">2007 GNAT GPL Edition</a>)
98       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
100       compiler with checking enabled.  This causes it to run much slower, but
101       helps catch mistakes in the compiler (please report any problems using
102       <a href="http://llvm.org/bugs">LLVM bugzilla</a>).</p></li>
103 </ol>
104
105 <p>Supposing appropriate compilers are available, llvm-gcc with Ada support can
106    be built on an x86-32 linux box using the following recipe:</p>
107
108 <ol>
109   <li><p>Download the <a href="http://llvm.org/releases/download.html">LLVM source</a>
110       and unpack it:</p>
111
112 <div class="doc_code">
113 <pre>wget http://llvm.org/releases/2.3/llvm-2.3.tar.gz
114 tar xzf llvm-2.3.tar.gz
115 mv llvm-2.3 llvm</pre>
116 </div>
117
118       <p>or <a href="GettingStarted.html#checkout">check out the
119       latest version from subversion</a>:</p>
120
121 <div class="doc_code">
122 <pre>svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</pre>
123 </div>
124       </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
130 <div class="doc_code">
131 <pre>wget http://llvm.org/releases/2.3/llvm-gcc-4.2-2.3.source.tar.gz
132 tar xzf llvm-gcc-4.2-2.3.source.tar.gz
133 mv llvm-gcc4.2-2.3.source llvm-gcc-4.2</pre>
134 </div>
135
136       <p>or <a href="GettingStarted.html#checkout">check out the
137       latest version from subversion</a>:</p>
138
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
144   <li><p>Make a build directory <tt>llvm-objects</tt> for llvm and make it the
145       current directory:</p>
146
147 <div class="doc_code">
148 <pre>mkdir llvm-objects
149 cd llvm-objects</pre>
150 </div>
151       </li>
152
153   <li><p>Configure LLVM (here it is configured to install into <tt>/usr/local</tt>):</p>
154
155 <div class="doc_code">
156 <pre>../llvm/configure --prefix=<b>/usr/local</b></pre>
157 </div>
158
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
162 <div class="doc_code">
163 <pre>CXX=<b>PATH_TO_C++_COMPILER</b> ../llvm/configure --prefix=<b>/usr/local</b></pre>
164 </div>
165       </li>
166
167   <li><p>Build LLVM with checking enabled (use <tt>ENABLE_OPTIMIZED=1</tt> to
168          build without checking):</p>
169
170 <div class="doc_code">
171 <pre>make ENABLE_OPTIMIZED=0</pre>
172 </div>
173       </li>
174
175   <li><p>Install LLVM (optional):</p>
176
177 <div class="doc_code">
178 <pre>make ENABLE_OPTIMIZED=0 install</pre>
179 </div>
180       </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
185 <div class="doc_code">
186 <pre>
187 cd ..
188 mkdir llvm-gcc-4.2-objects
189 cd llvm-gcc-4.2-objects</pre>
190 </div>
191       </li>
192
193   <li><p>Configure llvm-gcc (here it is configured to install into <tt>/usr/local</tt>).
194       The <tt>--enable-checking</tt> flag turns on sanity checks inside the compiler.
195       If you omit it then LLVM should be built with <tt>make ENABLE_OPTIMIZED=1</tt>.
196       Additional languages can be appended to the --enable-languages switch,
197       for example <tt>--enable-languages=ada,c,c++</tt>.</p>
198
199 <div class="doc_code">
200 <pre>../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</pre>
201 </div>
202
203       <p>If you have a multi-compiler setup, then you can configure like this:</p>
204 <div class="doc_code">
205
206 <pre>
207 export CC=<b>PATH_TO_C_AND_ADA_COMPILER</b>
208 export CXX=<b>PATH_TO_C++_COMPILER</b>
209 ../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</pre>
210 </div>
211       </li>
212
213   <li><p>Build and install the compiler:</p>
214
215 <div class="doc_code">
216 <pre>make
217 make install</pre>
218 </div>
219       </li>
220 </ol>
221
222 </div>
223
224 <!-- *********************************************************************** -->
225 <div class="doc_section">
226   <a name="license">Building the Fortran front-end</a>
227 </div>
228
229 <div class="doc_text">
230 <p>
231 To build with support for Fortran, follow the directions in the top-level
232 <tt>README.LLVM</tt> file, adding ",fortran" to EXTRALANGS, for example:</p>
233
234 <div class="doc_code">
235 <pre>
236 EXTRALANGS=,fortran
237 </pre>
238 </div>
239
240 </div>
241
242 <!-- *********************************************************************** -->
243 <div class="doc_section">
244   <a name="license">License Information</a>
245 </div>
246
247 <div class="doc_text">
248 <p>
249 The LLVM GCC frontend is licensed to you under the GNU General Public License
250 and the GNU Lesser General Public License.  Please see the files COPYING and
251 COPYING.LIB for more details.
252 </p>
253
254 <p>
255 More information is <a href="FAQ.html#license">available in the FAQ</a>.
256 </p>
257 </div>
258
259 <!-- *********************************************************************** -->
260
261 <hr>
262 <address>
263   <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
264   src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
265   <a href="http://validator.w3.org/check/referer"><img
266   src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
267
268   <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
269   Last modified: $Date$
270 </address>
271
272 </body>
273 </html>