Misha Brukman | 6a2b310 | 2004-05-12 18:49:47 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 3 | <html> |
| 4 | <head> |
Misha Brukman | 6a2b310 | 2004-05-12 18:49:47 +0000 | [diff] [blame] | 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 6 | <link rel="stylesheet" href="llvm.css" type="text/css" media="screen"> |
Misha Brukman | b9e5789 | 2003-10-28 21:09:29 +0000 | [diff] [blame] | 7 | <title>Bootstrapping the LLVM C/C++ Front-End</title> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 8 | </head> |
| 9 | <body> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 10 | |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 11 | <div class="doc_title"> |
Misha Brukman | b9e5789 | 2003-10-28 21:09:29 +0000 | [diff] [blame] | 12 | Bootstrapping the LLVM C/C++ Front-End |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 13 | </div> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 14 | |
Brian Gaeke | 7af03e9 | 2003-11-12 20:47:30 +0000 | [diff] [blame] | 15 | <ol> |
| 16 | <li><a href="#cautionarynote">A Cautionary Note</a> |
| 17 | <li><a href="#instructions">Instructions</a> |
John Criswell | d000e1d | 2003-12-18 16:43:17 +0000 | [diff] [blame] | 18 | <li><a href="#license">License Information</a> |
Brian Gaeke | 7af03e9 | 2003-11-12 20:47:30 +0000 | [diff] [blame] | 19 | </ol> |
| 20 | |
Chris Lattner | 7911ce2 | 2004-05-23 21:07:27 +0000 | [diff] [blame] | 21 | <div class="doc_author"> |
| 22 | <p>Written by Brian R. Gaeke</p> |
Brian Gaeke | 7af03e9 | 2003-11-12 20:47:30 +0000 | [diff] [blame] | 23 | </div> |
| 24 | |
| 25 | <!-- *********************************************************************** --> |
| 26 | <div class="doc_section"> |
| 27 | <a name="cautionarynote">A Cautionary Note</a> |
| 28 | </div> |
| 29 | <!-- *********************************************************************** --> |
| 30 | |
| 31 | <div class="doc_text"> |
| 32 | <p>This document is intended to explain the process of building the |
| 33 | LLVM C/C++ front-end, based on GCC 3.4, from its source code. You |
| 34 | would have to do this, for example, if you are porting LLVM to a new |
| 35 | architecture or operating system.</p> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 36 | |
| 37 | <p><b>NOTE:</b> This is currently a somewhat fragile, error-prone |
Misha Brukman | b9e5789 | 2003-10-28 21:09:29 +0000 | [diff] [blame] | 38 | process, and you should <b>only</b> try to do it if:</p> |
| 39 | |
| 40 | <ol> |
| 41 | <li>you really, really, really can't use the binaries we distribute</li> |
| 42 | <li>you need GCC to fix some of the header files on your system</li> |
| 43 | <li>you are an elite GCC hacker.</li> |
| 44 | </ol> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 45 | |
| 46 | <p>We welcome patches to help make this process simpler.</p> |
Brian Gaeke | 7af03e9 | 2003-11-12 20:47:30 +0000 | [diff] [blame] | 47 | </div> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 48 | |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 49 | <!-- *********************************************************************** --> |
| 50 | <div class="doc_section"> |
| 51 | <a name="instructions">Instructions</a> |
| 52 | </div> |
| 53 | <!-- *********************************************************************** --> |
| 54 | |
| 55 | <div class="doc_text"> |
| 56 | <p> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 57 | <ol> |
| 58 | <li><p>Configure and build the LLVM libraries and tools using:</p> |
| 59 | <pre> |
| 60 | % cd llvm |
| 61 | % ./configure [options...] |
| 62 | % gmake tools-only |
| 63 | </pre> |
| 64 | <p>The use of the non-default target "tools-only" means that the |
| 65 | LLVM tools and libraries will build, and the binaries will be |
| 66 | deposited in llvm/tools/Debug, but the runtime (bytecode) |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 67 | libraries will not build.</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 68 | |
| 69 | <li><p>Add the directory containing the tools to your PATH.</p> |
| 70 | <pre> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 71 | % set path = ( `cd llvm/tools/Debug && pwd` $path ) |
| 72 | </pre></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 73 | |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 74 | <li><p>Unpack the C/C++ front-end source into cfrontend/src.</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 75 | |
| 76 | <li><p>Edit src/configure. Change the first line (starting w/ #!) to |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 77 | contain the correct full pathname of sh.</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 78 | |
| 79 | <li><p>Make "build" and "install" directories as siblings of the "src" |
| 80 | tree.</p> |
| 81 | <pre> |
| 82 | % pwd |
| 83 | /usr/local/example/cfrontend/src |
| 84 | % cd .. |
| 85 | % mkdir build install |
| 86 | % set CFEINSTALL = `pwd`/install |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 87 | </pre></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 88 | |
John Criswell | 2998d3f | 2003-12-10 20:04:13 +0000 | [diff] [blame] | 89 | <li><p>Configure, build, and install the C front-end:</p> |
John Criswell | 5507284 | 2003-12-08 19:59:14 +0000 | [diff] [blame] | 90 | |
| 91 | <p> |
| 92 | <b>Linux/x86:</b> |
John Criswell | e360210 | 2004-03-12 18:02:17 +0000 | [diff] [blame] | 93 | <br> |
| 94 | <b>MacOS X/PowerPC:</b> |
John Criswell | 5507284 | 2003-12-08 19:59:14 +0000 | [diff] [blame] | 95 | </p> |
| 96 | |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 97 | <pre> |
| 98 | % cd build |
John Criswell | 2998d3f | 2003-12-10 20:04:13 +0000 | [diff] [blame] | 99 | % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls --disable-shared \ |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 100 | --enable-languages=c,c++ |
| 101 | % gmake all-gcc |
| 102 | % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc |
| 103 | % gmake all; gmake install |
| 104 | </pre> |
| 105 | |
John Criswell | 5507284 | 2003-12-08 19:59:14 +0000 | [diff] [blame] | 106 | <p> |
Brian Gaeke | 7e9bd80 | 2004-01-28 20:54:41 +0000 | [diff] [blame] | 107 | <b>Solaris/SPARC:</b> |
John Criswell | 5507284 | 2003-12-08 19:59:14 +0000 | [diff] [blame] | 108 | </p> |
| 109 | |
| 110 | <p> |
Brian Gaeke | 7e9bd80 | 2004-01-28 20:54:41 +0000 | [diff] [blame] | 111 | For Solaris/SPARC, LLVM only supports the SPARC V9. Therefore, the |
| 112 | configure command line should specify sparcv9, as shown below. Also, |
| 113 | note that Solaris has trouble with various wide (multibyte) character |
| 114 | functions from C as referenced from C++, so we typically configure with |
| 115 | --disable-c-mbchar (cf. <a href="http://llvm.cs.uiuc.edu/PR206">Bug 206</a>). |
John Criswell | 5507284 | 2003-12-08 19:59:14 +0000 | [diff] [blame] | 116 | </p> |
| 117 | |
| 118 | <pre> |
| 119 | % cd build |
Brian Gaeke | 7e9bd80 | 2004-01-28 20:54:41 +0000 | [diff] [blame] | 120 | % ../src/configure --prefix=$CFEINSTALL --disable-threads --disable-nls \ |
| 121 | --disable-shared --enable-languages=c,c++ --host=sparcv9-sun-solaris2.8 \ |
| 122 | --disable-c-mbchar |
John Criswell | 5507284 | 2003-12-08 19:59:14 +0000 | [diff] [blame] | 123 | % gmake all-gcc |
| 124 | % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc |
Brian Gaeke | 7e9bd80 | 2004-01-28 20:54:41 +0000 | [diff] [blame] | 125 | % gmake all; gmake install |
John Criswell | 5507284 | 2003-12-08 19:59:14 +0000 | [diff] [blame] | 126 | </pre> |
| 127 | |
Chris Lattner | e38c628 | 2003-10-23 03:55:23 +0000 | [diff] [blame] | 128 | <p><b>Common Problem:</b> You may get error messages regarding the fact |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 129 | that LLVM does not support inline assembly. Here are two common |
| 130 | fixes:</p> |
| 131 | |
| 132 | <ul> |
| 133 | <li><p><b>Fix 1:</b> If you have system header files that include |
| 134 | inline assembly, you may have to modify them to remove the inline |
| 135 | assembly, and install the modified versions in |
Misha Brukman | 6a2b310 | 2004-05-12 18:49:47 +0000 | [diff] [blame] | 136 | <code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code>.</li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 137 | |
| 138 | <li><b>Fix 2:</b> If you are building the C++ front-end on a CPU we |
| 139 | haven't tried yet, you will probably have to edit the appropriate |
| 140 | version of atomicity.h under |
| 141 | <code>src/libstdc++-v3/config/cpu/<i>name-of-cpu</i>/atomicity.h</code> |
Misha Brukman | 6a2b310 | 2004-05-12 18:49:47 +0000 | [diff] [blame] | 142 | and apply a patch so that it does not use inline assembly.</li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 143 | </ul> |
| 144 | |
Chris Lattner | e38c628 | 2003-10-23 03:55:23 +0000 | [diff] [blame] | 145 | <p><b>Porting to a new architecture:</b> If you are porting the new front-end |
| 146 | to a new architecture, or compiling in a different configuration that we have |
| 147 | previously, there are probably several changes you will have to make to the GCC |
| 148 | target to get it to work correctly. These include:<p> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 149 | |
| 150 | <ul> |
Chris Lattner | e38c628 | 2003-10-23 03:55:23 +0000 | [diff] [blame] | 151 | <li>Often targets include special or assembler linker flags which |
| 152 | <tt>gccas</tt>/<tt>gccld</tt> does not understand. In general, these can |
| 153 | just be removed.</li> |
| 154 | <li>LLVM currently does not support any floating point values other than |
| 155 | 32-bit and 64-bit IEEE floating point. The primary effect of this is |
| 156 | that you may have to map "long double" onto "double".</li> |
| 157 | <li>The profiling hooks in GCC do not apply at all to the LLVM front-end. |
| 158 | These may need to be disabled.</li> |
| 159 | <li>No inline assembly for position independent code. At the LLVM level, |
| 160 | everything is position independent.</li> |
| 161 | <li>We handle <tt>.init</tt> and <tt>.fini</tt> differently.</li> |
Chris Lattner | 13964e0 | 2003-10-24 16:02:34 +0000 | [diff] [blame] | 162 | <li>You may have to disable multilib support in your target. Using multilib |
| 163 | support causes the GCC compiler driver to add a lot of "<tt>-L</tt>" |
| 164 | options to the link line, which do not relate to LLVM and confuse |
| 165 | <tt>gccld</tt>. To disable multilibs, delete any |
| 166 | <tt>MULTILIB_OPTIONS</tt> lines from your target files.</li> |
Chris Lattner | e38c628 | 2003-10-23 03:55:23 +0000 | [diff] [blame] | 167 | <li>Did we mention that we don't support inline assembly? You'll probably |
| 168 | have to add some fixinclude hacks to disable it in the system |
| 169 | headers.</li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 170 | </ul> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 171 | </li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 172 | |
| 173 | <li><p>Go back into the LLVM source tree proper. Edit Makefile.config |
| 174 | to redefine <code>LLVMGCCDIR</code> to the full pathname of the |
| 175 | <code>$CFEINSTALL</code> directory, which is the directory you just |
| 176 | installed the C front-end into. (The ./configure script is likely to |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 177 | have set this to a directory which does not exist on your system.)</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 178 | |
| 179 | <li><p>If you edited header files during the C/C++ front-end build as |
| 180 | described in "Fix 1" above, you must now copy those header files from |
| 181 | <code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code> to |
| 182 | <code>$CFEINSTALL/lib/gcc/<i>target-triplet</i>/3.4-llvm/include</code>. |
| 183 | (This should be the "include" directory in the same directory as the |
| 184 | libgcc.a library, which you can find by running |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 185 | <code>$CFEINSTALL/bin/gcc --print-libgcc-file-name</code>.)</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 186 | |
| 187 | <li><p>Build and install the runtime (bytecode) libraries by running:</p> |
| 188 | <pre> |
| 189 | % gmake -C runtime |
| 190 | % mkdir $CFEINSTALL/bytecode-libs |
Brian Gaeke | 714caf2 | 2004-03-10 19:08:52 +0000 | [diff] [blame] | 191 | % gmake -C runtime install-bytecode |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 192 | % setenv LLVM_LIB_SEARCH_PATH $CFEINSTALL/bytecode-libs |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 193 | </pre></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 194 | |
| 195 | <li><p>Test the newly-installed C frontend by one or more of the |
| 196 | following means:</p> |
| 197 | <ul> |
Chris Lattner | e38c628 | 2003-10-23 03:55:23 +0000 | [diff] [blame] | 198 | <li> compiling and running a "hello, LLVM" program in C and C++.</li> |
| 199 | <li> running the tests under <tt>test/Programs</tt> using <code>gmake -C |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 200 | test/Programs</code></li> |
Misha Brukman | 6a2b310 | 2004-05-12 18:49:47 +0000 | [diff] [blame] | 201 | </ul></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 202 | </ol> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 203 | </div> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 204 | |
| 205 | <!-- *********************************************************************** --> |
John Criswell | d000e1d | 2003-12-18 16:43:17 +0000 | [diff] [blame] | 206 | <div class="doc_section"> |
| 207 | <a name="license">License Information</a> |
| 208 | </div> |
| 209 | |
| 210 | <div class="doc_text"> |
| 211 | <p> |
| 212 | The LLVM GCC frontend is licensed to you under the GNU General Public License |
| 213 | and the GNU Lesser General Public License. Please see the files COPYING and |
| 214 | COPYING.LIB for more details. |
| 215 | </p> |
| 216 | |
| 217 | <p> |
| 218 | The software also has the following additional copyrights: |
| 219 | </p> |
| 220 | |
| 221 | <pre> |
John Criswell | e360210 | 2004-03-12 18:02:17 +0000 | [diff] [blame] | 222 | |
| 223 | Copyright (c) 2003, 2004 University of Illinois at Urbana-Champaign. |
| 224 | All rights reserved. |
| 225 | |
| 226 | Developed by: |
| 227 | |
| 228 | LLVM Team |
| 229 | |
| 230 | University of Illinois at Urbana-Champaign |
| 231 | |
| 232 | http://llvm.cs.uiuc.edu |
| 233 | |
| 234 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 235 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 236 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 237 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 238 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 239 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE |
| 240 | SOFTWARE. |
| 241 | |
John Criswell | d000e1d | 2003-12-18 16:43:17 +0000 | [diff] [blame] | 242 | Copyright (c) 1994 |
| 243 | Hewlett-Packard Company |
| 244 | |
| 245 | Permission to use, copy, modify, distribute and sell this software |
| 246 | and its documentation for any purpose is hereby granted without fee, |
| 247 | provided that the above copyright notice appear in all copies and |
| 248 | that both that copyright notice and this permission notice appear |
| 249 | in supporting documentation. Hewlett-Packard Company makes no |
| 250 | representations about the suitability of this software for any |
| 251 | purpose. It is provided "as is" without express or implied warranty. |
| 252 | |
| 253 | Copyright (c) 1996, 1997, 1998, 1999 |
| 254 | Silicon Graphics Computer Systems, Inc. |
| 255 | |
| 256 | Permission to use, copy, modify, distribute and sell this software |
| 257 | and its documentation for any purpose is hereby granted without fee, |
| 258 | provided that the above copyright notice appear in all copies and |
| 259 | that both that copyright notice and this permission notice appear |
| 260 | in supporting documentation. Silicon Graphics makes no |
| 261 | representations about the suitability of this software for any |
| 262 | purpose. It is provided "as is" without express or implied warranty. |
| 263 | </pre> |
| 264 | </div> |
| 265 | |
| 266 | <!-- *********************************************************************** --> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 267 | |
Misha Brukman | b9e5789 | 2003-10-28 21:09:29 +0000 | [diff] [blame] | 268 | <hr> |
Misha Brukman | 6a2b310 | 2004-05-12 18:49:47 +0000 | [diff] [blame] | 269 | <address> |
| 270 | <a href="http://jigsaw.w3.org/css-validator/check/referer"><img |
| 271 | src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a> |
| 272 | <a href="http://validator.w3.org/check/referer"><img |
| 273 | src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a> |
| 274 | |
| 275 | Brian Gaeke<br> |
| 276 | <a href="http://llvm.cs.uiuc.edu">LLVM Compiler Infrastructure</a><br> |
Misha Brukman | b9e5789 | 2003-10-28 21:09:29 +0000 | [diff] [blame] | 277 | Last modified: $Date$ |
Misha Brukman | 6a2b310 | 2004-05-12 18:49:47 +0000 | [diff] [blame] | 278 | </address> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 279 | |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 280 | </body> |
| 281 | </html> |