This document describes the steps needed to compile LLDB on most Linux systems.
Preliminaries
LLDB relies on many of the technologies developed by the larger LLVM project.
In particular, it requires both Clang and LLVM itself in order to build. Due to
this tight integration the Getting Started guides for both of these projects
come as prerequisite reading:
In addition to any dependencies required by LLVM and Clang, LLDB needs a few
development packages that may also need to be installed depending on your
system. The current list of dependencies are:
So for example, on a Fedora system one might run:
> yum install swig python-devel libedit-devel
On an Ubuntu system one might run:
> sudo apt-get install swig python-dev libedit-dev
If building using GCC instead of Clang, GCC 4.6.2 or newer is required.
Building LLDB
We first need to checkout the source trees into the appropriate locations. Both
Clang and LLDB build as subprojects of LLVM. This means we will be checking out
the source for both Clang and LLDB into the tools subdirectory of LLVM. We
will be setting up a directory hierarchy looking something like this:
llvm
|
`-- tools
|
+-- clang
|
`-- lldb
For reference, we will call the root of the LLVM project tree $llvm, and the
roots of the Clang and LLDB source trees $clang and $lldb respectively.
Change to the directory where you want to do development work and checkout LLVM:
> svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
Now switch to LLVM’s tools subdirectory and checkout both Clang and LLDB:
> cd $llvm/tools
> svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
> svn co http://llvm.org/svn/llvm-project/lldb/trunk lldb
In general, building the LLDB trunk revision requires trunk revisions of both
LLVM and Clang.
It is highly recommended that you build the system out of tree. Create a second
build directory and configure the LLVM project tree to your specifications as
outlined in LLVM’s Getting Started Guide. A typical build procedure
might be:
> cd $llvm/..
> mkdir build
> cd build
> $llvm/configure --enable-cxx11 --enable-libcpp
> make
Note that once both LLVM and Clang have been configured and built it is not
necessary to perform a top-level make to rebuild changes made only to LLDB.
You can run make from the build/tools/lldb subdirectory as well. If your
compiler doesn't support libc++, you may need to tweak or remove the last
parameter to the configure script.
Additional Notes
LLDB has a Python scripting capability and supplies its own Python module,
lldb, built alongside the lldb binary. Python needs to know where to
look for this module when LLDB starts up. To tell python the location of LLDB, set
PYTHONPATH environment variable.
In bash with a Debug+Asserts build (the default if configure is invoked
like in the example on this page) one might run:
> export PYTHONPATH=$llvm/build/Debug+Asserts/lib/python2.7/site-packages
If you used different configure flags, or have a different version of python,
you may need to adjust the above to suit your needs. To test that the lldb python module
is built correctly and is available to Python, run:
> python -c 'import lldb'