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