| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 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> | 
| Misha Brukman | fd60966 | 2008-12-29 21:33:30 +0000 | [diff] [blame] | 17 | <li><a href="#ada">Building the Ada front-end</a></li> | 
|  | 18 | <li><a href="#fortran">Building the Fortran front-end</a></li> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 19 | <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 Brukman | fd60966 | 2008-12-29 21:33:30 +0000 | [diff] [blame] | 27 | <h1><a name="instructions">Building llvm-gcc from Source</a></h1> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 28 | <!-- *********************************************************************** --> | 
|  | 29 |  | 
|  | 30 | <div class="doc_text"> | 
|  | 31 |  | 
| Duncan Sands | 7192a54 | 2008-06-09 20:24:05 +0000 | [diff] [blame] | 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> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 37 |  | 
|  | 38 | <ol> | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 39 | <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 Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 42 |  | 
|  | 43 | <p>It is also possible to download the sources of the llvm-gcc front end | 
| Duncan Sands | 7192a54 | 2008-06-09 20:24:05 +0000 | [diff] [blame] | 44 | from a read-only mirror using subversion.  To check out the 4.2 code | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 45 | for first time use:</p> | 
|  | 46 |  | 
|  | 47 | <div class="doc_code"> | 
|  | 48 | <pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 49 | svn 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 Brukman | fd60966 | 2008-12-29 21:33:30 +0000 | [diff] [blame] | 70 | <h1><a name="ada">Building the Ada front-end</a></h1> | 
|  | 71 | <!-- *********************************************************************** --> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 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 | 
| Duncan Sands | 21285fc | 2008-04-11 13:24:43 +0000 | [diff] [blame] | 86 | build it.  Compilers known to work with the | 
| Duncan Sands | ec1b9b6 | 2008-12-10 14:24:58 +0000 | [diff] [blame] | 87 | <a href="http://llvm.org/releases/download.html">LLVM 2.4 release</a> | 
| Duncan Sands | 21285fc | 2008-04-11 13:24:43 +0000 | [diff] [blame] | 88 | are <a href="http://gcc.gnu.org/releases.html">gcc-4.2</a> and the | 
| Duncan Sands | 7192a54 | 2008-06-09 20:24:05 +0000 | [diff] [blame] | 89 | 2005, 2006 and 2007 versions of the | 
|  | 90 | <a href="http://libre.adacore.com/">GNAT GPL Edition</a>. | 
| Duncan Sands | 648e5d6 | 2008-02-16 09:47:41 +0000 | [diff] [blame] | 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. | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 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 | 
| Duncan Sands | 7192a54 | 2008-06-09 20:24:05 +0000 | [diff] [blame] | 97 | <a href="http://libre.adacore.com/">2007 GNAT GPL Edition</a>) | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 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 | 
| Duncan Sands | 21285fc | 2008-04-11 13:24:43 +0000 | [diff] [blame] | 100 | compiler with checking enabled.  This causes it to run much slower, but | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 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 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 112 | <pre class="doc_code"> | 
|  | 113 | wget http://llvm.org/releases/2.4/llvm-2.4.tar.gz | 
| Duncan Sands | ec1b9b6 | 2008-12-10 14:24:58 +0000 | [diff] [blame] | 114 | tar xzf llvm-2.4.tar.gz | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 115 | mv llvm-2.4 llvm | 
|  | 116 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 117 |  | 
|  | 118 | <p>or <a href="GettingStarted.html#checkout">check out the | 
|  | 119 | latest version from subversion</a>:</p> | 
|  | 120 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 121 | <pre class="doc_code">svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</pre> | 
|  | 122 |  | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 123 | </li> | 
|  | 124 |  | 
|  | 125 | <li><p>Download the | 
|  | 126 | <a href="http://llvm.org/releases/download.html">llvm-gcc-4.2 source</a> | 
|  | 127 | and unpack it:</p> | 
|  | 128 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 129 | <pre class="doc_code"> | 
|  | 130 | wget http://llvm.org/releases/2.4/llvm-gcc-4.2-2.4.source.tar.gz | 
| Duncan Sands | ec1b9b6 | 2008-12-10 14:24:58 +0000 | [diff] [blame] | 131 | tar xzf llvm-gcc-4.2-2.4.source.tar.gz | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 132 | mv llvm-gcc4.2-2.4.source llvm-gcc-4.2 | 
|  | 133 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 134 |  | 
|  | 135 | <p>or <a href="GettingStarted.html#checkout">check out the | 
|  | 136 | latest version from subversion</a>:</p> | 
|  | 137 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 138 | <pre class="doc_code"> | 
|  | 139 | svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk llvm-gcc-4.2 | 
|  | 140 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 141 | </li> | 
|  | 142 |  | 
|  | 143 | <li><p>Make a build directory <tt>llvm-objects</tt> for llvm and make it the | 
|  | 144 | current directory:</p> | 
|  | 145 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 146 | <pre class="doc_code"> | 
|  | 147 | mkdir llvm-objects | 
|  | 148 | cd llvm-objects | 
|  | 149 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 150 | </li> | 
|  | 151 |  | 
|  | 152 | <li><p>Configure LLVM (here it is configured to install into <tt>/usr/local</tt>):</p> | 
|  | 153 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 154 | <pre class="doc_code"> | 
|  | 155 | ../llvm/configure --prefix=<b>/usr/local</b> | 
|  | 156 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 157 |  | 
|  | 158 | <p>If you have a multi-compiler setup and the C++ compiler is not the | 
|  | 159 | default, then you can configure like this:</p> | 
|  | 160 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 161 | <pre class="doc_code"> | 
|  | 162 | CXX=<b>PATH_TO_C++_COMPILER</b> ../llvm/configure --prefix=<b>/usr/local</b> | 
|  | 163 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 164 | </li> | 
|  | 165 |  | 
|  | 166 | <li><p>Build LLVM with checking enabled (use <tt>ENABLE_OPTIMIZED=1</tt> to | 
|  | 167 | build without checking):</p> | 
|  | 168 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 169 | <pre class="doc_code"> | 
|  | 170 | make ENABLE_OPTIMIZED=0 | 
|  | 171 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 172 | </li> | 
|  | 173 |  | 
|  | 174 | <li><p>Install LLVM (optional):</p> | 
|  | 175 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 176 | <pre class="doc_code"> | 
|  | 177 | make ENABLE_OPTIMIZED=0 install | 
|  | 178 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 179 | </li> | 
|  | 180 |  | 
|  | 181 | <li><p>Make a build directory <tt>llvm-gcc-4.2-objects</tt> for llvm-gcc and make it the | 
|  | 182 | current directory:</p> | 
|  | 183 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 184 | <pre class="doc_code"> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 185 | cd .. | 
|  | 186 | mkdir llvm-gcc-4.2-objects | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 187 | cd llvm-gcc-4.2-objects | 
|  | 188 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 189 | </li> | 
|  | 190 |  | 
|  | 191 | <li><p>Configure llvm-gcc (here it is configured to install into <tt>/usr/local</tt>). | 
|  | 192 | The <tt>--enable-checking</tt> flag turns on sanity checks inside the compiler. | 
| Duncan Sands | 7192a54 | 2008-06-09 20:24:05 +0000 | [diff] [blame] | 193 | If you omit it then LLVM should be built with <tt>make ENABLE_OPTIMIZED=1</tt>. | 
| Misha Brukman | b536235 | 2009-01-03 02:35:05 +0000 | [diff] [blame] | 194 | Additional languages can be appended to the <tt>--enable-languages</tt> switch, | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 195 | for example <tt>--enable-languages=ada,c,c++</tt>.</p> | 
|  | 196 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 197 | <pre class="doc_code"> | 
| Misha Brukman | b536235 | 2009-01-03 02:35:05 +0000 | [diff] [blame] | 198 | ../llvm-gcc-4.2/configure --prefix=<b>/usr/local</b> --enable-languages=ada,c \ | 
|  | 199 | --enable-checking --enable-llvm=$PWD/../llvm-objects \ | 
|  | 200 | --disable-bootstrap --disable-multilib | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 201 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 202 |  | 
|  | 203 | <p>If you have a multi-compiler setup, then you can configure like this:</p> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 204 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 205 | <pre class="doc_code"> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 206 | export CC=<b>PATH_TO_C_AND_ADA_COMPILER</b> | 
|  | 207 | export CXX=<b>PATH_TO_C++_COMPILER</b> | 
| Misha Brukman | b536235 | 2009-01-03 02:35:05 +0000 | [diff] [blame] | 208 | ../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 Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 211 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 212 | </li> | 
|  | 213 |  | 
|  | 214 | <li><p>Build and install the compiler:</p> | 
|  | 215 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 216 | <pre class="doc_code"> | 
|  | 217 | make | 
|  | 218 | make install | 
|  | 219 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 220 | </li> | 
|  | 221 | </ol> | 
|  | 222 |  | 
|  | 223 | </div> | 
|  | 224 |  | 
|  | 225 | <!-- *********************************************************************** --> | 
| Misha Brukman | fd60966 | 2008-12-29 21:33:30 +0000 | [diff] [blame] | 226 | <h1><a name="fortran">Building the Fortran front-end</a></h1> | 
|  | 227 | <!-- *********************************************************************** --> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 228 |  | 
|  | 229 | <div class="doc_text"> | 
| Misha Brukman | fd60966 | 2008-12-29 21:33:30 +0000 | [diff] [blame] | 230 | <p>To build with support for Fortran, follow the directions in the top-level | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 231 | <tt>README.LLVM</tt> file, adding ",fortran" to EXTRALANGS, for example:</p> | 
|  | 232 |  | 
| Misha Brukman | 8dab303 | 2008-12-29 21:20:51 +0000 | [diff] [blame] | 233 | <pre class="doc_code"> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 234 | EXTRALANGS=,fortran | 
|  | 235 | </pre> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 236 |  | 
|  | 237 | </div> | 
|  | 238 |  | 
|  | 239 | <!-- *********************************************************************** --> | 
| Misha Brukman | fd60966 | 2008-12-29 21:33:30 +0000 | [diff] [blame] | 240 | <h1><a name="license">License Information</a></h1> | 
|  | 241 | <!-- *********************************************************************** --> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 242 |  | 
|  | 243 | <div class="doc_text"> | 
|  | 244 | <p> | 
|  | 245 | The LLVM GCC frontend is licensed to you under the GNU General Public License | 
|  | 246 | and the GNU Lesser General Public License.  Please see the files COPYING and | 
|  | 247 | COPYING.LIB for more details. | 
|  | 248 | </p> | 
|  | 249 |  | 
|  | 250 | <p> | 
|  | 251 | More information is <a href="FAQ.html#license">available in the FAQ</a>. | 
|  | 252 | </p> | 
|  | 253 | </div> | 
|  | 254 |  | 
|  | 255 | <!-- *********************************************************************** --> | 
|  | 256 |  | 
|  | 257 | <hr> | 
|  | 258 | <address> | 
|  | 259 | <a href="http://jigsaw.w3.org/css-validator/check/referer"><img | 
| Misha Brukman | 86242e1 | 2008-12-11 17:34:48 +0000 | [diff] [blame] | 260 | src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 261 | <a href="http://validator.w3.org/check/referer"><img | 
| Misha Brukman | 86242e1 | 2008-12-11 17:34:48 +0000 | [diff] [blame] | 262 | src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a> | 
| Duncan Sands | 551d3e6 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 263 |  | 
|  | 264 | <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br> | 
|  | 265 | Last modified: $Date$ | 
|  | 266 | </address> | 
|  | 267 |  | 
|  | 268 | </body> | 
|  | 269 | </html> |