How to compile lldb?

Hi everybody,

I am still trying to build lldb on Debian Stable. I configured cmake like this:

cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_C_COMPILER=/export/source/clang/bin/clang -DCMAKE_CXX_COMPILER=/export/source/clang/bin/clang++ -DCMAKE_INSTALL_PREFIX=/export/source/clang ..

However, I think that the build tries to use my c++ stdlib provided by the system gcc 4.7, and that this is the cause of the error:

[ 91%] Building CXX object tools/lldb/source/Plugins/Process/Linux/CMakeFiles/lldbPluginProcessLinux.dir/ThreadStateCoordinator.cpp.o
In file included from /export/source/git/llvm/tools/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp:17:
In file included from /export/source/git/llvm/tools/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.h:13:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/condition_variable:38:
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/chrono:540:6: error: no matching constructor for initialization of 'duration' (aka
       'std::chrono::duration<long, std::ratio<1, 1000000> >')
           : __d(__t.time_since_epoch())
             ^ ~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/condition_variable:111:42: note: in instantiation of function template specialization
       'std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<long, std::ratio<1, 1000000> >
       >::time_point<std::chrono::duration<long, std::ratio<1, 1000000000> > >' requested here
         const __clock_t::time_point __s_atime = __s_entry + __delta;
                                                 ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/chrono:234:12: note: candidate constructor not viable: no known conversion from
       'duration<[...], ratio<[...], 1000000000>>' to 'const duration<[...], ratio<[...], 1000000>>' for 1st argument
         constexpr duration(const duration&) = default;
                   ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/chrono:237:19: note: candidate template ignored: disabled by 'enable_if' [with _Rep2 =
       std::chrono::duration<long, std::ratio<1, 1000000000> >]
                enable_if<is_convertible<_Rep2, rep>::value
                          ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/chrono:244:19: note: candidate template ignored: disabled by 'enable_if' [with _Rep2 =
       long, _Period2 = std::ratio<1, 1000000000>]
enable_if<treat_as_floating_point<rep>::value
                          ^
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/chrono:232:12: note: candidate constructor not viable: requires 0 arguments, but 1 was
       provided
         constexpr duration() : __r() { }
                   ^
1 error generated.
make[2]: *** [tools/lldb/source/Plugins/Process/Linux/CMakeFiles/lldbPluginProcessLinux.dir/ThreadStateCoordinator.cpp.o] Error 1
make[1]: *** [tools/lldb/source/Plugins/Process/Linux/CMakeFiles/lldbPluginProcessLinux.dir/all] Error 2
make: *** [all] Error 2

I also compiled and installed libcxx, so maybe I should switch to that? How do I do that?

Best regards,

Arne

Hi Arne,

I think you’re going to need GCC 4.8.2 (that’s what I use). There may be other dependencies, Ubuntu 14.04 is known to work with a minimum of effort.

Vince

Hi Vince,

thanks for the response. I am set on Debian Stable, and cannot use a different system. As I said, I already build clang snapshot, and libcxx snapshot. Plus I am already building lldb using said clang. But now I just need to tell the build system to use the libcxx I have just built as well. How can I do this?

Best regards,

Arne

I have never tried this, but may be add -DCMAKE_CXX_FLAGS=-stdlib=libstdc++?

Oops, it should be s/libstdc++/libc++.

Hi Arne,

Sorry for not reading your message closer the first time.

These are roughly the steps we follow to build

Host setup (for Ubuntu 14.04, obviously debian steps may differ)

sudo apt-get update
sudo apt-get install build-essential cmake ninja-build git libedit-dev ncurses-dev python-dev swig clang-3.5 ccache binutils-gold

Download & Build

(lldb_configure.py really just invokes cmake)

ROOT_DIR=$HOME/ll/svn
mkdir -p $ROOT_DIR/build
cd $ROOT_DIR
svn co https://llvm.org/svn/llvm-project/lldb/trunk lldb
svn co https://llvm.org/svn/llvm-project/llvm/trunk llvm
svn co https://llvm.org/svn/llvm-project/cfe/trunk clang
git clone http://github.com/tfiala/lldb-tools
cd llvm/tools
ln -s …/…/clang clang
ln -s …/…/lldb lldb
cd $ROOT_DIR/build
CC=‘ccache clang -Qunused-arguments -fcolor-diagnostics’ CXX=‘ccache clang++ -Qunused-arguments -fcolor-diagnostics’ cmake -GNinja -DCMAKE_LINKER=ld.gold -DCMAKE_CXX_FLAGS= -DCMAKE_SHARED_LINKER_FLAGS= -DCMAKE_EXE_LINKER_FLAGS= -DCMAKE_INSTALL_PREFIX:PATH=$ROOT_DIR/install -DCMAKE_BUILD_TYPE=Release -Wno-dev …/llvm
ninja
ninja check-lldb

You can probably drop ccache and the compiler flags from CC and CXX

Vince

I’m too tired, minor corrections

Download & Build

ROOT_DIR=$HOME/ll/svn
mkdir -p $ROOT_DIR/build
cd $ROOT_DIR
svn co https://llvm.org/svn/llvm-project/lldb/trunk lldb
svn co https://llvm.org/svn/llvm-project/llvm/trunk llvm
svn co https://llvm.org/svn/llvm-project/cfe/trunk clang
cd llvm/tools
ln -s …/…/clang clang
ln -s …/…/lldb lldb
cd $ROOT_DIR/build
CC=‘ccache clang -Qunused-arguments -fcolor-diagnostics’ CXX=‘ccache clang++ -Qunused-arguments -fcolor-diagnostics’ cmake -GNinja -DCMAKE_LINKER=ld.gold -DCMAKE_CXX_FLAGS= -DCMAKE_SHARED_LINKER_FLAGS= -DCMAKE_EXE_LINKER_FLAGS= -DCMAKE_INSTALL_PREFIX:PATH=$ROOT_DIR/install -DCMAKE_BUILD_TYPE=Release -Wno-dev …/llvm
ninja
ninja check-lldb

This actually worked. I also needed to add -lcxxabi to the linking, otherwise I would get missing symbols.

Best regards,

Arne

And I have to correct myself as well: -lc++abi it is.

Arne