blob: e545b1198a49deedb297af1a331e34db52003c6c [file] [log] [blame]
Greg Clayton41d8a5c2011-03-22 22:39:26 +00001<!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" />
Greg Claytonf9ab5ea2012-01-22 02:55:08 +00006<title>Building LLDB</title>
Greg Clayton41d8a5c2011-03-22 22:39:26 +00007</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">
Daniel Malea65690032013-02-26 21:41:55 +000020 <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>
Ed Masteb669abf2013-07-24 14:44:09 +000027 <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>
Daniel Malea65690032013-02-26 21:41:55 +000029 </ul>
30 </div>
31 <div class="postfooter"></div>
Greg Clayton41d8a5c2011-03-22 22:39:26 +000032 <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>
Johnny Chene4ec5092012-08-16 00:08:21 +000036 </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>
Greg Clayton41d8a5c2011-03-22 22:39:26 +000044 <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">
Ed Masted6b09102013-07-24 14:53:48 +000054 <h1 class ="postheader">Building LLDB on Linux and FreeBSD</h1>
Greg Clayton41d8a5c2011-03-22 22:39:26 +000055 <div class="postcontent">
Ed Masted6b09102013-07-24 14:53:48 +000056 <p>This document describes the steps needed to compile LLDB on most Linux systems, and FreeBSD.</a></p>
Greg Clayton41d8a5c2011-03-22 22:39:26 +000057 </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>
Daniel Malea284e43e2012-12-14 20:02:21 +000068 <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>
Ed Masted6b09102013-07-24 14:53:48 +000074 <p>On FreeBSD the base system Clang and libc++ may be used to build LLDB,
75 or the GCC port or package.</p>
Greg Clayton41d8a5c2011-03-22 22:39:26 +000076 <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>
Ed Masted6b09102013-07-24 14:53:48 +000081 <li><a href="http://www.thrysoee.dk/editline">libedit</a> (Linux only)</li>
Greg Clayton41d8a5c2011-03-22 22:39:26 +000082 <li><a href="http://www.python.org">Python</a></li>
83 </ul>
Greg Claytonf19e1992012-10-15 20:39:39 +000084 <p>So for example, on a Fedora system one might run:</p>
Greg Clayton41d8a5c2011-03-22 22:39:26 +000085 <code>&gt; yum install swig python-devel libedit-devel</code>
Greg Claytonf19e1992012-10-15 20:39:39 +000086 <p>On an Ubuntu system one might run:</p>
Greg Clayton65da8c22013-05-03 16:29:42 +000087 <code>&gt; sudo apt-get install build-essential subversion swig python-dev libedit-dev </code>
Ed Masted6b09102013-07-24 14:53:48 +000088 <p>On FreeBSD one might run:</p>
89 <code>&gt; pkg install swig python</code>
Daniel Malea56c7ef62013-05-28 03:47:34 +000090 <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>
Greg Clayton41d8a5c2011-03-22 22:39:26 +0000101 <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
Greg Claytonf19e1992012-10-15 20:39:39 +0000128 <p>In general, building the LLDB trunk revision requires trunk revisions of both
129 LLVM and Clang.
Greg Clayton41d8a5c2011-03-22 22:39:26 +0000130 <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
Greg Claytonf19e1992012-10-15 20:39:39 +0000132 outlined in LLVM&#8217;s <em>Getting Started Guide</em>. A typical build procedure
133 might be:</p>
Greg Clayton41d8a5c2011-03-22 22:39:26 +0000134 <code>&gt; cd $llvm/..
135 <br>&gt; mkdir build
136 <br>&gt; cd build
Daniel Malea284e43e2012-12-14 20:02:21 +0000137 </code>
Daniel Malea02c106f2013-03-05 22:38:50 +0000138 <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>
Stefanus Du Toit69a39512013-07-23 17:29:44 +0000151 &gt; cmake .. -G Ninja
Daniel Malea02c106f2013-03-05 22:38:50 +0000152 <br>&gt; ninja lldb
153 <br>&gt; ninja check-lldb
154 </code>
155 <h3>Using CMake + Unix Makefiles</h3>
Daniel Malea66fd7b12013-03-05 22:43:08 +0000156 <p>If you do not have Ninja, you can still use CMake to generate Unix Makefiles that build LLDB:</p>
Daniel Malea02c106f2013-03-05 22:38:50 +0000157 <code>
Stefanus Du Toit69a39512013-07-23 17:29:44 +0000158 &gt; cmake ..
Daniel Malea51a5b472013-04-02 20:08:19 +0000159 <br>&gt; make
Daniel Malea02c106f2013-03-05 22:38:50 +0000160 <br>&gt; make check-lldb
161 </code>
Daniel Malea66fd7b12013-03-05 22:43:08 +0000162 <h2>To build with autoconf</h2>
Daniel Malead284d1b2013-03-05 22:58:53 +0000163 <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>
Daniel Malea284e43e2012-12-14 20:02:21 +0000165 <code>
Greg Clayton7712e1c2013-05-17 21:06:45 +0000166 &gt; $llvm/configure --enable-cxx11
Daniel Maleaa56f7f02012-11-10 18:09:36 +0000167 <br>&gt; make </code>
Daniel Malead284d1b2013-03-05 22:58:53 +0000168 <p>Or, if you are using a version of GCC that does not support the <tt>-std=c++11</tt> option:</p>
Daniel Malea284e43e2012-12-14 20:02:21 +0000169 <code>
Greg Clayton7712e1c2013-05-17 21:06:45 +0000170 &gt; $llvm/configure
Daniel Malea284e43e2012-12-14 20:02:21 +0000171 <br>&gt; make CXXFLAGS=-std=c++0x</code>
Greg Clayton7712e1c2013-05-17 21:06:45 +0000172 <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>
Daniel Malead284d1b2013-03-05 22:58:53 +0000181 <p> To run the LLDB test suite, run:</p>
182 <code>
183 <br>&gt; make -C tools/lldb/test</code>
Greg Clayton41d8a5c2011-03-22 22:39:26 +0000184 <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.
Daniel Malea1866b872012-12-17 21:32:49 +0000186 You can run <tt>make</tt> from the <tt>build/tools/lldb</tt> subdirectory as well.</p>
Daniel Malead284d1b2013-03-05 22:58:53 +0000187 <p> If you wish to build with libc++ instead of libstdc++ (the default), run configure with the
Daniel Malea1866b872012-12-17 21:32:49 +0000188 <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>
Daniel Malea02c106f2013-03-05 22:38:50 +0000190
Daniel Malea4f1759b2013-05-17 16:08:45 +0000191 <h2>Testing</h2>
Daniel Malea6d662362013-05-28 19:14:44 +0000192 <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>
Daniel Malea4f1759b2013-05-17 16:08:45 +0000201 <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>
Daniel Malea56c7ef62013-05-28 03:47:34 +0000218 <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>
Greg Clayton41d8a5c2011-03-22 22:39:26 +0000222 <h2>Additional Notes</h2>
Daniel Malea5a39ce32013-01-05 00:16:08 +0000223 <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>
Greg Claytonf19e1992012-10-15 20:39:39 +0000233 <code>&gt; python -c 'import lldb'</code></p>
Greg Clayton41d8a5c2011-03-22 22:39:26 +0000234 </div>
235 <div class="postfooter"></div>
236 </div>
237 </div>
238 </div>
239</div>
240</body>
Greg Claytonf19e1992012-10-15 20:39:39 +0000241</html>