1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
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 C/C++ Front-End</title>
11 <div class="doc_title">
12 Building the LLVM GCC Front-End
16 <li><a href="#instructions">Building llvm-gcc from Source</a></li>
17 <li><a href="#license">License Information</a></li>
20 <div class="doc_author">
21 <p>Written by the LLVM Team</p>
24 <!-- *********************************************************************** -->
25 <div class="doc_section">
26 <a name="instructions">Building llvm-gcc from Source</a>
28 <!-- *********************************************************************** -->
30 <div class="doc_text">
32 <p>This section describes how to acquire and build llvm-gcc 4.0 and 4.2, which are
33 based on the GCC 4.0.1/4.2.1 front-ends respectively. Both front-ends support C,
34 C++, Objective-C and Objective-C++. The 4.2 front-end also supports Ada and
35 Fortran to some extent. Note that the instructions for building these front-ends
36 are completely different (and much easier!) than those for building llvm-gcc3 in
40 <li><p>Retrieve the appropriate llvm-gcc4.x-y.z.source.tar.gz archive from the
41 <a href="http://llvm.org/releases/">llvm web site</a>.</p>
43 <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>
47 <div class="doc_code">
49 svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.0/trunk <i>dst-directory</i>
53 <p>To check out the 4.2 code use:</p>
55 <div class="doc_code">
57 svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk <i>dst-directory</i>
61 <p>After that, the code can be be updated in the destination directory
64 <div class="doc_code">
68 <p>The mirror is brought up to date every evening.</p></li>
70 <li>Follow the directions in the top-level <tt>README.LLVM</tt> file for
71 up-to-date instructions on how to build llvm-gcc. See below for building
72 with support for Ada or Fortran.
77 <!-- *********************************************************************** -->
78 <div class="doc_section">
79 <a name="license">Building the Ada front-end</a>
82 <div class="doc_text">
83 <p>Building with support for Ada amounts to following the directions in the
84 top-level <tt>README.LLVM</tt> file, adding ",ada" to EXTRALANGS, for example:
85 <tt>EXTRALANGS=,ada</tt></p>
87 <p>There are some complications however:</p>
90 <li>The only platform for which the Ada front-end is known to build is
91 32 bit intel x86 running linux. It is unlikely to build for other
92 systems without some work.</li>
93 <li>The build requires having a compiler that supports Ada, C and C++.
94 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
102 which supports C++, see below.</li>
105 <p>Supposing appropriate compilers are available, llvm-gcc with Ada support can
106 be built using the following recipe:</p>
109 <li>Download the <a href="http://llvm.org/releases/download.html">LLVM source</a>
112 <div class="doc_code">
113 <pre>wget http://llvm.org/releases/2.2/llvm-2.2.tar.gz
114 tar xzf llvm-2.2.tar.gz
115 mv llvm-2.2 llvm</pre>
118 or <a href="http://llvm.org/docs/GettingStarted.html#checkout">check out the
119 latest version from subversion</a>:
121 <div class="doc_code">
122 <pre>svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</pre>
127 <a href="http://llvm.org/releases/download.html">llvm-gcc-4.2 source</a>
130 <div class="doc_code">
131 <pre>wget http://llvm.org/releases/2.2/llvm-gcc4.2-2.2.source.tar.gz
132 tar xzf llvm-gcc4.2-2.2.source.tar.gz
133 mv llvm-gcc4.2-2.2.source llvm-gcc-4.2</pre>
136 or <a href="http://llvm.org/docs/GettingStarted.html#checkout">check out the
137 latest version from subversion</a>:
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>
144 <li>Make a build directory <tt>llvm-objects</tt> for llvm and make it the
147 <div class="doc_code">
148 <pre>mkdir llvm-objects
149 cd llvm-objects</pre>
153 <li>Configure LLVM (here it is configured to install into <tt>/usr/local</tt>):
155 <div class="doc_code">
156 <pre>../llvm/configure --prefix=/usr/local</pre>
159 If you have a multi-compiler setup and the C++ compiler is not the
160 default, then you can configure like this:
162 <div class="doc_code">
163 <pre>CXX=<b>PATH_TO_C++_COMPILER</b> ../llvm/configure --prefix=/usr/local</pre>
169 <div class="doc_code">
174 <li>Install LLVM (optional):
176 <div class="doc_code">
177 <pre>make install</pre>
181 <li>Make a build directory <tt>llvm-gcc-4.2-objects</tt> for llvm-gcc and make it the
184 <div class="doc_code">
187 mkdir llvm-gcc-4.2-objects
188 cd llvm-gcc-4.2-objects</pre>
192 <li>Configure llvm-gcc (here it is configured to install into <tt>/usr/local</tt>).
193 Additional languages can be appended to the --enable-languages switch,
194 for example <tt>--enable-languages=ada,c,c++</tt>.
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>
200 If you have a multi-compiler setup, then you can configure like this:
201 <div class="doc_code">
204 export CC=<b>PATH_TO_C_AND_ADA_COMPILER</b>
205 export 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>
210 <li>Build and install the compiler:
212 <div class="doc_code">
221 <!-- *********************************************************************** -->
222 <div class="doc_section">
223 <a name="license">Building the Fortran front-end</a>
226 <div class="doc_text">
228 To 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>
231 <div class="doc_code">
239 <!-- *********************************************************************** -->
240 <div class="doc_section">
241 <a name="license">License Information</a>
244 <div class="doc_text">
246 The LLVM GCC frontend is licensed to you under the GNU General Public License
247 and the GNU Lesser General Public License. Please see the files COPYING and
248 COPYING.LIB for more details.
252 More information is <a href="FAQ.html#license">available in the FAQ</a>.
256 <!-- *********************************************************************** -->
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>
265 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
266 Last modified: $Date$