1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5<link href="style.css" rel="stylesheet" type="text/css" />
6<title>Building LLDB</title>
7</head>
8
9<body>
10    <div class="www_title">
11      The <strong>LLDB</strong> Debugger
12    </div>
13
14<div id="container">
15	<div id="content">
16
17  <!--#include virtual="sidebar.incl"-->
18
19		<div id="middle">
20                <h1 class ="postheader">Continuous Integraton</h1>
21                <div class="postcontent">
22                        <p> The following LLVM buildbots build and test LLDB trunk:
23                        <ul>
24                                <li> <a href="http://lab.llvm.org:8011/builders/lldb-x86_64-debian-clang">LLDB Linux x86_64 build with Clang (automake)</a>
25                                <li> <a href="http://lab.llvm.org:8011/builders/lldb-x86_64-linux">LLDB Linux x86_64 build with GCC 4.6 (automake)</a>
26                                <li> <a href="http://lab.llvm.org:8011/builders/lldb-x86_64-darwin11">LLDB Mac OS X x86_64 build with Clang (XCode)</a>
27                                <li> <a href="http://llvm-amd64.freebsd.your.org:8010/builders/lldb-amd64-freebsd">LLDB FreeBSD x86_64</a>
28                                <li> <a href="http://llvm-amd64.freebsd.your.org:8010/builders/lldb-i386-freebsd">LLDB FreeBSD i386</a>
29                        </ul>
30                </div>
31                <div class="postfooter"></div>
32    		<div class="post">
33    			<h1 class ="postheader">Building LLDB on Mac OS X</h1>
34    			<div class="postcontent">
35    			    <p>Building on Mac OS X is as easy as downloading the code and building the Xcode project or workspace:</p>
36                </div>
37                <div class="postcontent">
38                    <h2>Preliminaries</h2>
39                    <ul>
40                        <li>XCode 4.3 or newer requires the "Command Line Tools" component (XCode->Preferences->Downloads->Components).</li>
41                        <li>Mac OS X Lion or newer requires installing <a href="http://swig.org">Swig</a>.</li>
42                    </ul>
43                    <h2>Building LLDB</h2>
44    			    <ul>
45                        <li><a href="download.html">Download</a> the lldb sources.</li>
46                        <li>Follow the code signing instructions in <b>lldb/docs/code-signing.txt</b></li>
47                        <li>In Xcode 3.x: <b>lldb/lldb.xcodeproj</b>, select the <b>lldb-tool</b> target, and build.</li>
48                        <li>In Xcode 4.x: <b>lldb/lldb.xcworkspace</b>, select the <b>lldb-tool</b> scheme, and build.</li>
49    			    </ul>
50    			</div>
51              	<div class="postfooter"></div>
52          	</div>
53    		<div class="post">
54    			<h1 class ="postheader">Building LLDB on Linux and FreeBSD</h1>
55    			<div class="postcontent">
56    			    <p>This document describes the steps needed to compile LLDB on most Linux systems, and FreeBSD.</a></p>
57    			</div>
58    			<div class="postcontent">
59                <h2>Preliminaries</h2>
60                <p>LLDB relies on many of the technologies developed by the larger LLVM project.
61                In particular, it requires both Clang and LLVM itself in order to build.  Due to
62                this tight integration the <em>Getting Started</em> guides for both of these projects
63                come as prerequisite reading:</p>
64			    <ul>
65                    <li><a href="http://llvm.org/docs/GettingStarted.html">LLVM</a></li>
66                    <li><a href="http://clang.llvm.org/get_started.html">Clang</a></li>
67                </ul>
68                <p>Supported compilers for building LLDB on Linux include:</p>
69                <ul>
70                  <li>Clang 3.2</li>
71                  <li><a href="http://gcc.gnu.org">GCC</a> 4.6.2 (later versions should work as well)</li>
72                </ul>
73                <p>It is recommended to use libstdc++ 4.6 (or higher) to build LLDB on Linux, but using libc++ is also known to work.</p>
74                <p>On FreeBSD the base system Clang and libc++ may be used to build LLDB,
75                or the GCC port or package.</p>
76                <p>In addition to any dependencies required by LLVM and Clang, LLDB needs a few
77                development packages that may also need to be installed depending on your
78                system.  The current list of dependencies are:</p>
79    			<ul>
80                    <li><a href="http://swig.org">Swig</a></li>
81                    <li><a href="http://www.thrysoee.dk/editline">libedit</a> (Linux only)</li>
82                    <li><a href="http://www.python.org">Python</a></li>
83                </ul>
84                <p>So for example, on a Fedora system one might run:</p>
85                <code>&gt; yum install swig python-devel libedit-devel</code>
86                <p>On an Ubuntu system one might run:</p>
87                <code>&gt; sudo apt-get install build-essential subversion swig python-dev libedit-dev </code>
88                <p>On FreeBSD one might run:</p>
89                <code>&gt; pkg install swig python</code>
90                <p>If you wish to build the optional reference documentation, additional dependencies are required:</p>
91                <ul>
92                  <li> Graphviz (for the 'dot' tool).
93                  <li> doxygen (only if you wish to build the C++ API reference)
94                  <li> epydoc (only if you wish to build the Python API reference)
95                </ul>
96                <p>To install the prerequisites for building the documentation (on Ubuntu) do:</p>
97                <code>
98                  <br>&gt; sudo apt-get install doxygen graphviz
99                  <br>&gt; sudo pip install epydoc
100                </code>
101                <h2 >Building LLDB</h2>
102                <p>We first need to checkout the source trees into the appropriate locations.  Both
103                Clang and LLDB build as subprojects of LLVM.  This means we will be checking out
104                the source for both Clang and LLDB into the <tt>tools</tt> subdirectory of LLVM.  We
105                will be setting up a directory hierarchy looking something like this:</p>
106                <p>
107                <pre><tt>
108                  llvm
109                  |
110                  `-- tools
111                      |
112                      +-- clang
113                      |
114                      `-- lldb
115                </tt></pre>
116                </p>
117                <p>For reference, we will call the root of the LLVM project tree <tt>$llvm</tt>, and the
118                roots of the Clang and LLDB source trees <tt>$clang</tt> and <tt>$lldb</tt> respectively.</p>
119                <p>Change to the directory where you want to do development work and checkout LLVM:</p>
120                <code>&gt; svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm</code>
121
122                <p>Now switch to LLVM&#8217;s tools subdirectory and checkout both Clang and LLDB:</p>
123                <code>&gt; cd $llvm/tools
124                <br>&gt; svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
125                <br>&gt; svn co http://llvm.org/svn/llvm-project/lldb/trunk lldb
126                </code>
127
128                <p>In general, building the LLDB trunk revision requires trunk revisions of both
129                LLVM and Clang.
130                <p>It is highly recommended that you build the system out of tree.  Create a second
131                build directory and configure the LLVM project tree to your specifications as
132                outlined in LLVM&#8217;s <em>Getting Started Guide</em>.  A typical build procedure
133                might be:</p>
134                <code>&gt; cd $llvm/..
135                  <br>&gt; mkdir build
136                  <br>&gt; cd build
137                </code>
138                <h2>To build with CMake</h2>
139                <p>Using CMake is documented on the <a href="http://llvm.org/docs/CMake.html">Building LLVM with CMake</a>
140                   page. Building LLDB is possible using one of the following generators:
141                </p>
142                <ul>
143                  <li> Ninja </li>
144                  <li> Unix Makefiles </li>
145                </ul>
146                <h3>Using CMake + Ninja</h3>
147                <p>Ninja is the fastest way to build LLDB! In order to use ninja, you need to have recent versions of CMake and
148                   ninja on your system. To build using ninja:
149                </p>
150                <code>
151                  &gt; cmake .. -G Ninja
152                  <br>&gt; ninja lldb
153                  <br>&gt; ninja check-lldb
154                </code>
155                <h3>Using CMake + Unix Makefiles</h3>
156                <p>If you do not have Ninja, you can still use CMake to generate Unix Makefiles that build LLDB:</p>
157                <code>
158                  &gt; cmake ..
159                  <br>&gt; make
160                  <br>&gt; make check-lldb
161                </code>
162                <h2>To build with autoconf</h2>
163                <p>If you do not have CMake, it is still possible to build LLDB using the autoconf build system. If you are using
164                   Clang or GCC 4.7+, run:</p>
165                <code>
166                  &gt; $llvm/configure --enable-cxx11
167                  <br>&gt; make </code>
168                <p>Or, if you are using a version of GCC that does not support the <tt>-std=c++11</tt> option:</p>
169                <code>
170                  &gt; $llvm/configure
171                  <br>&gt; make CXXFLAGS=-std=c++0x</code>
172                <p>If you are building with a GCC that isn't the default gcc/g++, like gcc-4.7/g++-4.7</p>
173                <code>
174                  &gt; $llvm/configure --enable-cxx11 CC=gcc-4.7 CXX=g++-4.7
175                  <br>&gt; make CC=gcc-4.7 CXX=g++-4.7</code>
176                <p>If you are running in a system that doesn't have a lot of RAM (less than 4GB), you might want to disable
177                    debug symbols by specifying DEBUG_SYMBOLS=0 when running make. You will know if you need to enable this
178                    because you will fail to link clang (the linker will get a SIGKILL and exit with status 9).</p>
179                <code>
180                    &gt; make DEBUG_SYMBOLS=0</code>
181                <p> To run the LLDB test suite, run:</p>
182                <code>
183                  <br>&gt; make -C tools/lldb/test</code>
184                <p>Note that once both LLVM and Clang have been configured and built it is not
185                necessary to perform a top-level <tt>make</tt> to rebuild changes made only to LLDB.
186                You can run <tt>make</tt> from the <tt>build/tools/lldb</tt> subdirectory as well.</p>
187                <p> If you wish to build with libc++ instead of libstdc++ (the default), run configure with the
188                <tt>--enable-libcpp</tt> flag.</p>
189                <p> If you wish to build a release version of LLDB, run configure with the <tt>--enable-optimized</tt> flag.</p>
190
191                <h2>Testing</h2>
192                <p>By default, the <tt>check-lldb</tt> target builds the 64-bit variants of the test programs with the same
193                compiler that was used to build LLDB. It is possible to customize the architecture and compiler by appending -A and
194                -C options respectively to the CMake variable <tt>LLDB_TEST_ARGS</tt>. For example, to test LLDB against 32-bit binaries
195                built with a custom version of clang, do:</p>
196                <code>
197                  <br>&gt; cmake -DLLDB_TEST_ARGS="-A i386 -C /path/to/custom/clang" -G Ninja
198                  <br>&gt; ninja check-lldb
199                </code>
200                <p>Note that multiple -A and -C flags can be specified to <tt>LLDB_TEST_ARGS</tt>.</p>
201                <p>In addition to running all the LLDB test suites with the "check-lldb" CMake target above, it is possible to
202                run individual LLDB tests. For example, to run the test cases defined in TestInferiorCrashing.py, run:</p>
203                <code>
204                  <br>&gt; cd $lldb/test
205                  <br>&gt; python dotest.py --executable &lt;path-to-lldb&gt;  -p TestInferiorCrashing.py
206                </code>
207                <p>In addition to running a test by name, it is also possible to specify a directory path to <tt>dotest.py</tt>
208                in order to run all the tests under that directory. For example, to run all the tests under the
209                'functionalities/data-formatter' directory, run:</p>
210                <code>
211                  <br>&gt; python dotest.py --executable &lt;path-to-lldb&gt; functionalities/data-formatter
212                </code>
213                <p>To dump additional information to <tt>stdout</tt> about how the test harness is driving LLDB, run
214                <tt>dotest.py</tt> with the <tt>-t</tt> flag. Many more options that are available. To see a list of all of them, run:</p>
215                <code>
216                  <br>&gt; python dotest.py -h
217                </code>
218                <h2>Building API reference documentation</h2>
219                <p>LLDB exposes a C++ as well as a Python API. To build the reference documentation for these two APIs, ensure you have
220                the required dependencies installed, and build the <tt>lldb-python-doc</tt> and <tt>lldb-cpp-doc</tt> CMake targets.</p>
221                <p> The output HTML reference documentation can be found in <tt>&lt;build-dir&gt;/tools/lldb/docs/</tt>.<p>
222                <h2>Additional Notes</h2>
223                <p>LLDB has a Python scripting capability and supplies its own Python module named <tt>lldb</tt>.
224                If a script is run inside the command line <tt>lldb</tt> application, the Python module
225                is made available automatically.  However, if a script is to be run by a Python interpreter
226                outside the command line application, the <tt>PYTHONPATH</tt> environment variable can be used
227                to let the Python interpreter find the <tt>lldb</tt> module.
228                <p>The correct path can be obtained by invoking the command line <tt>lldb</tt> tool with the -P flag:</p>
229                <code>&gt; export PYTHONPATH=`$llvm/build/Debug+Asserts/bin/lldb -P`</code>
230                <p>If you used a different build directory or made a release build, you may need to adjust the
231                above to suit your needs. To test that the lldb Python module
232                is built correctly and is available to the default Python interpreter, run:</p>
233                <code>&gt; python -c 'import lldb'</code></p>
234                </div>
235              	<div class="postfooter"></div>
236          	</div>
237      	</div>
238	</div>
239</div>
240</body>
241</html>
242