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