Duncan Sands | 8655b15 | 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> |
| 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.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 |
| 37 | the past.</p> |
| 38 | |
| 39 | <ol> |
| 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> |
| 42 | |
| 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> |
| 46 | |
| 47 | <div class="doc_code"> |
| 48 | <pre> |
| 49 | svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.0/trunk <i>dst-directory</i> |
| 50 | </pre> |
| 51 | </div> |
| 52 | |
| 53 | <p>To check out the 4.2 code use:</p> |
| 54 | |
| 55 | <div class="doc_code"> |
| 56 | <pre> |
| 57 | svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk <i>dst-directory</i> |
| 58 | </pre> |
| 59 | </div> |
| 60 | |
| 61 | <p>After that, the code can be be updated in the destination directory |
| 62 | using:</p> |
| 63 | |
| 64 | <div class="doc_code"> |
| 65 | <pre>svn update</pre> |
| 66 | </div> |
| 67 | |
| 68 | <p>The mirror is brought up to date every evening.</p></li> |
| 69 | |
| 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. |
| 73 | </ol> |
| 74 | |
| 75 | </div> |
| 76 | |
| 77 | <!-- *********************************************************************** --> |
| 78 | <div class="doc_section"> |
| 79 | <a name="license">Building the Ada front-end</a> |
| 80 | </div> |
| 81 | |
| 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> |
| 86 | |
| 87 | <p>There are some complications however:</p> |
| 88 | |
| 89 | <ol> |
| 90 | <li><p>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.</p></li> |
| 93 | <li><p>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 |
Duncan Sands | d918b7e | 2008-04-11 13:24:43 +0000 | [diff] [blame] | 95 | build it. Compilers known to work with the |
| 96 | <a href="http://llvm.org/releases/download.html">LLVM 2.2 release</a> |
| 97 | are <a href="http://gcc.gnu.org/releases.html">gcc-4.2</a> and the |
| 98 | <a href="http://libre.adacore.com/">2005 GNAT GPL Edition</a>. |
| 99 | <a href="GettingStarted.html#checkout">LLVM from subversion</a> |
| 100 | also works with the |
| 101 | <a href="http://libre.adacore.com/">2006 and 2007 GNAT GPL Editions</a>. |
Duncan Sands | 17bcde9 | 2008-02-16 09:47:41 +0000 | [diff] [blame] | 102 | The LLVM parts of llvm-gcc are written in C++ so a C++ compiler is |
| 103 | needed to build them. The rest of gcc is written in C. |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 104 | Some linux distributions provide a version of gcc that supports all |
| 105 | three languages (the Ada part often comes as an add-on package to |
| 106 | the rest of gcc). Otherwise it is possible to combine two versions |
| 107 | of gcc, one that supports Ada and C (such as the |
Duncan Sands | d918b7e | 2008-04-11 13:24:43 +0000 | [diff] [blame] | 108 | <a href="http://libre.adacore.com/">2005 GNAT GPL Edition</a>) |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 109 | and another which supports C++, see below.</p></li> |
| 110 | <li><p>Because the Ada front-end is experimental, it is wise to build the |
Duncan Sands | d918b7e | 2008-04-11 13:24:43 +0000 | [diff] [blame] | 111 | compiler with checking enabled. This causes it to run much slower, but |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 112 | helps catch mistakes in the compiler (please report any problems using |
| 113 | <a href="http://llvm.org/bugs">LLVM bugzilla</a>).</p></li> |
| 114 | </ol> |
| 115 | |
| 116 | <p>Supposing appropriate compilers are available, llvm-gcc with Ada support can |
| 117 | be built on an x86-32 linux box using the following recipe:</p> |
| 118 | |
| 119 | <ol> |
| 120 | <li><p>Download the <a href="http://llvm.org/releases/download.html">LLVM source</a> |
| 121 | and unpack it:</p> |
| 122 | |
| 123 | <div class="doc_code"> |
| 124 | <pre>wget http://llvm.org/releases/2.2/llvm-2.2.tar.gz |
| 125 | tar xzf llvm-2.2.tar.gz |
| 126 | mv llvm-2.2 llvm</pre> |
| 127 | </div> |
| 128 | |
| 129 | <p>or <a href="GettingStarted.html#checkout">check out the |
| 130 | latest version from subversion</a>:</p> |
| 131 | |
| 132 | <div class="doc_code"> |
| 133 | <pre>svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</pre> |
| 134 | </div> |
| 135 | </li> |
| 136 | |
| 137 | <li><p>Download the |
| 138 | <a href="http://llvm.org/releases/download.html">llvm-gcc-4.2 source</a> |
| 139 | and unpack it:</p> |
| 140 | |
| 141 | <div class="doc_code"> |
| 142 | <pre>wget http://llvm.org/releases/2.2/llvm-gcc4.2-2.2.source.tar.gz |
| 143 | tar xzf llvm-gcc4.2-2.2.source.tar.gz |
| 144 | mv llvm-gcc4.2-2.2.source llvm-gcc-4.2</pre> |
| 145 | </div> |
| 146 | |
| 147 | <p>or <a href="GettingStarted.html#checkout">check out the |
| 148 | latest version from subversion</a>:</p> |
| 149 | |
| 150 | <div class="doc_code"> |
| 151 | <pre>svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk llvm-gcc-4.2</pre> |
| 152 | </div> |
| 153 | </li> |
| 154 | |
| 155 | <li><p>Make a build directory <tt>llvm-objects</tt> for llvm and make it the |
| 156 | current directory:</p> |
| 157 | |
| 158 | <div class="doc_code"> |
| 159 | <pre>mkdir llvm-objects |
| 160 | cd llvm-objects</pre> |
| 161 | </div> |
| 162 | </li> |
| 163 | |
| 164 | <li><p>Configure LLVM (here it is configured to install into <tt>/usr/local</tt>):</p> |
| 165 | |
| 166 | <div class="doc_code"> |
| 167 | <pre>../llvm/configure --prefix=<b>/usr/local</b></pre> |
| 168 | </div> |
| 169 | |
| 170 | <p>If you have a multi-compiler setup and the C++ compiler is not the |
| 171 | default, then you can configure like this:</p> |
| 172 | |
| 173 | <div class="doc_code"> |
| 174 | <pre>CXX=<b>PATH_TO_C++_COMPILER</b> ../llvm/configure --prefix=<b>/usr/local</b></pre> |
| 175 | </div> |
| 176 | </li> |
| 177 | |
| 178 | <li><p>Build LLVM with checking enabled (use <tt>ENABLE_OPTIMIZED=1</tt> to |
| 179 | build without checking):</p> |
| 180 | |
| 181 | <div class="doc_code"> |
| 182 | <pre>make ENABLE_OPTIMIZED=0</pre> |
| 183 | </div> |
| 184 | </li> |
| 185 | |
| 186 | <li><p>Install LLVM (optional):</p> |
| 187 | |
| 188 | <div class="doc_code"> |
| 189 | <pre>make install</pre> |
| 190 | </div> |
| 191 | </li> |
| 192 | |
| 193 | <li><p>Make a build directory <tt>llvm-gcc-4.2-objects</tt> for llvm-gcc and make it the |
| 194 | current directory:</p> |
| 195 | |
| 196 | <div class="doc_code"> |
| 197 | <pre> |
| 198 | cd .. |
| 199 | mkdir llvm-gcc-4.2-objects |
| 200 | cd llvm-gcc-4.2-objects</pre> |
| 201 | </div> |
| 202 | </li> |
| 203 | |
| 204 | <li><p>Configure llvm-gcc (here it is configured to install into <tt>/usr/local</tt>). |
| 205 | The <tt>--enable-checking</tt> flag turns on sanity checks inside the compiler. |
| 206 | If you omit it then LLVM must be built with <tt>make ENABLE_OPTIMIZED=1</tt>. |
| 207 | Additional languages can be appended to the --enable-languages switch, |
| 208 | for example <tt>--enable-languages=ada,c,c++</tt>.</p> |
| 209 | |
| 210 | <div class="doc_code"> |
| 211 | <pre>../llvm-gcc-4.2/configure --prefix=<b>/usr/local</b> --enable-languages=ada,c --enable-checking --enable-llvm=$PWD/../llvm-objects --disable-shared --disable-bootstrap --disable-multilib</pre> |
| 212 | </div> |
| 213 | |
| 214 | <p>If you have a multi-compiler setup, then you can configure like this:</p> |
| 215 | <div class="doc_code"> |
| 216 | |
| 217 | <pre> |
| 218 | export CC=<b>PATH_TO_C_AND_ADA_COMPILER</b> |
| 219 | export CXX=<b>PATH_TO_C++_COMPILER</b> |
| 220 | ../llvm-gcc-4.2/configure --prefix=<b>/usr/local</b> --enable-languages=ada,c --enable-checking --enable-llvm=$PWD/../llvm-objects --disable-shared --disable-bootstrap --disable-multilib</pre> |
| 221 | </div> |
| 222 | </li> |
| 223 | |
| 224 | <li><p>Build and install the compiler:</p> |
| 225 | |
| 226 | <div class="doc_code"> |
| 227 | <pre>make |
| 228 | make install</pre> |
| 229 | </div> |
| 230 | </li> |
| 231 | </ol> |
| 232 | |
| 233 | </div> |
| 234 | |
| 235 | <!-- *********************************************************************** --> |
| 236 | <div class="doc_section"> |
| 237 | <a name="license">Building the Fortran front-end</a> |
| 238 | </div> |
| 239 | |
| 240 | <div class="doc_text"> |
| 241 | <p> |
| 242 | To build with support for Fortran, follow the directions in the top-level |
| 243 | <tt>README.LLVM</tt> file, adding ",fortran" to EXTRALANGS, for example:</p> |
| 244 | |
| 245 | <div class="doc_code"> |
| 246 | <pre> |
| 247 | EXTRALANGS=,fortran |
| 248 | </pre> |
| 249 | </div> |
| 250 | |
| 251 | </div> |
| 252 | |
| 253 | <!-- *********************************************************************** --> |
| 254 | <div class="doc_section"> |
| 255 | <a name="license">License Information</a> |
| 256 | </div> |
| 257 | |
| 258 | <div class="doc_text"> |
| 259 | <p> |
| 260 | The LLVM GCC frontend is licensed to you under the GNU General Public License |
| 261 | and the GNU Lesser General Public License. Please see the files COPYING and |
| 262 | COPYING.LIB for more details. |
| 263 | </p> |
| 264 | |
| 265 | <p> |
| 266 | More information is <a href="FAQ.html#license">available in the FAQ</a>. |
| 267 | </p> |
| 268 | </div> |
| 269 | |
| 270 | <!-- *********************************************************************** --> |
| 271 | |
| 272 | <hr> |
| 273 | <address> |
| 274 | <a href="http://jigsaw.w3.org/css-validator/check/referer"><img |
| 275 | src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a> |
| 276 | <a href="http://validator.w3.org/check/referer"><img |
| 277 | src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a> |
| 278 | |
| 279 | <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br> |
| 280 | Last modified: $Date$ |
| 281 | </address> |
| 282 | |
| 283 | </body> |
| 284 | </html> |