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 | |
Duncan Sands | 98301c0 | 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 | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 37 | |
| 38 | <ol> |
Misha Brukman | 0427f7a | 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 | 8655b15 | 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 | 98301c0 | 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 | 8655b15 | 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 | 8655b15 | 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 | <!-- *********************************************************************** --> |
| 70 | <div class="doc_section"> |
| 71 | <a name="license">Building the Ada front-end</a> |
| 72 | </div> |
| 73 | |
| 74 | <div class="doc_text"> |
| 75 | <p>Building with support for Ada amounts to following the directions in the |
| 76 | top-level <tt>README.LLVM</tt> file, adding ",ada" to EXTRALANGS, for example: |
| 77 | <tt>EXTRALANGS=,ada</tt></p> |
| 78 | |
| 79 | <p>There are some complications however:</p> |
| 80 | |
| 81 | <ol> |
| 82 | <li><p>The only platform for which the Ada front-end is known to build is |
| 83 | 32 bit intel x86 running linux. It is unlikely to build for other |
| 84 | systems without some work.</p></li> |
| 85 | <li><p>The build requires having a compiler that supports Ada, C and C++. |
| 86 | 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] | 87 | build it. Compilers known to work with the |
Duncan Sands | b8ee801 | 2008-12-10 14:24:58 +0000 | [diff] [blame] | 88 | <a href="http://llvm.org/releases/download.html">LLVM 2.4 release</a> |
Duncan Sands | d918b7e | 2008-04-11 13:24:43 +0000 | [diff] [blame] | 89 | are <a href="http://gcc.gnu.org/releases.html">gcc-4.2</a> and the |
Duncan Sands | 98301c0 | 2008-06-09 20:24:05 +0000 | [diff] [blame] | 90 | 2005, 2006 and 2007 versions of the |
| 91 | <a href="http://libre.adacore.com/">GNAT GPL Edition</a>. |
Duncan Sands | 17bcde9 | 2008-02-16 09:47:41 +0000 | [diff] [blame] | 92 | The LLVM parts of llvm-gcc are written in C++ so a C++ compiler is |
| 93 | needed to build them. The rest of gcc is written in C. |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 94 | Some linux distributions provide a version of gcc that supports all |
| 95 | three languages (the Ada part often comes as an add-on package to |
| 96 | the rest of gcc). Otherwise it is possible to combine two versions |
| 97 | of gcc, one that supports Ada and C (such as the |
Duncan Sands | 98301c0 | 2008-06-09 20:24:05 +0000 | [diff] [blame] | 98 | <a href="http://libre.adacore.com/">2007 GNAT GPL Edition</a>) |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 99 | and another which supports C++, see below.</p></li> |
| 100 | <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] | 101 | compiler with checking enabled. This causes it to run much slower, but |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 102 | helps catch mistakes in the compiler (please report any problems using |
| 103 | <a href="http://llvm.org/bugs">LLVM bugzilla</a>).</p></li> |
| 104 | </ol> |
| 105 | |
| 106 | <p>Supposing appropriate compilers are available, llvm-gcc with Ada support can |
| 107 | be built on an x86-32 linux box using the following recipe:</p> |
| 108 | |
| 109 | <ol> |
| 110 | <li><p>Download the <a href="http://llvm.org/releases/download.html">LLVM source</a> |
| 111 | and unpack it:</p> |
| 112 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 113 | <pre class="doc_code"> |
| 114 | wget http://llvm.org/releases/2.4/llvm-2.4.tar.gz |
Duncan Sands | b8ee801 | 2008-12-10 14:24:58 +0000 | [diff] [blame] | 115 | tar xzf llvm-2.4.tar.gz |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 116 | mv llvm-2.4 llvm |
| 117 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 118 | |
| 119 | <p>or <a href="GettingStarted.html#checkout">check out the |
| 120 | latest version from subversion</a>:</p> |
| 121 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 122 | <pre class="doc_code">svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</pre> |
| 123 | |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 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 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 130 | <pre class="doc_code"> |
| 131 | wget http://llvm.org/releases/2.4/llvm-gcc-4.2-2.4.source.tar.gz |
Duncan Sands | b8ee801 | 2008-12-10 14:24:58 +0000 | [diff] [blame] | 132 | tar xzf llvm-gcc-4.2-2.4.source.tar.gz |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 133 | mv llvm-gcc4.2-2.4.source llvm-gcc-4.2 |
| 134 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 135 | |
| 136 | <p>or <a href="GettingStarted.html#checkout">check out the |
| 137 | latest version from subversion</a>:</p> |
| 138 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 139 | <pre class="doc_code"> |
| 140 | svn co http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk llvm-gcc-4.2 |
| 141 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 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 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 147 | <pre class="doc_code"> |
| 148 | mkdir llvm-objects |
| 149 | cd llvm-objects |
| 150 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 151 | </li> |
| 152 | |
| 153 | <li><p>Configure LLVM (here it is configured to install into <tt>/usr/local</tt>):</p> |
| 154 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 155 | <pre class="doc_code"> |
| 156 | ../llvm/configure --prefix=<b>/usr/local</b> |
| 157 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 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 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 162 | <pre class="doc_code"> |
| 163 | CXX=<b>PATH_TO_C++_COMPILER</b> ../llvm/configure --prefix=<b>/usr/local</b> |
| 164 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 165 | </li> |
| 166 | |
| 167 | <li><p>Build LLVM with checking enabled (use <tt>ENABLE_OPTIMIZED=1</tt> to |
| 168 | build without checking):</p> |
| 169 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 170 | <pre class="doc_code"> |
| 171 | make ENABLE_OPTIMIZED=0 |
| 172 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 173 | </li> |
| 174 | |
| 175 | <li><p>Install LLVM (optional):</p> |
| 176 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 177 | <pre class="doc_code"> |
| 178 | make ENABLE_OPTIMIZED=0 install |
| 179 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 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 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 185 | <pre class="doc_code"> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 186 | cd .. |
| 187 | mkdir llvm-gcc-4.2-objects |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 188 | cd llvm-gcc-4.2-objects |
| 189 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 190 | </li> |
| 191 | |
| 192 | <li><p>Configure llvm-gcc (here it is configured to install into <tt>/usr/local</tt>). |
| 193 | The <tt>--enable-checking</tt> flag turns on sanity checks inside the compiler. |
Duncan Sands | 98301c0 | 2008-06-09 20:24:05 +0000 | [diff] [blame] | 194 | If you omit it then LLVM should be built with <tt>make ENABLE_OPTIMIZED=1</tt>. |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 195 | Additional languages can be appended to the --enable-languages switch, |
| 196 | for example <tt>--enable-languages=ada,c,c++</tt>.</p> |
| 197 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 198 | <pre class="doc_code"> |
| 199 | ../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 |
| 200 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 201 | |
| 202 | <p>If you have a multi-compiler setup, then you can configure like this:</p> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 203 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 204 | <pre class="doc_code"> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 205 | export CC=<b>PATH_TO_C_AND_ADA_COMPILER</b> |
| 206 | export CXX=<b>PATH_TO_C++_COMPILER</b> |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 207 | ../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 |
| 208 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 209 | </li> |
| 210 | |
| 211 | <li><p>Build and install the compiler:</p> |
| 212 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 213 | <pre class="doc_code"> |
| 214 | make |
| 215 | make install |
| 216 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 217 | </li> |
| 218 | </ol> |
| 219 | |
| 220 | </div> |
| 221 | |
| 222 | <!-- *********************************************************************** --> |
| 223 | <div class="doc_section"> |
| 224 | <a name="license">Building the Fortran front-end</a> |
| 225 | </div> |
| 226 | |
| 227 | <div class="doc_text"> |
| 228 | <p> |
| 229 | To build with support for Fortran, follow the directions in the top-level |
| 230 | <tt>README.LLVM</tt> file, adding ",fortran" to EXTRALANGS, for example:</p> |
| 231 | |
Misha Brukman | 0427f7a | 2008-12-29 21:20:51 +0000 | [diff] [blame^] | 232 | <pre class="doc_code"> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 233 | EXTRALANGS=,fortran |
| 234 | </pre> |
Duncan Sands | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 235 | |
| 236 | </div> |
| 237 | |
| 238 | <!-- *********************************************************************** --> |
| 239 | <div class="doc_section"> |
| 240 | <a name="license">License Information</a> |
| 241 | </div> |
| 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 | 4440870 | 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 | 8655b15 | 2008-02-14 17:53:22 +0000 | [diff] [blame] | 261 | <a href="http://validator.w3.org/check/referer"><img |
Misha Brukman | 4440870 | 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 | 8655b15 | 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> |