Add VANext and VAArg stubs.
[oota-llvm.git] / docs / UsingLibraries.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4         <title>Using The LLVM Libraries</title>
5   <link rel="stylesheet" href="llvm.css" type="text/css">
6 </head>
7 <body>
8 <div class="doc_title">Using The LLVM Libraries</div>
9 <ol>
10   <li><a href="#abstract">Abstract</a></li>
11   <li><a href="#introduction">Introduction</a></li>
12   <li><a href="#descriptions">Library Descriptions</a></li>
13   <li><a href="#rot">Linkage Rules Of Thumb</a>
14           <ol>
15       <li><a href="#always">Always link LLVMCore, LLVMSupport, LLVMSystem</a>
16                         <li><a href="#onlyone">Never link both archive and re-linked</a>
17                 </ol>
18         </li>
19 </ol>
20
21 <div class="doc_author">
22   <p>Written by <a href="mailto:rspencer@x10sys.com">Reid Spencer</a></p>
23 </div>
24
25 <!-- ======================================================================= -->
26 <div class="doc_section"><a name="abstract">Abstract</a></div>
27 <div class="doc_text">
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.
35 </p>
36 </div>
37
38 <!-- ======================================================================= -->
39 <div class="doc_section"> <a name="introduction">Introduction</a></div>
40 <div class="doc_text">
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.
66 </div>
67 <!-- ======================================================================= -->
68 <div class="doc_section"><a name="descriptions"></a>Library Descriptions</div>
69 <div class="doc_text">
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>
73   <tr><th colspan="3">Core Libraries</th></tr>
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>
88
89   <tr><th colspan="3">Analysis Libraries</th></tr>
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>
96
97   <tr><th colspan="3">Transformation Libraries</th></tr>
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>
110
111   <tr><th colspan="3">Code Generation Libraries </th></tr>
112   <tr><td>LLVMCodeGen</td><td><tt>.o</tt></td>
113     <td>Native code generation infrastructure</td></tr>
114
115   <tr><th colspan="3">Target Libraries</th></tr>
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>
138
139   <tr><th colspan="3">Runtime Libraries</th></tr>
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>
148 </table>
149 </div>
150
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 <!-- ======================================================================= -->
158 <div class="doc_subsection"><a name="always">Always Link LLVMCore, LLVMSupport,
159     and LLVMSystem</a></div>
160 <div class="doc_text">
161   <p>No matter what you do with LLVM, the last three entries in the value of 
162   your LLVMLIBS make variable should always be: 
163   <tt>LLVMCore LLVMSupport.a LLVMSystem.a</tt>. There are no <tt>LLVM</tt> 
164   programs that don't depend on these three.</p>
165 </div>
166 <!-- ======================================================================= -->
167 <div class="doc_subsection"><a name="onlyone">Never link both archive and
168     re-linked library</a></div>
169 <div class="doc_text">
170   <p>There is never any point to linking both the re-linked (<tt>.o</tt>) and
171   the archive (<tt>.a</tt>) versions of a library. Since the re-linked version
172   includes the entire library, the archive version will not resolve any symbols.
173   You could even end up with link error if you place the archive version before
174   the re-linked version on the linker's command line.</p>
175 </div>
176 <!-- ======================================================================= -->
177 <hr>
178 <div class="doc_footer">
179 <address>
180   <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
181     src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"/></a>
182   <a href="http://validator.w3.org/check/referer"><img
183     src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
184   <a href="mailto:rspencer@x10sys.com">Reid Spencer</a>
185 </address>
186 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a> 
187 <br>Last modified: $Date$ </div>
188 </body>
189 </html>
190 <!-- vim: sw=2 ts=2 ai
191 -->