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" /> |
| 6 | <title>Bootstrapping the C/C++ Front-End</title> |
| 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"> |
| 11 | Bootstrapping the C/C++ Front-End |
| 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 |
| 18 | process, and you should only try to do it if (A) you really, really, |
| 19 | really can't use the binaries we distribute, and (B) you are a wicked |
| 20 | good GCC hacker.</p> |
| 21 | |
| 22 | <p>We welcome patches to help make this process simpler.</p> |
| 23 | |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 24 | <!-- *********************************************************************** --> |
| 25 | <div class="doc_section"> |
| 26 | <a name="instructions">Instructions</a> |
| 27 | </div> |
| 28 | <!-- *********************************************************************** --> |
| 29 | |
| 30 | <div class="doc_text"> |
| 31 | <p> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 32 | <ol> |
| 33 | <li><p>Configure and build the LLVM libraries and tools using:</p> |
| 34 | <pre> |
| 35 | % cd llvm |
| 36 | % ./configure [options...] |
| 37 | % gmake tools-only |
| 38 | </pre> |
| 39 | <p>The use of the non-default target "tools-only" means that the |
| 40 | LLVM tools and libraries will build, and the binaries will be |
| 41 | deposited in llvm/tools/Debug, but the runtime (bytecode) |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 42 | libraries will not build.</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 43 | |
| 44 | <li><p>Add the directory containing the tools to your PATH.</p> |
| 45 | <pre> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 46 | % set path = ( `cd llvm/tools/Debug && pwd` $path ) |
| 47 | </pre></li> |
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 | <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] | 50 | |
| 51 | <li><p>Edit src/configure. Change the first line (starting w/ #!) to |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 52 | contain the correct full pathname of sh.</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 53 | |
| 54 | <li><p>Make "build" and "install" directories as siblings of the "src" |
| 55 | tree.</p> |
| 56 | <pre> |
| 57 | % pwd |
| 58 | /usr/local/example/cfrontend/src |
| 59 | % cd .. |
| 60 | % mkdir build install |
| 61 | % set CFEINSTALL = `pwd`/install |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 62 | </pre></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 63 | |
| 64 | <li><p>Configure, build and install the C front-end:</p> |
| 65 | <pre> |
| 66 | % cd build |
| 67 | % ../src/configure --prefix=$CFEINSTALL --disable-nls --disable-shared \ |
| 68 | --enable-languages=c,c++ |
| 69 | % gmake all-gcc |
| 70 | % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc |
| 71 | % gmake all; gmake install |
| 72 | </pre> |
| 73 | |
| 74 | <p><b>Common Problem 1:</b> You may get error messages regarding the fact |
| 75 | that LLVM does not support inline assembly. Here are two common |
| 76 | fixes:</p> |
| 77 | |
| 78 | <ul> |
| 79 | <li><p><b>Fix 1:</b> If you have system header files that include |
| 80 | inline assembly, you may have to modify them to remove the inline |
| 81 | assembly, and install the modified versions in |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 82 | <code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code>.</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 83 | |
| 84 | <li><b>Fix 2:</b> If you are building the C++ front-end on a CPU we |
| 85 | haven't tried yet, you will probably have to edit the appropriate |
| 86 | version of atomicity.h under |
| 87 | <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^] | 88 | 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] | 89 | </ul> |
| 90 | |
| 91 | <p><b>Common Problem 2:</b> <b>FIXME:</b> Chris should add a section about |
| 92 | common problems porting to a new architecture, including changes you |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 93 | might have to make to the <tt>gcc/gcc/config/<i>name-of-cpu</i></tt> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 94 | directory. For example (expand these):</p> |
| 95 | |
| 96 | <ul> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 97 | <li>Munge linker flags so they are compatible with <tt>gccld</tt>.</li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 98 | <li>Change the target so it doesn't have long double; just use double |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 99 | instead.</li> |
| 100 | <li>No inline assembly for position independent code.</li> |
| 101 | <li>We handle init and fini differently.</li> |
| 102 | <li>Do not include inline assembly map things for SPARC, or profile |
| 103 | things.</li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 104 | </ul> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 105 | </li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 106 | |
| 107 | <li><p>Go back into the LLVM source tree proper. Edit Makefile.config |
| 108 | to redefine <code>LLVMGCCDIR</code> to the full pathname of the |
| 109 | <code>$CFEINSTALL</code> directory, which is the directory you just |
| 110 | installed the C front-end into. (The ./configure script is likely to |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 111 | 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] | 112 | |
| 113 | <li><p>If you edited header files during the C/C++ front-end build as |
| 114 | described in "Fix 1" above, you must now copy those header files from |
| 115 | <code>$CFEINSTALL/<i>target-triplet</i>/sys-include</code> to |
| 116 | <code>$CFEINSTALL/lib/gcc/<i>target-triplet</i>/3.4-llvm/include</code>. |
| 117 | (This should be the "include" directory in the same directory as the |
| 118 | libgcc.a library, which you can find by running |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 119 | <code>$CFEINSTALL/bin/gcc --print-libgcc-file-name</code>.)</p></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 120 | |
| 121 | <li><p>Build and install the runtime (bytecode) libraries by running:</p> |
| 122 | <pre> |
| 123 | % gmake -C runtime |
| 124 | % mkdir $CFEINSTALL/bytecode-libs |
| 125 | % gmake -C runtime install |
| 126 | % setenv LLVM_LIB_SEARCH_PATH $CFEINSTALL/bytecode-libs |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 127 | </pre></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 128 | |
| 129 | <li><p>Test the newly-installed C frontend by one or more of the |
| 130 | following means:</p> |
| 131 | <ul> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 132 | <li> compiling and running a "hello, world" program in C or C++.</li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 133 | <li> running the tests under test/Programs using <code>gmake -C |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 134 | test/Programs</code></li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 135 | </ul> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 136 | </p> |
| 137 | </li> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 138 | </ol> |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 139 | </div> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 140 | |
| 141 | <!-- *********************************************************************** --> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 142 | |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 143 | <hr><font size="-1"> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 144 | <address><a href="mailto:gaeke -at- uiuc.edu">Brian Gaeke</a></address> |
| 145 | Last modified: $Date$ |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 146 | </font> |
Brian Gaeke | 46079d2 | 2003-10-21 21:58:38 +0000 | [diff] [blame] | 147 | |
Misha Brukman | 83bd33a | 2003-10-23 01:48:33 +0000 | [diff] [blame^] | 148 | </body> |
| 149 | </html> |