blob: 26d37d517b901439b564a44765f109495dc00f2a [file] [log] [blame]
Reid Spencercbadf802004-11-01 09:21:32 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Chris Lattner61757352004-02-27 06:28:34 +00002<html>
3<head>
Reid Spencer341d7142004-10-31 23:00:25 +00004 <title>Using The LLVM Libraries</title>
Chris Lattner61757352004-02-27 06:28:34 +00005 <link rel="stylesheet" href="llvm.css" type="text/css">
6</head>
7<body>
Reid Spencer341d7142004-10-31 23:00:25 +00008<div class="doc_title">Using The LLVM Libraries</div>
Chris Lattner61757352004-02-27 06:28:34 +00009<ol>
10 <li><a href="#abstract">Abstract</a></li>
11 <li><a href="#introduction">Introduction</a></li>
Reid Spencer341d7142004-10-31 23:00:25 +000012 <li><a href="#descriptions">Library Descriptions</a></li>
Chris Lattner61757352004-02-27 06:28:34 +000013 <li><a href="#rot">Linkage Rules Of Thumb</a>
14 <ol>
Reid Spencer41482662004-10-31 23:24:31 +000015 <li><a href="#always">Always link LLVMCore, LLVMSupport, LLVMSystem</a>
16 <li><a href="#onlyone">Never link both archive and re-linked</a>
Chris Lattner61757352004-02-27 06:28:34 +000017 </ol>
18 </li>
19</ol>
Chris Lattner7911ce22004-05-23 21:07:27 +000020
21<div class="doc_author">
22 <p>Written by <a href="mailto:rspencer@x10sys.com">Reid Spencer</a></p>
Chris Lattner61757352004-02-27 06:28:34 +000023</div>
Chris Lattner7911ce22004-05-23 21:07:27 +000024
Chris Lattner61757352004-02-27 06:28:34 +000025<!-- ======================================================================= -->
26<div class="doc_section"><a name="abstract">Abstract</a></div>
27<div class="doc_text">
Reid Spencer341d7142004-10-31 23:00:25 +000028 <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 Lattner61757352004-02-27 06:28:34 +000035</p>
36</div>
Reid Spencer341d7142004-10-31 23:00:25 +000037
Chris Lattner61757352004-02-27 06:28:34 +000038<!-- ======================================================================= -->
39<div class="doc_section"> <a name="introduction">Introduction</a></div>
40<div class="doc_text">
Reid Spencer341d7142004-10-31 23:00:25 +000041 <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 Lattner61757352004-02-27 06:28:34 +000066</div>
67<!-- ======================================================================= -->
Reid Spencer341d7142004-10-31 23:00:25 +000068<div class="doc_section"><a name="descriptions"></a>Library Descriptions</div>
Chris Lattner61757352004-02-27 06:28:34 +000069<div class="doc_text">
Reid Spencer341d7142004-10-31 23:00:25 +000070 <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 Spencer0a4e8b32004-11-01 09:22:49 +000073 <tr><th colspan="3">Core Libraries</th></tr>
Reid Spencer41482662004-10-31 23:24:31 +000074 <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 Spencer341d7142004-10-31 23:00:25 +000088
Reid Spencer0a4e8b32004-11-01 09:22:49 +000089 <tr><th colspan="3">Analysis Libraries</th></tr>
Reid Spencer41482662004-10-31 23:24:31 +000090 <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 Spencer341d7142004-10-31 23:00:25 +000096
Reid Spencer0a4e8b32004-11-01 09:22:49 +000097 <tr><th colspan="3">Transformation Libraries</th></tr>
Reid Spencer41482662004-10-31 23:24:31 +000098 <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 Spencer341d7142004-10-31 23:00:25 +0000110
Reid Spencer0a4e8b32004-11-01 09:22:49 +0000111 <tr><th colspan="3">Code Generation Libraries </th></tr>
Reid Spencer41482662004-10-31 23:24:31 +0000112 <tr><td>LLVMCodeGen</td><td><tt>.o</tt></td>
113 <td>Native code generation infrastructure</td></tr>
Reid Spencer341d7142004-10-31 23:00:25 +0000114
Reid Spencer0a4e8b32004-11-01 09:22:49 +0000115 <tr><th colspan="3">Target Libraries</th></tr>
Reid Spencer41482662004-10-31 23:24:31 +0000116 <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 Spencer341d7142004-10-31 23:00:25 +0000138
Reid Spencer0a4e8b32004-11-01 09:22:49 +0000139 <tr><th colspan="3">Runtime Libraries</th></tr>
Reid Spencer41482662004-10-31 23:24:31 +0000140 <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 Lattner61757352004-02-27 06:28:34 +0000148</table>
149</div>
Reid Spencer341d7142004-10-31 23:00:25 +0000150
Chris Lattner61757352004-02-27 06:28:34 +0000151<!-- ======================================================================= -->
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<!-- ======================================================================= -->
Misha Brukman6fb51662004-11-08 00:22:22 +0000158<div class="doc_subsection"><a name="always">Always Link LLVMCore, LLVMSupport,
159 and LLVMSystem</a></div>
Chris Lattner61757352004-02-27 06:28:34 +0000160<div class="doc_text">
Reid Spencer341d7142004-10-31 23:00:25 +0000161 <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 Lattner61757352004-02-27 06:28:34 +0000163</div>
164<!-- ======================================================================= -->
Reid Spencer341d7142004-10-31 23:00:25 +0000165<div class="doc_subsection"><a name="onlyone">Never link both archive and
166 re-linked library</a></div>
Chris Lattner61757352004-02-27 06:28:34 +0000167<div class="doc_text">
Reid Spencer341d7142004-10-31 23:00:25 +0000168 <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 Lattner61757352004-02-27 06:28:34 +0000173</div>
174<!-- ======================================================================= -->
175<hr>
176<div class="doc_footer">
Reid Spencerbd722412004-11-01 09:19:53 +0000177<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 Lattner61757352004-02-27 06:28:34 +0000184<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-->