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