This document describes how to build a debug version of LLVM for use with
LLDB, and how to make LLDB use it.
It assumes that you are using the Xcode 3 series (I used 3.2.4) to build
LLDB. It also assumes that your shell is /bin/bash, and that you are
currently at a shell prompt in a checked-out LLDB repository.
1. Check out LLVM and Clang from their repositories. To determine
the revision to use, consult scripts/build-llvm.pl (this is done
in the first command line below). !!! WARNING Do not use the
name "llvm" for your checkout, for reasons described in part 3
below.
$ export CLANG_REVISION=`cat scripts/build-llvm.pl | grep ^our.*llvm_revision | cut -d \' -f 2,2`
$ svn co -r $CLANG_REVISION http://llvm.org/svn/llvm-project/llvm/trunk llvm.checkout
$ svn co -r $CLANG_REVISION http://llvm.org/svn/llvm-project/cfe/trunk llvm.checkout/tools/clang
2. Configure LLVM/Clang with the proper options and compilers. I use:
$ cd llvm.checkout
$ CC="cc -g -O0" CXX="c++ -g -O0" ./configure --disable-optimized --enable-assertions --enable-targets=x86_64,arm
$ CC="cc -g -O0" CXX="c++ -g -O0" make -j 2
$ cd ..
3. Create a link to the built LLVM. !!! WARNING: Do not rename the
directory! The LLVM builder script that runs as part of the Xcode
build keys off the fact that llvm/ is a symlink to recognize that
we are building with a custom debug build.
$ ln -sf llvm.checkout llvm
4. Make sure that your Xcode project is set up correctly. Open
lldb.xcodeproj and do the following:
Under "Targets" in the Groups & Files navigator, double-click
lldb-tool. In the resulting window, select "Debug" from the
"Configuration:" drop-down. Then, make sure that the setting
"Build Active Architecture Only" is enabled. Close the window.
Under "Targets" in the Groups & Files navigator, double-click
LLDB. In the resulting window, select "Debug" from the
"Configuration:" drop-down. Then, make sure that the setting
"Build Active Architecture Only" is enabled. Close the window.
5. Ensure that Xcode is building the lldb-tool target in Debug
configuration for your architecture (typically x86_64). You
can usually pick these options from the Overview drop-down at
the top left of the Xcode window.
6. Build lldb.xcodeproj.