| Reid Spencer | 271fe88 | 2004-11-01 09:21:32 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 2 | <html> | 
|  | 3 | <head> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 4 | <title>Using The LLVM Libraries</title> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 5 | <link rel="stylesheet" href="llvm.css" type="text/css"> | 
|  | 6 | </head> | 
|  | 7 | <body> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 8 | <div class="doc_title">Using The LLVM Libraries</div> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 9 | <ol> | 
|  | 10 | <li><a href="#abstract">Abstract</a></li> | 
|  | 11 | <li><a href="#introduction">Introduction</a></li> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 12 | <li><a href="#descriptions">Library Descriptions</a></li> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 13 | <li><a href="#rot">Linkage Rules Of Thumb</a> | 
|  | 14 | <ol> | 
| Reid Spencer | b145487 | 2004-10-31 23:24:31 +0000 | [diff] [blame] | 15 | <li><a href="#always">Always link LLVMCore, LLVMSupport, LLVMSystem</a> | 
|  | 16 | <li><a href="#onlyone">Never link both archive and re-linked</a> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 17 | </ol> | 
|  | 18 | </li> | 
|  | 19 | </ol> | 
| Chris Lattner | 020e1fc | 2004-05-23 21:07:27 +0000 | [diff] [blame] | 20 |  | 
|  | 21 | <div class="doc_author"> | 
|  | 22 | <p>Written by <a href="mailto:rspencer@x10sys.com">Reid Spencer</a></p> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 23 | </div> | 
| Chris Lattner | 020e1fc | 2004-05-23 21:07:27 +0000 | [diff] [blame] | 24 |  | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 25 | <!-- ======================================================================= --> | 
|  | 26 | <div class="doc_section"><a name="abstract">Abstract</a></div> | 
|  | 27 | <div class="doc_text"> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 28 | <p>Amongst other things, LLVM is a toolkit for building compilers, linkers, | 
|  | 29 | runtime executives, virtual machines, and other program execution related | 
|  | 30 | tools. In addition to the LLVM tool set, the functionality of LLVM is | 
|  | 31 | available through a set of libraries.  To use LLVM as a toolkit for | 
|  | 32 | constructing tools, a developer needs to understand what is contained in the | 
|  | 33 | various libraries, what they depend on, and how to use them.  This document | 
|  | 34 | describes the contents of the libraries and how and when to use them. | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 35 | </p> | 
|  | 36 | </div> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 37 |  | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 38 | <!-- ======================================================================= --> | 
|  | 39 | <div class="doc_section"> <a name="introduction">Introduction</a></div> | 
|  | 40 | <div class="doc_text"> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 41 | <p>If you're writing a compiler, virtual machine, or any other utility based | 
|  | 42 | on LLVM, you'll need to figure out which of the many libraries files you will | 
|  | 43 | need to link with to be successful. An understanding of the contents of these | 
|  | 44 | files and their inter-relationships will be useful in coming up with an optimal | 
|  | 45 | specification for the libraries to link with. The purpose of this document is | 
|  | 46 | to reduce some of the trial and error that the author experienced in using | 
|  | 47 | LLVM.</p> | 
|  | 48 | <p>LLVM produces two types of libraries: archives (ending in <tt>.a</tt>) and | 
|  | 49 | objects (ending in <tt>.o</tt>). However, both are libraries. Libraries ending | 
|  | 50 | in <tt>.o</tt> are known as re-linked libraries because they contain all the | 
|  | 51 | compilation units of the library linked together as a single <tt>.o</tt> file. | 
|  | 52 | Furthermore, many of the libraries have <em>both</em> forms of library. The | 
|  | 53 | re-linked libraries are used whenever you want to include all symbols from the | 
|  | 54 | library. The archive libraries are used whenever you want to only resolve | 
|  | 55 | outstanding symbols at that point in the link without including everything in | 
|  | 56 | the library. </p> | 
|  | 57 | <p>When linking your tools, you will use the <tt>LLVMLIBS</tt> make variable. | 
|  | 58 | (see the <a href="MakefileGuide.html#LLVMLIBS">Makefile Guide</a> for | 
|  | 59 | details). This variable specifies which LLVM libraries to link into your tool | 
|  | 60 | and the order in which they will be linked. You specify re-linked libraries by | 
|  | 61 | naming the library without a suffix. You specify archive libraries by naming | 
|  | 62 | the library with a <tt>.a</tt> suffix but without the <tt>lib</tt> prefix. The | 
|  | 63 | order in which the libraries appear in the <tt>LLVMLIBS</tt> variable | 
|  | 64 | definition is the order in which they will be linked. Getting this order | 
|  | 65 | correct for your tool can sometimes be challenging. | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 66 | </div> | 
|  | 67 | <!-- ======================================================================= --> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 68 | <div class="doc_section"><a name="descriptions"></a>Library Descriptions</div> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 69 | <div class="doc_text"> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 70 | <p>The table below categorizes each library | 
|  | 71 | <table style="text-align:left"> | 
|  | 72 | <tr><th>Library</th><th>Forms</th><th>Description</th></tr> | 
| Reid Spencer | 7336a6c | 2004-11-01 09:22:49 +0000 | [diff] [blame^] | 73 | <tr><th colspan="3">Core Libraries</th></tr> | 
| Reid Spencer | b145487 | 2004-10-31 23:24:31 +0000 | [diff] [blame] | 74 | <tr><td>LLVMAsmParser</td><td><tt>.o</tt></td> | 
|  | 75 | <td>LLVM Assembly Parsing</td></tr> | 
|  | 76 | <tr><td>LLVMBCReader</td><td><tt>.o</tt></td> | 
|  | 77 | <td>LLVM Bytecode Reading</td></tr> | 
|  | 78 | <tr><td>LLVMBCWriter</td><td><tt>.o</tt></td> | 
|  | 79 | <td>LLVM Bytecode Writing</td></tr> | 
|  | 80 | <tr><td>LLVMDebugger</td><td><tt>.o</tt></td> | 
|  | 81 | <td>Source Level Debugging Support</td></tr> | 
|  | 82 | <tr><td>LLVMSupport</td><td><tt>.a .o</tt></td> | 
|  | 83 | <td>General support utilities</td></tr> | 
|  | 84 | <tr><td>LLVMSystem</td><td><tt>.a .o</tt></td> | 
|  | 85 | <td>Operating system abstraction</td></tr> | 
|  | 86 | <tr><td>LLVMCore</td><td><tt>.o</tt></td> | 
|  | 87 | <td>LLVM Core IR</td></tr> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 88 |  | 
| Reid Spencer | 7336a6c | 2004-11-01 09:22:49 +0000 | [diff] [blame^] | 89 | <tr><th colspan="3">Analysis Libraries</th></tr> | 
| Reid Spencer | b145487 | 2004-10-31 23:24:31 +0000 | [diff] [blame] | 90 | <tr><td>LLVMAnalysis</td><td><tt>.a .o</tt></td> | 
|  | 91 | <td>Various analysis passes.</td></tr> | 
|  | 92 | <tr><td>LLVMDataStructure</td><td><tt>.a .o</tt></td> | 
|  | 93 | <td>Data structure analysis passes.</td></tr> | 
|  | 94 | <tr><td>LLVMipa</td><td><tt>.a .o</tt></td> | 
|  | 95 | <td>Inter-procedural analysis passes.</td></tr> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 96 |  | 
| Reid Spencer | 7336a6c | 2004-11-01 09:22:49 +0000 | [diff] [blame^] | 97 | <tr><th colspan="3">Transformation Libraries</th></tr> | 
| Reid Spencer | b145487 | 2004-10-31 23:24:31 +0000 | [diff] [blame] | 98 | <tr><td>LLVMInstrumentation</td><td><tt>.a .o</tt></td> | 
|  | 99 | <td>Instrumentation passes.</td></tr> | 
|  | 100 | <tr><td>LLVMipo</td><td><tt>.a .o</tt></td> | 
|  | 101 | <td>All inter-procedural optimization passes.</td></tr> | 
|  | 102 | <tr><td>LLVMScalarOpts</td><td><tt>.a .o</tt></td> | 
|  | 103 | <td>All scalar optimization passes.</td></tr> | 
|  | 104 | <tr><td>LLVMTransforms</td><td><tt>.a .o</tt></td> | 
|  | 105 | <td>Uncategorized transformation passes.</td></tr> | 
|  | 106 | <tr><td>LLVMTransformUtils</td><td><tt>.a .o</tt></td> | 
|  | 107 | <td>Transformation utilities.</td></tr> | 
|  | 108 | <tr><td>LLVMProfilePaths</td><td><tt>.o</tt></td> | 
|  | 109 | <td>Profile paths for instrumentation.</td></tr> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 110 |  | 
| Reid Spencer | 7336a6c | 2004-11-01 09:22:49 +0000 | [diff] [blame^] | 111 | <tr><th colspan="3">Code Generation Libraries </th></tr> | 
| Reid Spencer | b145487 | 2004-10-31 23:24:31 +0000 | [diff] [blame] | 112 | <tr><td>LLVMCodeGen</td><td><tt>.o</tt></td> | 
|  | 113 | <td>Native code generation infrastructure</td></tr> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 114 |  | 
| Reid Spencer | 7336a6c | 2004-11-01 09:22:49 +0000 | [diff] [blame^] | 115 | <tr><th colspan="3">Target Libraries</th></tr> | 
| Reid Spencer | b145487 | 2004-10-31 23:24:31 +0000 | [diff] [blame] | 116 | <tr><td>LLVMCBackend</td><td><tt>.o</tt></td> | 
|  | 117 | <td>'C' language code generator.</td></tr> | 
|  | 118 | <tr><td>LLVMPowerPC</td><td><tt>.o</tt></td> | 
|  | 119 | <td>PowerPC code generation backend</td></tr> | 
|  | 120 | <tr><td>LLVMSelectionDAG</td><td><tt>.o</tt></td> | 
|  | 121 | <td>Aggressive instruction selector for Directed Acyclic Graphs.</td></tr> | 
|  | 122 | <tr><td>LLVMSkeleton</td><td><tt>.a .o</tt></td> | 
|  | 123 | <td>Skeleton for a code generation backend.</td></tr> | 
|  | 124 | <tr><td>LLVMSparcV9</td><td><tt>.o</tt></td> | 
|  | 125 | <td>Code generation for SparcV9.</td></tr> | 
|  | 126 | <tr><td>LLVMSparcV9RegAlloc</td><td><tt>.a .o</tt></td> | 
|  | 127 | <td>Graph-coloring register allocator for SparcV9.</td></tr> | 
|  | 128 | <tr><td>LLVMSparcV9InstrSched</td><td><tt>.o</tt></td> | 
|  | 129 | <td>Instruction scheduling for SparcV9.</td></tr> | 
|  | 130 | <tr><td>LLVMSparcV9LiveVar</td><td><tt>.o</tt></td> | 
|  | 131 | <td>Live variable analysis SparcV9.</td></tr> | 
|  | 132 | <tr><td>LLVMSparcV9ModuloSched</td><td><tt>.o</tt></td> | 
|  | 133 | <td>Modulo scheduling for SparcV9.</td></tr> | 
|  | 134 | <tr><td>LLVMTarget</td><td><tt>.a .o</tt></td> | 
|  | 135 | <td>Generic code generation utilities.</td></tr> | 
|  | 136 | <tr><td>LLVMX86</td><td><tt>.o</tt></td> | 
|  | 137 | <td>Intel x86 code generation backend</td></tr> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 138 |  | 
| Reid Spencer | 7336a6c | 2004-11-01 09:22:49 +0000 | [diff] [blame^] | 139 | <tr><th colspan="3">Runtime Libraries</th></tr> | 
| Reid Spencer | b145487 | 2004-10-31 23:24:31 +0000 | [diff] [blame] | 140 | <tr><td>LLVMInterpreter</td><td><tt>.o</tt></td> | 
|  | 141 | <td>Bytecode Interpreter</td></tr> | 
|  | 142 | <tr><td>LLVMJIT</td><td><tt>.o</tt></td> | 
|  | 143 | <td>Bytecode JIT Compiler</td></tr> | 
|  | 144 | <tr><td>LLVMExecutionEngine</td><td><tt>.o</tt></td> | 
|  | 145 | <td>Virtual machine engine</td></tr> | 
|  | 146 | <tr><td>LLVMexecve</td><td><tt>.o</tt></td> | 
|  | 147 | <td>execve(2) replacement for llee</td></tr> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 148 | </table> | 
|  | 149 | </div> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 150 |  | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 151 | <!-- ======================================================================= --> | 
|  | 152 | <div class="doc_section"><a name="rot">Linkage Rules Of Thumb</a></div> | 
|  | 153 | <div class="doc_text"> | 
|  | 154 | <p>This section contains various "rules of thumb" about what files you | 
|  | 155 | should link into your programs.</p> | 
|  | 156 | </div> | 
|  | 157 | <!-- ======================================================================= --> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 158 | <div class="doc_subsection"><a name="always">Always Link LLVMCore LLVMSupport | 
|  | 159 | LLVMSystem</a></div> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 160 | <div class="doc_text"> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 161 | <p>No matter what you do with LLVM, the last three entries in your linke line | 
|  | 162 | should always be: <tt>LLVMCore LLVMSupport.a LLVMSystem.a</tt>.</p> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 163 | </div> | 
|  | 164 | <!-- ======================================================================= --> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 165 | <div class="doc_subsection"><a name="onlyone">Never link both archive and | 
|  | 166 | re-linked library</a></div> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 167 | <div class="doc_text"> | 
| Reid Spencer | 0d6d8d0 | 2004-10-31 23:00:25 +0000 | [diff] [blame] | 168 | <p>There is never any point to linking both the re-linked (<tt>.o</tt>) and | 
|  | 169 | the archive (<tt>.a</tt>) versions of a library. Since the re-linked version | 
|  | 170 | includes the entire library, the archive version will not resolve any symbols. | 
|  | 171 | You could even end up with link error is you place the archive version before | 
|  | 172 | the re-linked version on the linker's command line.</p> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 173 | </div> | 
|  | 174 | <!-- ======================================================================= --> | 
|  | 175 | <hr> | 
|  | 176 | <div class="doc_footer"> | 
| Reid Spencer | fea14b5 | 2004-11-01 09:19:53 +0000 | [diff] [blame] | 177 | <address> | 
|  | 178 | <a href="http://jigsaw.w3.org/css-validator/check/referer"><img | 
|  | 179 | src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"/></a> | 
|  | 180 | <a href="http://validator.w3.org/check/referer"><img | 
|  | 181 | src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a> | 
|  | 182 | <a href="mailto:rspencer@x10sys.com">Reid Spencer</a> | 
|  | 183 | </address> | 
| Chris Lattner | 524ee2b | 2004-02-27 06:28:34 +0000 | [diff] [blame] | 184 | <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a> | 
|  | 185 | <br>Last modified: $Date$ </div> | 
|  | 186 | </body> | 
|  | 187 | </html> | 
|  | 188 | <!-- vim: sw=2 ts=2 ai | 
|  | 189 | --> |