Guochun Shi | f4688a8 | 2002-07-17 23:05:56 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | <html> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 3 | <head> |
| 4 | <title>Getting Started with LLVM System</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | <center><h1>Getting Started with the LLVM System<br><font size=3>By: <a |
| 9 | href="mailto:gshi1@uiuc.edu">Guochun Shi</a>, |
John Criswell | cb27f1e | 2003-07-01 21:55:57 +0000 | [diff] [blame] | 10 | <a href="mailto:sabre@nondot.org">Chris Lattner</a>, |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 11 | <a href="mailto:criswell@uiuc.edu">John Criswell</a>, |
| 12 | <a href="http://misha.brukman.net">Misha Brukman</a>, and |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 13 | <a href="http://www.cs.uiuc.edu/~vadve">Vikram Adve</a> |
| 14 | </font></h1></center> |
| 15 | |
| 16 | <!--=====================================================================--> |
| 17 | <h2><a name="Contents">Contents</a></h2> |
| 18 | <!--=====================================================================--> |
| 19 | |
| 20 | <ul> |
| 21 | <li><a href="#overview">Overview</a> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 22 | <li><a href="#quickstart">Getting Started Quickly (A Summary)</a> |
John Criswell | 3ab7136 | 2003-10-20 16:39:52 +0000 | [diff] [blame] | 23 | <li><a href="#requirements">Requirements</a> |
| 24 | <ol> |
| 25 | <li><a href="#hardware">Hardware</a> |
| 26 | <li><a href="#software">Software</a> |
| 27 | </ol> |
| 28 | |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 29 | <li><a href="#starting">Getting Started with LLVM</a> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 30 | <ol> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 31 | <li><a href="#terminology">Terminology and Notation</tt></a> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 32 | <li><a href="#environment">Setting Up Your Environment</a> |
John Criswell | 312a68c | 2003-07-07 19:27:35 +0000 | [diff] [blame] | 33 | <li><a href="#unpack">Unpacking the LLVM Archives</a> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 34 | <li><a href="#checkout">Checkout LLVM from CVS</a> |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 35 | <li><a href="#installcf">Install the GCC Front End</a> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 36 | <li><a href="#config">Local LLVM Configuration</tt></a> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 37 | <li><a href="#compile">Compiling the LLVM Suite Source Code</a> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 38 | <li><a href="#objfiles">The Location of LLVM Object Files</tt></a> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 39 | </ol> |
| 40 | <li><a href="#layout">Program layout</a> |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 41 | <ol> |
| 42 | <li><a href="#cvsdir"><tt>CVS</tt> directories</a> |
| 43 | <li><a href="#include"><tt>llvm/include</tt></a> |
| 44 | <li><a href="#lib"><tt>llvm/lib</tt></a> |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 45 | <li><a href="#runtime"><tt>llvm/runtime</tt></a> |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 46 | <li><a href="#test"><tt>llvm/test</tt></a> |
| 47 | <li><a href="#tools"><tt>llvm/tools</tt></a> |
| 48 | <li><a href="#utils"><tt>llvm/utils</tt></a> |
| 49 | </ol> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 50 | <li><a href="#tutorial">An Example Using the LLVM Tool Chain</a> |
| 51 | <li><a href="#problems">Common Problems</a> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 52 | <li><a href="#links">Links</a> |
| 53 | </ul> |
| 54 | |
| 55 | |
| 56 | <!--=====================================================================--> |
| 57 | <center> |
| 58 | <h2><a name="overview"><b>Overview</b></a></h2> |
| 59 | </center> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 60 | <hr> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 61 | <!--=====================================================================--> |
| 62 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 63 | Welcome to LLVM! In order to get started, you first need to know some |
| 64 | basic information. |
| 65 | |
| 66 | <p> |
| 67 | First, LLVM comes in two pieces. The first piece is the LLVM suite. This |
| 68 | contains all of the tools, libraries, and header files needed to use the |
John Criswell | 3ab7136 | 2003-10-20 16:39:52 +0000 | [diff] [blame] | 69 | low level virtual machine. It contains an assembler, disassembler, |
| 70 | bytecode analyzer, and bytecode optimizer. It also contains a test suite |
| 71 | that can be used to test the LLVM tools and the GCC front end. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 72 | <p> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 73 | The second piece is the GCC front end. This component provides a version |
| 74 | of GCC that compiles C and C++ code into LLVM bytecode. Currently, the |
| 75 | GCC front end is a modified version of GCC 3.4 (we track the GCC 3.4 |
| 76 | development). Once compiled into LLVM bytecode, a program can be |
| 77 | manipulated with the LLVM tools from the LLVM suite. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 78 | |
| 79 | <!--=====================================================================--> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 80 | <center> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 81 | <h2><a name="quickstart"><b>Getting Started Quickly (A Summary)</b></a></h2> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 82 | </center> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 83 | <hr> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 84 | <!--=====================================================================--> |
| 85 | |
| 86 | Here's the short story for getting up and running quickly with LLVM: |
Chris Lattner | 96768ea | 2003-02-14 04:22:13 +0000 | [diff] [blame] | 87 | <ol> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 88 | <li>Install the GCC front end: |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 89 | <ol> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 90 | <li><tt>cd <i>where-you-want-the-C-front-end-to-live</i></tt> |
| 91 | <li><tt>gunzip --stdout cfrontend.<i>platform</i>.tar.gz | tar -xvf |
| 92 | -</tt> |
John Criswell | 0f6d7c0 | 2003-10-27 18:18:16 +0000 | [diff] [blame^] | 93 | <li><b>Sparc Only:</b><br> |
| 94 | <tt> |
| 95 | cd cfrontend/sparc<br> |
| 96 | ./fixheaders |
| 97 | </tt> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 98 | </ol> |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 99 | |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 100 | <p> |
| 101 | |
| 102 | <li>Get the Source Code |
| 103 | <ul> |
| 104 | <li>With the distributed files: |
| 105 | <ol> |
| 106 | <li><tt>cd <i>where-you-want-llvm-to-live</i></tt> |
| 107 | <li><tt>gunzip --stdout llvm.tar.gz | tar -xvf -</tt> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 108 | <li><tt>cd llvm</tt> |
| 109 | </ol> |
| 110 | |
| 111 | <p> |
| 112 | |
| 113 | <li>With anonymous CVS access: |
| 114 | <ol> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 115 | <li><tt>cd <i>where-you-want-llvm-to-live</i></tt> |
John Criswell | e04c263 | 2003-10-21 21:24:38 +0000 | [diff] [blame] | 116 | <li><tt>cvs -d :pserver:anon@llvm-cvs.cs.uiuc.edu:/var/cvs/llvm login</tt> |
| 117 | <li>Hit the return key when prompted for the password. |
Chris Lattner | 70bb09b | 2003-10-23 19:49:01 +0000 | [diff] [blame] | 118 | <li><tt>cvs -z3 -d :pserver:anon@llvm-cvs.cs.uiuc.edu:/var/cvs/llvm co llvm</tt> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 119 | <li><tt>cd llvm</tt> |
| 120 | </ol> |
| 121 | </ul> |
| 122 | </ul> |
| 123 | |
| 124 | <p> |
| 125 | |
| 126 | <li>Configure the LLVM Build Environment |
| 127 | <ol> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 128 | <li>Change directory to where you want to store the LLVM object |
| 129 | files and run <tt>configure</tt> to configure the Makefiles and |
| 130 | header files for the default platform. |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 131 | Useful options include: |
| 132 | <ul> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 133 | <li><tt>--with-llvmgccdir=<i>directory</i></tt> |
| 134 | <br> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 135 | Specify where the LLVM GCC frontend is installed. |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 136 | <p> |
| 137 | |
| 138 | <li><tt>--enable-spec2000=<i>directory</i></tt> |
| 139 | <br> |
| 140 | Enable the SPEC2000 benchmarks for testing. The SPEC2000 |
| 141 | benchmarks should be available in <tt><i>directory</i></tt>. |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 142 | </ul> |
| 143 | </ol> |
| 144 | |
| 145 | <p> |
| 146 | |
| 147 | <li>Build the LLVM Suite |
| 148 | <ol> |
| 149 | <li>Set your LLVM_LIB_SEARCH_PATH environment variable. |
| 150 | <li><tt>gmake -k |& tee gnumake.out |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 151 | # this is csh or tcsh syntax</tt> |
| 152 | </ol> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 153 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 154 | <p> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 155 | |
Chris Lattner | 96768ea | 2003-02-14 04:22:13 +0000 | [diff] [blame] | 156 | </ol> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 157 | |
John Criswell | 3ab7136 | 2003-10-20 16:39:52 +0000 | [diff] [blame] | 158 | <p> |
| 159 | Consult the <a href="starting">Getting Started with LLVM</a> section for |
| 160 | detailed information on configuring and compiling LLVM. See |
| 161 | <a href="#environment">Setting Up Your Environment</a> for tips that |
| 162 | simplify working with the GCC front end and LLVM tools. Go to |
| 163 | <a href="#layout">Program Layout</a> to learn about the layout of the |
| 164 | source code tree. |
| 165 | |
| 166 | <!--=====================================================================--> |
| 167 | <center> |
| 168 | <h2><a name="requirements"><b>Requirements</b></a></h2> |
| 169 | </center> |
| 170 | <hr> |
| 171 | <!--=====================================================================--> |
| 172 | |
| 173 | Before you begin to use the LLVM system, review the requirements given |
| 174 | below. This may save you some trouble by knowing ahead of time what |
| 175 | hardware and software you will need. |
| 176 | |
| 177 | <!--=====================================================================--> |
| 178 | <h3><a name="hardware"><b>Hardware</b></a></h3> |
| 179 | <!--=====================================================================--> |
| 180 | LLVM is known to work on the following platforms: |
| 181 | <ul> |
| 182 | <li> Linux on x86 (Pentium and above) |
| 183 | <ul> |
| 184 | <li> Approximately 760 MB of Free Disk Space |
| 185 | <ul> |
| 186 | <li>Source code: 30 MB |
| 187 | <li>Object code: 670 MB |
| 188 | <li>GCC front end: 60 MB |
| 189 | </ul> |
| 190 | </ul> |
| 191 | |
| 192 | <p> |
| 193 | |
| 194 | <li> Solaris on SparcV9 (Ultrasparc) |
| 195 | <ul> |
| 196 | <li> Approximately 1.24 GB of Free Disk Space |
| 197 | <ul> |
| 198 | <li>Source code: 30 MB |
| 199 | <li>Object code: 1000 MB |
| 200 | <li>GCC front end: 210 MB |
| 201 | </ul> |
| 202 | </ul> |
| 203 | </ul> |
| 204 | |
| 205 | The LLVM suite <i>may</i> compile on other platforms, but it is not |
| 206 | guaranteed to do so. If compilation is successful, the LLVM utilities |
| 207 | should be able to assemble, disassemble, analyze, and optimize LLVM |
| 208 | bytecode. Code generation should work as well, although the generated |
| 209 | native code may not work on your platform. |
| 210 | <p> |
| 211 | The GCC front end is not very portable at the moment. If you want to get |
John Criswell | 0f6d7c0 | 2003-10-27 18:18:16 +0000 | [diff] [blame^] | 212 | it to work on another platform, you can download a copy of the source |
John Criswell | 3ab7136 | 2003-10-20 16:39:52 +0000 | [diff] [blame] | 213 | and try to compile it on your platform. |
| 214 | </p> |
| 215 | |
| 216 | <!--=====================================================================--> |
| 217 | <h3><a name="software"><b>Software</b></a></h3> |
| 218 | <!--=====================================================================--> |
| 219 | <p> |
| 220 | |
| 221 | Compiling LLVM requires that you have several software packages installed: |
| 222 | |
| 223 | <ul compact> |
| 224 | <li> |
| 225 | <a href="http://gcc.gnu.org">GCC 3.x with C and C++ language support</a> |
| 226 | |
| 227 | <li> |
| 228 | <a href="http://savannah.gnu.org/projects/make">GNU Make</a> |
| 229 | |
| 230 | <li> |
| 231 | <a href="http://www.gnu.org/software/flex">Flex</a> |
| 232 | |
| 233 | <li> |
| 234 | <a href="http://www.gnu.org/software/bison/bison.html">Bison</a> |
| 235 | </ul> |
| 236 | |
| 237 | <p> |
| 238 | There are some additional tools that you may want to have when working with |
| 239 | LLVM: |
| 240 | </p> |
| 241 | |
| 242 | <ul> |
| 243 | <li><A href="http://www.gnu.org/software/autoconf">GNU Autoconf</A> |
| 244 | <li><A href="http://savannah.gnu.org/projects/m4">GNU M4</A> |
| 245 | <p> |
| 246 | If you want to make changes to the configure scripts, you will need |
| 247 | GNU autoconf (2.57 or higher), and consequently, GNU M4 (version 1.4 |
| 248 | or higher). |
| 249 | </p> |
| 250 | |
| 251 | <li><A href="http://www.codesourcery.com/qm/qmtest">QMTest</A> |
| 252 | <li><A href="http://www.python.org">Python</A> |
| 253 | <p> |
| 254 | These are needed to use the LLVM test suite. |
| 255 | </ul> |
| 256 | |
| 257 | |
| 258 | <p>The remainder of this guide is meant to get you up and running with |
| 259 | LLVM and to give you some basic information about the LLVM environment. |
| 260 | A <a href="#starting">complete guide to installation</a> is provided in the |
| 261 | next section. |
| 262 | |
| 263 | <p>The later sections of this guide describe the <a |
| 264 | href="#layout">general layout</a> of the the LLVM source tree, a <a |
| 265 | href="#tutorial">simple example</a> using the LLVM tool chain, and <a |
| 266 | href="#links">links</a> to find more information about LLVM or to get |
| 267 | help via e-mail. |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 268 | |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 269 | <!--=====================================================================--> |
| 270 | <center> |
| 271 | <h2><a name="starting"><b>Getting Started with LLVM</b></a></h2> |
| 272 | </center> |
| 273 | <hr> |
| 274 | <!--=====================================================================--> |
| 275 | |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 276 | <!-------------------------------------------------------------------------> |
| 277 | <h3><a name="terminology">Terminology and Notation</a></h3> |
| 278 | <!-------------------------------------------------------------------------> |
| 279 | |
| 280 | <p>Throughout this manual, the following names are used to denote paths |
| 281 | specific to the local system and working environment. <i>These are not |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 282 | environment variables you need to set but just strings used in the rest |
| 283 | of this document below</i>. In any of the examples below, simply replace |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 284 | each of these names with the appropriate pathname on your local system. |
Chris Lattner | 1db872d | 2002-09-06 16:26:13 +0000 | [diff] [blame] | 285 | All these paths are absolute:</p> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 286 | <dl compact> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 287 | <dt>SRC_ROOT |
| 288 | <dd> |
| 289 | This is the top level directory of the LLVM source tree. |
| 290 | <p> |
| 291 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 292 | <dt>OBJ_ROOT |
| 293 | <dd> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 294 | This is the top level directory of the LLVM object tree (i.e. the |
| 295 | tree where object files and compiled programs will be placed. It |
| 296 | can be the same as SRC_ROOT). |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 297 | <p> |
| 298 | |
| 299 | <dt>LLVMGCCDIR |
| 300 | <dd> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 301 | This is the where the LLVM GCC Front End is installed. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 302 | <p> |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 303 | For the pre-built GCC front end binaries, the LLVMGCCDIR is |
John Criswell | a27028b | 2003-07-03 16:49:40 +0000 | [diff] [blame] | 304 | <tt>cfrontend/<i>platform</i>/llvm-gcc</tt>. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 305 | </dl> |
| 306 | |
| 307 | <!-------------------------------------------------------------------------> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 308 | <h3><a name="environment">Setting Up Your Environment</a></h3> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 309 | <!-------------------------------------------------------------------------> |
| 310 | |
| 311 | <p> |
| 312 | In order to compile and use LLVM, you will need to set some environment |
| 313 | variables. There are also some shell aliases which you may find useful. |
| 314 | You can set these on the command line, or better yet, set them in your |
| 315 | <tt>.cshrc</tt> or <tt>.profile</tt>. |
| 316 | |
| 317 | <dl compact> |
| 318 | <dt><tt>LLVM_LIB_SEARCH_PATH</tt>=<tt><i>LLVMGCCDIR</i>/llvm-gcc/bytecode-libs</tt> |
| 319 | <dd> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 320 | This environment variable helps the LLVM GCC front end find bytecode |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 321 | libraries that it will need for compilation. |
| 322 | <p> |
| 323 | |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 324 | <dt>alias llvmgcc <i>LLVMGCCDIR</i><tt>/llvm-gcc/bin/gcc</tt> |
| 325 | <dt>alias llvmg++ <i>LLVMGCCDIR</i><tt>/llvm-gcc/bin/g++</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 326 | <dd> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 327 | This alias allows you to use the LLVM C and C++ front ends without putting |
| 328 | them in your <tt>PATH</tt> or typing in their complete pathnames. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 329 | </dl> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 330 | |
| 331 | <!-------------------------------------------------------------------------> |
John Criswell | 312a68c | 2003-07-07 19:27:35 +0000 | [diff] [blame] | 332 | <h3><a name="unpack">Unpacking the LLVM Archives</a></h3> |
| 333 | <!-------------------------------------------------------------------------> |
| 334 | |
| 335 | <p> |
| 336 | If you have the LLVM distribution, you will need to unpack it before you |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 337 | can begin to compile it. LLVM is distributed as a set of three files. Each |
John Criswell | 312a68c | 2003-07-07 19:27:35 +0000 | [diff] [blame] | 338 | file is a TAR archive that is compressed with the gzip program. |
| 339 | </p> |
| 340 | |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 341 | <p> The three files are as follows: |
John Criswell | 312a68c | 2003-07-07 19:27:35 +0000 | [diff] [blame] | 342 | <dl compact> |
| 343 | <dt>llvm.tar.gz |
| 344 | <dd>This is the source code to the LLVM suite. |
| 345 | <p> |
| 346 | |
| 347 | <dt>cfrontend.sparc.tar.gz |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 348 | <dd>This is the binary release of the GCC front end for Solaris/Sparc. |
John Criswell | 312a68c | 2003-07-07 19:27:35 +0000 | [diff] [blame] | 349 | <p> |
| 350 | |
| 351 | <dt>cfrontend.x86.tar.gz |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 352 | <dd>This is the binary release of the GCC front end for Linux/x86. |
John Criswell | 312a68c | 2003-07-07 19:27:35 +0000 | [diff] [blame] | 353 | </dl> |
| 354 | |
John Criswell | 312a68c | 2003-07-07 19:27:35 +0000 | [diff] [blame] | 355 | <!-------------------------------------------------------------------------> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 356 | <h3><a name="checkout">Checkout LLVM from CVS</a></h3> |
| 357 | <!-------------------------------------------------------------------------> |
| 358 | |
John Criswell | 312a68c | 2003-07-07 19:27:35 +0000 | [diff] [blame] | 359 | <p>If you have access to our CVS repository, you can get a fresh copy of |
| 360 | the entire source code. All you need to do is check it out from CVS as |
| 361 | follows: |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 362 | <ul> |
| 363 | <li><tt>cd <i>where-you-want-llvm-to-live</i></tt> |
John Criswell | e04c263 | 2003-10-21 21:24:38 +0000 | [diff] [blame] | 364 | <li><tt>cvs -d :pserver:anon@llvm-cvs.cs.uiuc.edu:/var/cvs/llvm login</tt> |
| 365 | <li>Hit the return key when prompted for the password. |
Chris Lattner | 70bb09b | 2003-10-23 19:49:01 +0000 | [diff] [blame] | 366 | <li><tt>cvs -z3 -d :pserver:anon@llvm-cvs.cs.uiuc.edu:/var/cvs/llvm co llvm</tt> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 367 | </ul> |
| 368 | |
| 369 | <p>This will create an '<tt>llvm</tt>' directory in the current |
| 370 | directory and fully populate it with the LLVM source code, Makefiles, |
| 371 | test directories, and local copies of documentation files.</p> |
| 372 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 373 | <p> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 374 | Note that the GCC front end is not included in the CVS repository. You |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 375 | should have downloaded the binary distribution for your platform. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 376 | </p> |
| 377 | |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 378 | <!-------------------------------------------------------------------------> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 379 | <h3><a name="installcf">Install the GCC Front End</a></h3> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 380 | <!-------------------------------------------------------------------------> |
| 381 | |
| 382 | <p> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 383 | Before configuring and compiling the LLVM suite, you need to extract the |
John Criswell | 0f6d7c0 | 2003-10-27 18:18:16 +0000 | [diff] [blame^] | 384 | LLVM GCC front end from the binary distribution. It is used for building |
| 385 | the |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 386 | bytecode libraries later used by the GCC front end for linking programs, and |
| 387 | its location must be specified when the LLVM suite is configured. |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 388 | </p> |
| 389 | |
| 390 | <p> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 391 | To install the GCC front end, do the following: |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 392 | <ol> |
| 393 | <li><tt>cd <i>where-you-want-the-front-end-to-live</i></tt> |
| 394 | <li><tt>gunzip --stdout cfrontend.<i>platform</i>.tar.gz | tar -xvf |
| 395 | -</tt> |
| 396 | </ol> |
| 397 | |
John Criswell | 0f6d7c0 | 2003-10-27 18:18:16 +0000 | [diff] [blame^] | 398 | If you are on a Sparc/Solaris machine, you will need to fix the header |
| 399 | files: |
| 400 | |
| 401 | <p> |
| 402 | |
| 403 | <tt> |
| 404 | cd cfrontend/sparc |
| 405 | <br> |
| 406 | ./fixheaders |
| 407 | </tt> |
| 408 | |
| 409 | <p> |
| 410 | The binary versions of the GCC front end may not suit all of your needs. |
| 411 | For example, the binary distribution may include an old version of a system |
| 412 | header file, not "fix" a header file that needs to be fixed for GCC, or it |
| 413 | may be linked with libraries not available on your system. |
| 414 | </p> |
| 415 | |
| 416 | <p> |
| 417 | In cases like these, you may want to try |
| 418 | <a href="CFEBuildInstrs.html">building the GCC front end from source.</a> |
| 419 | This is not for the faint of heart, so be forewarned. |
| 420 | </p> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 421 | <!-------------------------------------------------------------------------> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 422 | <h3><a name="config">Local LLVM Configuration</a></h3> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 423 | <!-------------------------------------------------------------------------> |
| 424 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 425 | <p>Once checked out from the CVS repository, the LLVM suite source code |
| 426 | must be configured via the <tt>configure</tt> script. This script sets |
| 427 | variables in <tt>llvm/Makefile.config</tt> and |
John Criswell | e04c263 | 2003-10-21 21:24:38 +0000 | [diff] [blame] | 428 | <tt>llvm/include/Config/config.h</tt>. It also populates <i>OBJ_ROOT</i> |
| 429 | with the Makefiles needed to build LLVM. |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 430 | |
| 431 | <p> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 432 | The following environment variables are used by the <tt>configure</tt> |
| 433 | script to configure the build system: |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 434 | </p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 435 | |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 436 | <table border=1> |
| 437 | <tr> |
| 438 | <th>Variable</th> |
| 439 | <th> |
| 440 | Purpose |
| 441 | </th> |
| 442 | </tr> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 443 | |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 444 | <tr> |
| 445 | <td>CC</td> |
| 446 | <td> |
| 447 | Tells <tt>configure</tt> which C compiler to use. By default, |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 448 | <tt>configure</tt> will look for the first GCC C compiler in |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 449 | <tt>PATH</tt>. Use this variable to override |
| 450 | <tt>configure</tt>'s default behavior. |
| 451 | </td> |
| 452 | </tr> |
| 453 | |
| 454 | <tr> |
| 455 | <td>CXX</td> |
| 456 | <td> |
| 457 | Tells <tt>configure</tt> which C++ compiler to use. By default, |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 458 | <tt>configure</tt> will look for the first GCC C++ compiler in |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 459 | <tt>PATH</tt>. Use this variable to override |
| 460 | <tt>configure</tt>'s default behavior. |
| 461 | </td> |
| 462 | </tr> |
| 463 | </table> |
| 464 | |
| 465 | <p> |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 466 | The following options can be used to set or enable LLVM specific options: |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 467 | </p> |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 468 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 469 | <dl compact> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 470 | <dt><i>--with-llvmgccdir=LLVMGCCDIR</i> |
| 471 | <dd> |
| 472 | Path to the location where the LLVM C front end binaries and |
| 473 | associated libraries will be installed. |
| 474 | <p> |
| 475 | <dt><i>--enable-optimized</i> |
| 476 | <dd> |
John Criswell | 623e594 | 2003-10-10 18:51:11 +0000 | [diff] [blame] | 477 | Enables optimized compilation by default (debugging symbols are removed |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 478 | and GCC optimization flags are enabled). The default is to use an |
| 479 | unoptimized build (also known as a debug build). |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 480 | <p> |
| 481 | <dt><i>--enable-jit</i> |
| 482 | <dd> |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 483 | Compile the Just In Time (JIT) functionality. This is not available |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 484 | on all platforms. The default is dependent on platform, so it is best |
| 485 | to explicitly enable it if you want it. |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 486 | <p> |
| 487 | <dt><i>--enable-spec2000</i> |
| 488 | <dt><i>--enable-spec2000=<<tt>directory</tt>></i> |
| 489 | <dd> |
| 490 | Enable the use of SPEC2000 when testing LLVM. This is disabled by default |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 491 | (unless <tt>configure</tt> finds SPEC2000 installed). By specifying |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 492 | <tt>directory</tt>, you can tell configure where to find the SPEC2000 |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 493 | benchmarks. If <tt>directory</tt> is left unspecified, <tt>configure</tt> |
| 494 | uses the default value |
| 495 | <tt>/home/vadve/shared/benchmarks/speccpu2000/benchspec</tt>. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 496 | </dl> |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 497 | |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 498 | <p> |
| 499 | To configure LLVM, follow these steps: |
| 500 | <ol> |
| 501 | <li>Change directory into the object root directory: |
| 502 | <br> |
| 503 | <tt>cd <i>OBJ_ROOT</i></tt> |
| 504 | <p> |
| 505 | |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 506 | <li>Run the <tt>configure</tt> script located in the LLVM source tree: |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 507 | <br> |
| 508 | <tt><i>SRC_ROOT</i>/configure</tt> |
| 509 | <p> |
| 510 | </ol> |
| 511 | </p> |
| 512 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 513 | In addition to running <tt>configure</tt>, you must set the |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 514 | <tt>LLVM_LIB_SEARCH_PATH</tt> environment variable in your startup scripts. |
| 515 | This environment variable is used to locate "system" libraries like |
| 516 | "<tt>-lc</tt>" and "<tt>-lm</tt>" when linking. This variable should be set |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 517 | to the absolute path for the bytecode-libs subdirectory of the GCC front end |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 518 | install, or <i>LLVMGCCDIR</i>/llvm-gcc/bytecode-libs. For example, one might |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 519 | set <tt>LLVM_LIB_SEARCH_PATH</tt> to |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 520 | <tt>/home/vadve/lattner/local/x86/llvm-gcc/bytecode-libs</tt> for the X86 |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 521 | version of the GCC front end on our research machines.<p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 522 | |
| 523 | <!-------------------------------------------------------------------------> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 524 | <h3><a name="compile">Compiling the LLVM Suite Source Code</a></h3> |
| 525 | <!-------------------------------------------------------------------------> |
| 526 | |
| 527 | Once you have configured LLVM, you can build it. There are three types of |
| 528 | builds: |
| 529 | |
| 530 | <dl compact> |
| 531 | <dt>Debug Builds |
| 532 | <dd> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 533 | These builds are the default when one types <tt>gmake</tt> (unless the |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 534 | <tt>--enable-optimized</tt> option was used during configuration). The |
| 535 | build system will compile the tools and libraries with debugging |
| 536 | information. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 537 | <p> |
| 538 | |
| 539 | <dt>Release (Optimized) Builds |
| 540 | <dd> |
| 541 | These builds are enabled with the <tt>--enable-optimized</tt> option to |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 542 | <tt>configure</tt> or by specifying <tt>ENABLE_OPTIMIZED=1</tt> on the |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 543 | <tt>gmake</tt> command line. For these builds, the build system will |
| 544 | compile the tools and libraries with GCC optimizations enabled and strip |
| 545 | debugging information from the libraries and executables it generates. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 546 | <p> |
| 547 | |
| 548 | <dt>Profile Builds |
| 549 | <dd> |
| 550 | These builds are for use with profiling. They compile profiling |
| 551 | information into the code for use with programs like <tt>gprof</tt>. |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 552 | Profile builds must be started by specifying <tt>ENABLE_PROFILING=1</tt> |
| 553 | on the <tt>gmake</tt> command line. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 554 | </dl> |
| 555 | |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 556 | Once you have LLVM configured, you can build it by entering the |
| 557 | <i>OBJ_ROOT</i> directory and issuing the following command: |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 558 | <p> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 559 | <tt>gmake</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 560 | |
| 561 | <p> |
| 562 | If you have multiple processors in your machine, you may wish to use some |
| 563 | of the parallel build options provided by GNU Make. For example, you could |
| 564 | use the command: |
| 565 | </p> |
| 566 | |
| 567 | <p> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 568 | <tt>gmake -j2</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 569 | |
| 570 | <p> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 571 | There are several special targets which are useful when working with the LLVM |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 572 | source code: |
| 573 | |
| 574 | <dl compact> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 575 | <dt><tt>gmake clean</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 576 | <dd> |
| 577 | Removes all files generated by the build. This includes object files, |
| 578 | generated C/C++ files, libraries, and executables. |
| 579 | <p> |
| 580 | |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 581 | <dt><tt>gmake distclean</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 582 | <dd> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 583 | Removes everything that <tt>gmake clean</tt> does, but also removes |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 584 | files generated by <tt>configure</tt>. It attempts to return the |
| 585 | source tree to the original state in which it was shipped. |
| 586 | <p> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 587 | |
| 588 | <dt><tt>gmake install</tt> |
| 589 | <dd> |
| 590 | Installs LLVM files into the proper location. For the most part, |
| 591 | this does nothing, but it does install bytecode libraries into the |
| 592 | GCC front end's bytecode library directory. If you need to update |
| 593 | your bytecode libraries, this is the target to use once you've built |
| 594 | them. |
| 595 | <p> |
| 596 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 597 | </dl> |
| 598 | |
| 599 | It is also possible to override default values from <tt>configure</tt> by |
| 600 | declaring variables on the command line. The following are some examples: |
| 601 | |
| 602 | <dl compact> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 603 | <dt><tt>gmake ENABLE_OPTIMIZED=1</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 604 | <dd> |
| 605 | Perform a Release (Optimized) build. |
| 606 | <p> |
| 607 | |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 608 | <dt><tt>gmake ENABLE_PROFILING=1</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 609 | <dd> |
| 610 | Perform a Profiling build. |
| 611 | <p> |
| 612 | |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 613 | <dt><tt>gmake VERBOSE=1</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 614 | <dd> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 615 | Print what <tt>gmake</tt> is doing on standard output. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 616 | <p> |
| 617 | </dl> |
| 618 | |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 619 | Every directory in the LLVM object tree includes a <tt>Makefile</tt> to |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 620 | build it and any subdirectories that it contains. Entering any directory |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 621 | inside the LLVM object tree and typing <tt>gmake</tt> should rebuild |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 622 | anything in or below that directory that is out of date. |
| 623 | |
| 624 | <!-------------------------------------------------------------------------> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 625 | <h3><a name="objfiles">The Location of LLVM Object Files</a></h3> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 626 | <!-------------------------------------------------------------------------> |
| 627 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 628 | <p> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 629 | The LLVM build system is capable of sharing a single LLVM source tree among |
| 630 | several LLVM builds. Hence, it is possible to build LLVM for several |
| 631 | different platforms or configurations using the same source tree. |
John Criswell | ef0096f | 2003-08-08 22:36:30 +0000 | [diff] [blame] | 632 | <p> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 633 | This is accomplished in the typical autoconf manner: |
| 634 | <ul> |
| 635 | <li>Change directory to where the LLVM object files should live: |
| 636 | <p> |
| 637 | <tt>cd <i>OBJ_ROOT</i></tt> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 638 | |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 639 | <li>Run the <tt>configure</tt> script found in the LLVM source directory: |
| 640 | <p> |
| 641 | <tt><i>SRC_ROOT</i>/configure</tt> |
| 642 | </ul> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 643 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 644 | <p> |
| 645 | The LLVM build will place files underneath <i>OBJ_ROOT</i> in directories |
| 646 | named after the build type: |
| 647 | </p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 648 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 649 | <dl compact> |
| 650 | <dt>Debug Builds |
| 651 | <dd> |
| 652 | <dl compact> |
| 653 | <dt>Tools |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 654 | <dd><tt><i>OBJ_ROOT</i>/tools/Debug</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 655 | <dt>Libraries |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 656 | <dd><tt><i>OBJ_ROOT</i>/lib/Debug</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 657 | </dl> |
| 658 | <p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 659 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 660 | <dt>Release Builds |
| 661 | <dd> |
| 662 | <dl compact> |
| 663 | <dt>Tools |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 664 | <dd><tt><i>OBJ_ROOT</i>/tools/Release</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 665 | <dt>Libraries |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 666 | <dd><tt><i>OBJ_ROOT</i>/lib/Release</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 667 | </dl> |
| 668 | <p> |
Chris Lattner | 7fe7f81 | 2002-07-24 19:51:14 +0000 | [diff] [blame] | 669 | |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 670 | <dt>Profile Builds |
| 671 | <dd> |
| 672 | <dl compact> |
| 673 | <dt>Tools |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 674 | <dd><tt><i>OBJ_ROOT</i>/tools/Profile</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 675 | <dt>Libraries |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 676 | <dd><tt><i>OBJ_ROOT</i>/lib/Profile</tt> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 677 | </dl> |
| 678 | </dl> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 679 | |
| 680 | <!--=====================================================================--> |
| 681 | <center> |
| 682 | <h2><a name="layout"><b>Program Layout</b></a></h2> |
| 683 | </center> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 684 | <hr> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 685 | <!--=====================================================================--> |
| 686 | |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 687 | <p> |
| 688 | One useful source of information about the LLVM source base is the LLVM <a |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 689 | href="http://www.doxygen.org">doxygen</a> documentation, available at <tt><a |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 690 | href="http://llvm.cs.uiuc.edu/doxygen/">http://llvm.cs.uiuc.edu/doxygen/</a></tt>. |
| 691 | The following is a brief introduction to code layout: |
| 692 | </p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 693 | |
| 694 | <!-------------------------------------------------------------------------> |
| 695 | <h3><a name="cvsdir"><tt>CVS</tt> directories</a></h3> |
| 696 | <!-------------------------------------------------------------------------> |
| 697 | |
| 698 | Every directory checked out of CVS will contain a <tt>CVS</tt> directory; |
| 699 | for the most part these can just be ignored. |
| 700 | |
| 701 | |
| 702 | <!-------------------------------------------------------------------------> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 703 | <h3><a name="include"><tt>llvm/include</tt></a></h3> |
| 704 | <!-------------------------------------------------------------------------> |
| 705 | |
| 706 | This directory contains public header files exported from the LLVM |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 707 | library. The three main subdirectories of this directory are:<p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 708 | |
John Criswell | 8df90e0 | 2003-06-11 20:46:40 +0000 | [diff] [blame] | 709 | <ol> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 710 | <li><tt>llvm/include/llvm</tt> - This directory contains all of the LLVM |
| 711 | specific header files. This directory also has subdirectories for |
| 712 | different portions of LLVM: <tt>Analysis</tt>, <tt>CodeGen</tt>, |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 713 | <tt>Target</tt>, <tt>Transforms</tt>, etc... |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 714 | |
| 715 | <li><tt>llvm/include/Support</tt> - This directory contains generic |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 716 | support libraries that are independent of LLVM, but are used by LLVM. |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 717 | For example, some C++ STL utilities and a Command Line option processing |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 718 | library store their header files here. |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 719 | |
| 720 | <li><tt>llvm/include/Config</tt> - This directory contains header files |
| 721 | configured by the <tt>configure</tt> script. They wrap "standard" UNIX |
| 722 | and C header files. Source code can include these header files which |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 723 | automatically take care of the conditional #includes that the |
| 724 | <tt>configure</tt> script generates. |
Chris Lattner | 7fe7f81 | 2002-07-24 19:51:14 +0000 | [diff] [blame] | 725 | </ol> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 726 | |
| 727 | <!-------------------------------------------------------------------------> |
| 728 | <h3><a name="lib"><tt>llvm/lib</tt></a></h3> |
| 729 | <!-------------------------------------------------------------------------> |
| 730 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 731 | This directory contains most of the source files of the LLVM system. In |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 732 | LLVM, almost all |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 733 | code exists in libraries, making it very easy to share code among the |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 734 | different <a href="#tools">tools</a>.<p> |
| 735 | |
| 736 | <dl compact> |
| 737 | <dt><tt>llvm/lib/VMCore/</tt><dd> This directory holds the core LLVM |
| 738 | source files that implement core classes like Instruction and BasicBlock. |
| 739 | |
| 740 | <dt><tt>llvm/lib/AsmParser/</tt><dd> This directory holds the source code |
| 741 | for the LLVM assembly language parser library. |
| 742 | |
| 743 | <dt><tt>llvm/lib/ByteCode/</tt><dd> This directory holds code for reading |
| 744 | and write LLVM bytecode. |
| 745 | |
| 746 | <dt><tt>llvm/lib/CWriter/</tt><dd> This directory implements the LLVM to C |
| 747 | converter. |
| 748 | |
| 749 | <dt><tt>llvm/lib/Analysis/</tt><dd> This directory contains a variety of |
| 750 | different program analyses, such as Dominator Information, Call Graphs, |
| 751 | Induction Variables, Interval Identification, Natural Loop Identification, |
| 752 | etc... |
| 753 | |
| 754 | <dt><tt>llvm/lib/Transforms/</tt><dd> This directory contains the source |
| 755 | code for the LLVM to LLVM program transformations, such as Aggressive Dead |
| 756 | Code Elimination, Sparse Conditional Constant Propagation, Inlining, Loop |
John Criswell | 623e594 | 2003-10-10 18:51:11 +0000 | [diff] [blame] | 757 | Invariant Code Motion, Dead Global Elimination, and many others... |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 758 | |
| 759 | <dt><tt>llvm/lib/Target/</tt><dd> This directory contains files that |
| 760 | describe various target architectures for code generation. For example, |
| 761 | the llvm/lib/Target/Sparc directory holds the Sparc machine |
| 762 | description.<br> |
| 763 | |
| 764 | <dt><tt>llvm/lib/CodeGen/</tt><dd> This directory contains the major parts |
| 765 | of the code generator: Instruction Selector, Instruction Scheduling, and |
| 766 | Register Allocation. |
| 767 | |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 768 | <dt><tt>llvm/lib/Support/</tt><dd> This directory contains the source code |
| 769 | that corresponds to the header files located in |
| 770 | <tt>llvm/include/Support/</tt>. |
| 771 | </dl> |
| 772 | |
| 773 | <!-------------------------------------------------------------------------> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 774 | <h3><a name="runtime"><tt>llvm/runtime</tt></a></h3> |
| 775 | <!-------------------------------------------------------------------------> |
| 776 | |
| 777 | <p> |
| 778 | This directory contains libraries which are compiled into LLVM bytecode and |
| 779 | used when linking programs with the GCC front end. Most of these libraries |
| 780 | are skeleton versions of real libraries; for example, libc is a stripped down |
| 781 | version of glibc. |
| 782 | </p> |
| 783 | |
| 784 | <p> |
| 785 | Unlike the rest of the LLVM suite, this directory needs the LLVM GCC front end |
| 786 | to compile. |
| 787 | </p> |
| 788 | |
| 789 | <!-------------------------------------------------------------------------> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 790 | <h3><a name="test"><tt>llvm/test</tt></a></h3> |
| 791 | <!-------------------------------------------------------------------------> |
| 792 | |
| 793 | <p>This directory contains regression tests and source code that is used to |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 794 | test the LLVM infrastructure. |
| 795 | </p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 796 | |
| 797 | <!-------------------------------------------------------------------------> |
| 798 | <h3><a name="tools"><tt>llvm/tools</tt></a></h3> |
| 799 | <!-------------------------------------------------------------------------> |
| 800 | |
| 801 | <p>The <b>tools</b> directory contains the executables built out of the |
| 802 | libraries above, which form the main part of the user interface. You can |
| 803 | always get help for a tool by typing <tt>tool_name --help</tt>. The |
| 804 | following is a brief introduction to the most important tools.</p> |
| 805 | |
| 806 | <dl compact> |
Misha Brukman | ef0ad41 | 2003-10-06 19:23:34 +0000 | [diff] [blame] | 807 | <dt> |
| 808 | |
| 809 | <dt><tt><b>analyze</b></tt><dd> <tt>analyze</tt> is used to run a specific |
| 810 | analysis on an input LLVM bytecode file and print out the results. It is |
| 811 | primarily useful for debugging analyses, or familiarizing yourself with |
| 812 | what an analysis does.<p> |
| 813 | |
| 814 | <dt><tt><b>bugpoint</b></tt><dd> <tt>bugpoint</tt> is used to debug |
| 815 | optimization passes or code generation backends by narrowing down the |
| 816 | given test case to the minimum number of passes and/or instructions that |
| 817 | still cause a problem, whether it is a crash or miscompilation. See <a |
| 818 | href="HowToSubmitABug.html">HowToSubmitABug.html</a> for more information |
| 819 | on using <tt>bugpoint</tt>.<p> |
| 820 | |
| 821 | <dt><tt><b>llvm-ar</b></tt><dd>The archiver produces an archive containing |
| 822 | the given LLVM bytecode files, optionally with an index for faster |
| 823 | lookup.<p> |
| 824 | |
Misha Brukman | a0a0a03 | 2003-08-28 22:02:50 +0000 | [diff] [blame] | 825 | <dt><tt><b>llvm-as</b></tt><dd>The assembler transforms the human readable |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 826 | LLVM assembly to LLVM bytecode.<p> |
| 827 | |
Misha Brukman | a0a0a03 | 2003-08-28 22:02:50 +0000 | [diff] [blame] | 828 | <dt><tt><b>llvm-dis</b></tt><dd>The disassembler transforms the LLVM |
Misha Brukman | ef0ad41 | 2003-10-06 19:23:34 +0000 | [diff] [blame] | 829 | bytecode to human readable LLVM assembly. Additionally, it can convert |
Misha Brukman | a0a0a03 | 2003-08-28 22:02:50 +0000 | [diff] [blame] | 830 | LLVM bytecode to C, which is enabled with the <tt>-c</tt> option.<p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 831 | |
Misha Brukman | ef0ad41 | 2003-10-06 19:23:34 +0000 | [diff] [blame] | 832 | <dt><tt><b>llvm-link</b></tt><dd> <tt>llvm-link</tt>, not surprisingly, |
| 833 | links multiple LLVM modules into a single program.<p> |
| 834 | |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 835 | <dt><tt><b>lli</b></tt><dd> <tt>lli</tt> is the LLVM interpreter, which |
| 836 | can directly execute LLVM bytecode (although very slowly...). In addition |
Misha Brukman | ef0ad41 | 2003-10-06 19:23:34 +0000 | [diff] [blame] | 837 | to a simple interpreter, <tt>lli</tt> also has a tracing mode (entered by |
| 838 | specifying <tt>-trace</tt> on the command line). Finally, for |
| 839 | architectures that support it (currently only x86 and Sparc), by default, |
| 840 | <tt>lli</tt> will function as a Just-In-Time compiler (if the |
| 841 | functionality was compiled in), and will execute the code <i>much</i> |
| 842 | faster than the interpreter.<p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 843 | |
| 844 | <dt><tt><b>llc</b></tt><dd> <tt>llc</tt> is the LLVM backend compiler, |
Misha Brukman | c56e582 | 2003-07-03 16:29:36 +0000 | [diff] [blame] | 845 | which translates LLVM bytecode to a SPARC or x86 assembly file.<p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 846 | |
Misha Brukman | ef0ad41 | 2003-10-06 19:23:34 +0000 | [diff] [blame] | 847 | <dt><tt><b>llvmgcc</b></tt><dd> <tt>llvmgcc</tt> is a GCC-based C frontend |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 848 | that has been retargeted to emit LLVM code as the machine code output. It |
| 849 | works just like any other GCC compiler, taking the typical <tt>-c, -S, -E, |
| 850 | -o</tt> options that are typically used. The source code for the |
Chris Lattner | 70bb09b | 2003-10-23 19:49:01 +0000 | [diff] [blame] | 851 | <tt>llvmgcc</tt> tool is currently not included in the LLVM CVS tree |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 852 | because it is quite large and not very interesting.<p> |
| 853 | |
| 854 | <ol> |
| 855 | <dt><tt><b>gccas</b></tt><dd> This tool is invoked by the |
| 856 | <tt>llvmgcc</tt> frontend as the "assembler" part of the compiler. This |
| 857 | tool actually assembles LLVM assembly to LLVM bytecode, |
Misha Brukman | ef0ad41 | 2003-10-06 19:23:34 +0000 | [diff] [blame] | 858 | performs a variety of optimizations, and outputs LLVM bytecode. Thus |
| 859 | when you invoke <tt>llvmgcc -c x.c -o x.o</tt>, you are causing |
| 860 | <tt>gccas</tt> to be run, which writes the <tt>x.o</tt> file (which is |
| 861 | an LLVM bytecode file that can be disassembled or manipulated just like |
| 862 | any other bytecode file). The command line interface to <tt>gccas</tt> |
| 863 | is designed to be as close as possible to the <b>system</b> |
| 864 | `<tt>as</tt>' utility so that the gcc frontend itself did not have to be |
| 865 | modified to interface to a "weird" assembler.<p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 866 | |
| 867 | <dt><tt><b>gccld</b></tt><dd> <tt>gccld</tt> links together several LLVM |
| 868 | bytecode files into one bytecode file and does some optimization. It is |
John Criswell | abb1b58 | 2003-10-10 16:17:19 +0000 | [diff] [blame] | 869 | the linker invoked by the GCC frontend when multiple .o files need to be |
| 870 | linked together. Like <tt>gccas</tt>, the command line interface of |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 871 | <tt>gccld</tt> is designed to match the system linker, to aid |
| 872 | interfacing with the GCC frontend.<p> |
| 873 | </ol> |
| 874 | |
| 875 | <dt><tt><b>opt</b></tt><dd> <tt>opt</tt> reads LLVM bytecode, applies a |
| 876 | series of LLVM to LLVM transformations (which are specified on the command |
| 877 | line), and then outputs the resultant bytecode. The '<tt>opt --help</tt>' |
| 878 | command is a good way to get a list of the program transformations |
| 879 | available in LLVM.<p> |
| 880 | |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 881 | </dl> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 882 | |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 883 | <!-------------------------------------------------------------------------> |
| 884 | <h3><a name="utils"><tt>llvm/utils</tt></a></h3> |
| 885 | <!-------------------------------------------------------------------------> |
| 886 | |
John Criswell | 623e594 | 2003-10-10 18:51:11 +0000 | [diff] [blame] | 887 | This directory contains utilities for working with LLVM source code, and some |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 888 | of the utilities are actually required as part of the build process because |
| 889 | they are code generators for parts of LLVM infrastructure. |
| 890 | |
| 891 | <dl compact> |
Misha Brukman | e0db815 | 2003-08-11 19:13:12 +0000 | [diff] [blame] | 892 | <td><tt><b>Burg/</b></tt><dd> <tt>Burg</tt> is an instruction selector |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 893 | generator -- it builds trees on which it then performs pattern-matching to |
| 894 | select instructions according to the patterns the user has specified. Burg |
| 895 | is currently used in the Sparc V9 backend.<p> |
| 896 | |
| 897 | <dt><tt><b>codegen-diff</b></tt><dd> <tt>codegen-diff</tt> is a script |
| 898 | that finds differences between code that LLC generates and code that LLI |
| 899 | generates. This is a useful tool if you are debugging one of them, |
| 900 | assuming that the other generates correct output. For the full user |
| 901 | manual, run <tt>`perldoc codegen-diff'</tt>.<p> |
| 902 | |
| 903 | <dt><tt><b>cvsupdate</b></tt><dd> <tt>cvsupdate</tt> is a script that will |
| 904 | update your CVS tree, but produce a much cleaner and more organized output |
Chris Lattner | 70bb09b | 2003-10-23 19:49:01 +0000 | [diff] [blame] | 905 | than simply running <tt>`cvs -z3 up -dP'</tt> will. For example, it will group |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 906 | together all the new and updated files and modified files in separate |
| 907 | sections, so you can see at a glance what has changed. If you are at the |
| 908 | top of your LLVM CVS tree, running <tt>utils/cvsupdate</tt> is the |
| 909 | preferred way of updating the tree.<p> |
| 910 | |
Misha Brukman | e0db815 | 2003-08-11 19:13:12 +0000 | [diff] [blame] | 911 | <dt><tt><b>emacs/</b></tt><dd> The <tt>emacs</tt> directory contains |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 912 | syntax-highlighting files which will work with Emacs and XEmacs editors, |
| 913 | providing syntax highlighting support for LLVM assembly files and TableGen |
Misha Brukman | e0db815 | 2003-08-11 19:13:12 +0000 | [diff] [blame] | 914 | description files. For information on how to use the syntax files, consult |
| 915 | the <tt>README</tt> file in that directory.<p> |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 916 | |
| 917 | <dt><tt><b>getsrcs.sh</b></tt><dd> The <tt>getsrcs.sh</tt> script finds |
| 918 | and outputs all non-generated source files, which is useful if one wishes |
| 919 | to do a lot of development across directories and does not want to |
| 920 | individually find each file. One way to use it is to run, for example: |
| 921 | <tt>xemacs `utils/getsources.sh`</tt> from the top of your LLVM source |
| 922 | tree.<p> |
| 923 | |
| 924 | <dt><tt><b>makellvm</b></tt><dd> The <tt>makellvm</tt> script compiles all |
| 925 | files in the current directory and then compiles and links the tool that |
| 926 | is the first argument. For example, assuming you are in the directory |
| 927 | <tt>llvm/lib/Target/Sparc</tt>, if <tt>makellvm</tt> is in your path, |
| 928 | simply running <tt>makellvm llc</tt> will make a build of the current |
| 929 | directory, switch to directory <tt>llvm/tools/llc</tt> and build it, |
| 930 | causing a re-linking of LLC.<p> |
| 931 | |
| 932 | <dt><tt><b>NightlyTest.pl</b></tt> and |
| 933 | <tt><b>NightlyTestTemplate.html</b></tt><dd> These files are used in a |
| 934 | cron script to generate nightly status reports of the functionality of |
| 935 | tools, and the results can be seen by following the appropriate link on |
| 936 | the <a href="http://llvm.cs.uiuc.edu/">LLVM homepage</a>.<p> |
| 937 | |
Misha Brukman | e0db815 | 2003-08-11 19:13:12 +0000 | [diff] [blame] | 938 | <dt><tt><b>TableGen/</b></tt><dd> The <tt>TableGen</tt> directory contains |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 939 | the tool used to generate register descriptions, instruction set |
Chris Lattner | a8f5de3 | 2003-08-11 18:53:14 +0000 | [diff] [blame] | 940 | descriptions, and even assemblers from common TableGen description |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 941 | files.<p> |
| 942 | |
Misha Brukman | e0db815 | 2003-08-11 19:13:12 +0000 | [diff] [blame] | 943 | <dt><tt><b>vim/</b></tt><dd> The <tt>vim</tt> directory contains |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 944 | syntax-highlighting files which will work with the VIM editor, providing |
| 945 | syntax highlighting support for LLVM assembly files and TableGen |
Misha Brukman | e0db815 | 2003-08-11 19:13:12 +0000 | [diff] [blame] | 946 | description files. For information on how to use the syntax files, consult |
| 947 | the <tt>README</tt> file in that directory.<p> |
Misha Brukman | c103adf | 2003-08-11 18:45:46 +0000 | [diff] [blame] | 948 | |
| 949 | </dl> |
| 950 | |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 951 | <!--=====================================================================--> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 952 | <h2> |
| 953 | <center><a name="tutorial">An Example Using the LLVM Tool Chain</center> |
| 954 | </h2> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 955 | <hr> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 956 | <!--=====================================================================--> |
| 957 | |
| 958 | <ol> |
| 959 | <li>First, create a simple C file, name it 'hello.c': |
| 960 | <pre> |
| 961 | #include <stdio.h> |
| 962 | int main() { |
| 963 | printf("hello world\n"); |
| 964 | return 0; |
| 965 | } |
| 966 | </pre> |
| 967 | |
| 968 | <li>Next, compile the C file into a LLVM bytecode file:<p> |
| 969 | |
| 970 | <tt>% llvmgcc hello.c -o hello</tt><p> |
| 971 | |
| 972 | This will create two result files: <tt>hello</tt> and |
| 973 | <tt>hello.bc</tt>. The <tt>hello.bc</tt> is the LLVM bytecode that |
| 974 | corresponds the the compiled program and the library facilities that it |
| 975 | required. <tt>hello</tt> is a simple shell script that runs the bytecode |
| 976 | file with <tt>lli</tt>, making the result directly executable.<p> |
| 977 | |
| 978 | <li>Run the program. To make sure the program ran, execute one of the |
| 979 | following commands:<p> |
John Criswell | 8df90e0 | 2003-06-11 20:46:40 +0000 | [diff] [blame] | 980 | |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 981 | <tt>% ./hello</tt><p> |
| 982 | |
| 983 | or<p> |
| 984 | |
| 985 | <tt>% lli hello.bc</tt><p> |
| 986 | |
Misha Brukman | a0a0a03 | 2003-08-28 22:02:50 +0000 | [diff] [blame] | 987 | <li>Use the <tt>llvm-dis</tt> utility to take a look at the LLVM assembly |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 988 | code:<p> |
| 989 | |
Misha Brukman | a0a0a03 | 2003-08-28 22:02:50 +0000 | [diff] [blame] | 990 | <tt>% llvm-dis < hello.bc | less</tt><p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 991 | |
| 992 | <li>Compile the program to native Sparc assembly using the code |
Misha Brukman | c56e582 | 2003-07-03 16:29:36 +0000 | [diff] [blame] | 993 | generator (assuming you are currently on a Sparc system):<p> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 994 | |
| 995 | <tt>% llc hello.bc -o hello.s</tt><p> |
| 996 | |
| 997 | <li>Assemble the native sparc assemble file into a program:<p> |
| 998 | |
| 999 | <tt>% /opt/SUNWspro/bin/cc -xarch=v9 hello.s -o hello.sparc</tt><p> |
| 1000 | |
| 1001 | <li>Execute the native sparc program:<p> |
| 1002 | |
| 1003 | <tt>% ./hello.sparc</tt><p> |
| 1004 | |
| 1005 | </ol> |
| 1006 | |
| 1007 | |
| 1008 | <!--=====================================================================--> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 1009 | <h2> |
| 1010 | <center><a name="problems">Common Problems</a></center> |
| 1011 | </h2> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 1012 | <hr> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 1013 | <!--=====================================================================--> |
| 1014 | |
John Criswell | b96646f | 2003-10-13 16:16:25 +0000 | [diff] [blame] | 1015 | If you are having problems building or using LLVM, or if you have any other |
| 1016 | general questions about LLVM, please consult the |
John Criswell | b5ca43e | 2003-10-13 16:19:30 +0000 | [diff] [blame] | 1017 | <a href="FAQ.html">Frequently Asked Questions</a> page. |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 1018 | |
| 1019 | <!--=====================================================================--> |
John Criswell | 0b45920 | 2003-07-08 20:35:59 +0000 | [diff] [blame] | 1020 | <h2><center><a name="links">Links</a></center></h2> |
John Criswell | 20d2d3e | 2003-10-10 14:26:14 +0000 | [diff] [blame] | 1021 | <hr> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 1022 | <!--=====================================================================--> |
| 1023 | |
| 1024 | <p>This document is just an <b>introduction</b> to how to use LLVM to do |
| 1025 | some simple things... there are many more interesting and complicated things |
| 1026 | that you can do that aren't documented here (but we'll gladly accept a patch |
| 1027 | if you want to write something up!). For more information about LLVM, check |
| 1028 | out:</p> |
| 1029 | |
| 1030 | <ul> |
| 1031 | <li><a href="http://llvm.cs.uiuc.edu/">LLVM homepage</a></li> |
| 1032 | <li><a href="http://llvm.cs.uiuc.edu/doxygen/">LLVM doxygen tree</a></li> |
John Criswell | ce760f6 | 2003-07-03 16:01:38 +0000 | [diff] [blame] | 1033 | <li><a href="http://llvm.cs.uiuc.edu/docs/Projects.html">Starting a Project that Uses LLVM</a></li> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 1034 | </ul> |
| 1035 | |
| 1036 | <hr> |
| 1037 | |
| 1038 | If you have any questions or run into any snags (or you have any |
| 1039 | additions...), please send an email to |
| 1040 | <a href="mailto:sabre@nondot.org">Chris Lattner</a>.</p> |
John Criswell | 0f6d7c0 | 2003-10-27 18:18:16 +0000 | [diff] [blame^] | 1041 | <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a> |
| 1042 | <br> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 1043 | |
John Criswell | 0f6d7c0 | 2003-10-27 18:18:16 +0000 | [diff] [blame^] | 1044 | <!-- Created: Mon Jul 1 02:29:02 CDT 2002 --> |
| 1045 | <!-- hhmts start --> |
| 1046 | Last modified: Mon Oct 27 12:00:00 CDT 2003 |
| 1047 | <!-- hhmts end --> |
John Criswell | 85ed361 | 2003-06-12 19:34:44 +0000 | [diff] [blame] | 1048 | </body> |
Guochun Shi | f4688a8 | 2002-07-17 23:05:56 +0000 | [diff] [blame] | 1049 | </html> |