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