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 | |
| 14 | <p>This document is intended to explain the process of building the LLVM |
| 15 | C/C++ front-end, based on GCC 3.4, from source.</p> |
| 16 | |
| 17 | <p><b>NOTE:</b> This is currently a somewhat fragile, error-prone |
Misha Brukman | b9e5789 | 2003-10-28 21:09:29 +0000 | [diff] [blame^] | 18 | process, and you should <b>only</b> try to do it if:</p> |
| 19 | |
| 20 | <ol> |
| 21 | <li>you really, really, really can't use the binaries we distribute</li> |
| 22 | <li>you need GCC to fix some of the header files on your system</li> |
| 23 | <li>you are an elite GCC hacker.</li> |
| 24 | </ol> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 25 | |
| 26 | <p>We welcome patches to help make this process simpler.</p> |
| 27 | |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 28 | <!-- *********************************************************************** --> |
| 29 | <div class="doc_section"> |
| 30 | <a name="instructions">Instructions</a> |
| 31 | </div> |
| 32 | <!-- *********************************************************************** --> |
| 33 | |
| 34 | <div class="doc_text"> |
| 35 | <p> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 36 | <ol> |
| 37 | <li><p>Configure and build the LLVM libraries and tools using:</p> |
| 38 | <pre> |
| 39 | % cd llvm |
| 40 | % ./configure [options...] |
| 41 | % gmake tools-only |
| 42 | </pre> |
| 43 | <p>The use of the non-default target "tools-only" means that the |
| 44 | LLVM tools and libraries will build, and the binaries will be |
| 45 | deposited in llvm/tools/Debug, but the runtime (bytecode) |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 46 | libraries will not build.</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 47 | |
| 48 | <li><p>Add the directory containing the tools to your PATH.</p> |
| 49 | <pre> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 50 | % set path = ( `cd llvm/tools/Debug && pwd` $path ) |
| 51 | </pre></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 52 | |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 53 | <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] | 54 | |
| 55 | <li><p>Edit src/configure. Change the first line (starting w/ #!) to |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 56 | contain the correct full pathname of sh.</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 57 | |
| 58 | <li><p>Make "build" and "install" directories as siblings of the "src" |
| 59 | tree.</p> |
| 60 | <pre> |
| 61 | % pwd |
| 62 | /usr/local/example/cfrontend/src |
| 63 | % cd .. |
| 64 | % mkdir build install |
| 65 | % set CFEINSTALL = `pwd`/install |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 66 | </pre></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 67 | |
| 68 | <li><p>Configure, build and install the C front-end:</p> |
| 69 | <pre> |
| 70 | % cd build |
| 71 | % ../src/configure --prefix=$CFEINSTALL --disable-nls --disable-shared \ |
| 72 | --enable-languages=c,c++ |
| 73 | % gmake all-gcc |
| 74 | % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc |
| 75 | % gmake all; gmake install |
| 76 | </pre> |
| 77 | |
Chris Lattner | e38c628 | 2003-10-23 03:55:23 +0000 | [diff] [blame] | 78 | <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] | 79 | that LLVM does not support inline assembly. Here are two common |
| 80 | fixes:</p> |
| 81 | |
| 82 | <ul> |
| 83 | <li><p><b>Fix 1:</b> If you have system header files that include |
| 84 | inline assembly, you may have to modify them to remove the inline |
| 85 | assembly, and install the modified versions in |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 86 | <code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code>.</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 87 | |
| 88 | <li><b>Fix 2:</b> If you are building the C++ front-end on a CPU we |
| 89 | haven't tried yet, you will probably have to edit the appropriate |
| 90 | version of atomicity.h under |
| 91 | <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] | 92 | 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] | 93 | </ul> |
| 94 | |
Chris Lattner | e38c628 | 2003-10-23 03:55:23 +0000 | [diff] [blame] | 95 | <p><b>Porting to a new architecture:</b> If you are porting the new front-end |
| 96 | to a new architecture, or compiling in a different configuration that we have |
| 97 | previously, there are probably several changes you will have to make to the GCC |
| 98 | target to get it to work correctly. These include:<p> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 99 | |
| 100 | <ul> |
Chris Lattner | e38c628 | 2003-10-23 03:55:23 +0000 | [diff] [blame] | 101 | <li>Often targets include special or assembler linker flags which |
| 102 | <tt>gccas</tt>/<tt>gccld</tt> does not understand. In general, these can |
| 103 | just be removed.</li> |
| 104 | <li>LLVM currently does not support any floating point values other than |
| 105 | 32-bit and 64-bit IEEE floating point. The primary effect of this is |
| 106 | that you may have to map "long double" onto "double".</li> |
| 107 | <li>The profiling hooks in GCC do not apply at all to the LLVM front-end. |
| 108 | These may need to be disabled.</li> |
| 109 | <li>No inline assembly for position independent code. At the LLVM level, |
| 110 | everything is position independent.</li> |
| 111 | <li>We handle <tt>.init</tt> and <tt>.fini</tt> differently.</li> |
Chris Lattner | 13964e0 | 2003-10-24 16:02:34 +0000 | [diff] [blame] | 112 | <li>You may have to disable multilib support in your target. Using multilib |
| 113 | support causes the GCC compiler driver to add a lot of "<tt>-L</tt>" |
| 114 | options to the link line, which do not relate to LLVM and confuse |
| 115 | <tt>gccld</tt>. To disable multilibs, delete any |
| 116 | <tt>MULTILIB_OPTIONS</tt> lines from your target files.</li> |
Chris Lattner | e38c628 | 2003-10-23 03:55:23 +0000 | [diff] [blame] | 117 | <li>Did we mention that we don't support inline assembly? You'll probably |
| 118 | have to add some fixinclude hacks to disable it in the system |
| 119 | headers.</li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 120 | </ul> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 121 | </li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 122 | |
| 123 | <li><p>Go back into the LLVM source tree proper. Edit Makefile.config |
| 124 | to redefine <code>LLVMGCCDIR</code> to the full pathname of the |
| 125 | <code>$CFEINSTALL</code> directory, which is the directory you just |
| 126 | installed the C front-end into. (The ./configure script is likely to |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 127 | 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] | 128 | |
| 129 | <li><p>If you edited header files during the C/C++ front-end build as |
| 130 | described in "Fix 1" above, you must now copy those header files from |
| 131 | <code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code> to |
| 132 | <code>$CFEINSTALL/lib/gcc/<i>target-triplet</i>/3.4-llvm/include</code>. |
| 133 | (This should be the "include" directory in the same directory as the |
| 134 | libgcc.a library, which you can find by running |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 135 | <code>$CFEINSTALL/bin/gcc --print-libgcc-file-name</code>.)</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 136 | |
| 137 | <li><p>Build and install the runtime (bytecode) libraries by running:</p> |
| 138 | <pre> |
| 139 | % gmake -C runtime |
| 140 | % mkdir $CFEINSTALL/bytecode-libs |
| 141 | % gmake -C runtime install |
| 142 | % setenv LLVM_LIB_SEARCH_PATH $CFEINSTALL/bytecode-libs |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 143 | </pre></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 144 | |
| 145 | <li><p>Test the newly-installed C frontend by one or more of the |
| 146 | following means:</p> |
| 147 | <ul> |
Chris Lattner | e38c628 | 2003-10-23 03:55:23 +0000 | [diff] [blame] | 148 | <li> compiling and running a "hello, LLVM" program in C and C++.</li> |
| 149 | <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] | 150 | test/Programs</code></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 151 | </ul> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 152 | </p> |
| 153 | </li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 154 | </ol> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 155 | </div> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 156 | |
| 157 | <!-- *********************************************************************** --> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 158 | |
Misha Brukman | b9e5789 | 2003-10-28 21:09:29 +0000 | [diff] [blame^] | 159 | <hr> |
| 160 | <div class="doc_footer"> |
| 161 | <address><a href="mailto:gaeke -at- uiuc.edu">Brian Gaeke</a></address> |
| 162 | <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a> |
| 163 | <br> |
| 164 | Last modified: $Date$ |
| 165 | </div> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 166 | |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame] | 167 | </body> |
| 168 | </html> |