unable to build lldb on linux

Hi,

I tried to follow the instruction I found in http://lldb.llvm.org/build.html but I’m unable to build lldb.

The structure of my source three is:

~/llvm-clang

__build (normal dir)
__llvm (git)
__tools
__clang (git)
__lldb (git)

I ran sudo apt-get build-dep lldb-3.3
Then from ~/llvm-clang/build, I ran `cmake …/llvm -G Ninja -DLLVM_ENABLE_CXX11=ON

This might be relevant:

CMake Warning (dev) at tools/lldb/source/CMakeLists.txt:289 (add_dependencies):
Policy CMP0046 is not set: Error on non-existent dependency in
add_dependencies. Run “cmake --help-policy CMP0046” for policy details.
Use the cmake_policy command to set the policy and suppress this warning.

The dependency target
“/home/tfarina/llvm-clang/build/tools/lldb/scripts/LLDBWrapPython.cpp” of
target “liblldb” does not exist.

By the end, I ran ninja lldb 2>&1 | tee ninja.log

Log with output attached.

$ clang -v
clang version 3.5.0 (trunk 204777)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.5.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7

What am I missing?

Thanks in advance!

NOTE: I’m not subscribed to this list, so please keep me in the CC list when replying.

ninja.log (60.5 KB)

Hi Tiago,

Which version of Linux are you running under? I assume it is Debian based given the apt-get.

It looks like there might be a build error in top of tree based on your output, I will check in a minute on my end.

I’ll have a look at the packages listed in the docs to see if anything I tend to need is missing. I build pretty regularly both on Ubuntu 12.04 x86_64 and Ubuntu 13.10 x86_64, although I almost exclusively use gcc 4.8.1 or 4.8.2 due to some issues I ran into back in Nov 2013 (I need to work on migrating or at least supporting clang in our build process).

Back in a bit after I see if I can get a clean build…

It looks like there might be a build error in top of tree based on your output, I will check in a minute on my end.

I was able to make a clean build with cmake/ninja with top of tree r205497.

Looking at the build page, there are a few mistakes there (I’ll look into getting these updated):

  • gcc 4.8+ is needed now (as of very late 2013). We’re using cxx11 features not fully supported by earlier gcc versions. I’ve used gcc 4.8.1 (Ubuntu 13.10 default) and gcc 4.8.2 (what I build custom on Ubuntu 12.04).

  • The enable cxx11 bits are setup by default now (as of Feb/March 2014).

  • libedit is needed as of roughly Feb 2014. Use ‘sudo apt-get install libedit-dev’. That works for Ubuntu 13.10 or later. For earlier versions, you really need the July 2013 version of libedit. We use a configure-based version of it on Ubuntu 12.04, but use the stock Ubuntu version for Ubuntu 13.10 and later.

  • The version of cmake available on Ubuntu 13.10 worked fine for me. I had to build a custom latest version for Ubuntu 12.04.
    Let me know if that gets you further. If not, I can distill what we run out of our build scripts to see if you can replicate. A big key at this point is which distribution version you’re using, though.

Thanks!

Sincerely,
Todd Fiala

Hey Todd,

Ok cool. That’s our standard OS over here.

I’d recommend:

  1. building a gcc 4.8.2 from source. A standard download, unpack, mkdir on a parallel build dir, configure --prefix=/some/install/path, etc. to give you a gcc 4.8.2 on Ubuntu 12.04. Let me know if you have trouble with that. The key here is that you’ll get a functional libstdc++ that will work for the later steps in addition to sufficient c++11 support. You’ll need to add the install lib64 path to your LD_LIBRARY_PATH and similarly for linker -L options on the linker command line.

  2. build the latest cmake release from source and install somewhere local. The latest available for Ubuntu 12.04 I think gave me errors since it was too old.

  3. grab a configure buildable libedit (we get it from here). You might be able to survive with libedit-dev from Ubuntu 12.04 now, but for a while that was not sufficient. If you build it, you’ll need to add the lib64 path to your LD_LIBRARY_PATH, and a -L for the lib path and -I for the header path.

  4. Not sure exactly where you got your ninja, build I found on Ubuntu < 13.10 I have to install it from source. You may have a valid route too, that’s just been my experience.

FWIW - In the last couple hours I’ve tried once again to build the lldb tree on Ubuntu 12.04 with a top of tree clang that I build with gcc 4.8.2. I had trouble getting the top of tree clang to be happy working with my gcc 4.8.2 libstdc++. I could get it past the cmake step but clang++ doesn’t seem to like my libstdc++ 4.8.2 headers. I’ve had no luck with getting libc++ built on this setup but I may try again. I was attempting to get a clang setup to try to replicate your scenario. If I get that working and can replicate the issue you saw on clang, I’ll get back on this thread.

In the meantime, if you try the steps above and hit any trouble with using gcc 4.8.2 on Ubuntu 12.04 x86_64, let me know and I can help out. This is our stock build environment so I’m sure we can work out any issues there.

Thanks!

-Todd

Hi Thiago,

You need gcc 4.8 to build lldb on Linux. Actually, 4.7 may work also.

We have successfully to build lldb under older Suse 11.3 x86_64 and even on

older 11.1 x86 version. Besides putting all required libraries into your system,

you also need matched llvm, clang and lldb. The tip of llvm clang lldb may not

compatible each other. You need git back several days and try again.

I remember the required libraries are

Libedit, libncurse, python 2.7, gcc 4.8

Yin

Hey Thiago,

Here are some instructions that should get you a gcc 4.8.2 build on Ubuntu 12.04 x86_64. Including lldb-dev again so I can point others to this. Let me know if you hit any issues with it and we’ll get that fixed up.

Yup. Can you help me build gcc? That is a non-trivial task.

Sure thing:

  1. Download gcc 4.8.2 from here.
  2. Unpack it somewhere. You can run a command sequence like:
  3. mkdir ~/src
  4. cd src
  5. tar xjf ~/Downloads/gcc-4.8.2.tar.bz2
  6. the above will dump the gcc 4.8.2 source tree in ~/src/gcc-4.8.21. Make sure you have packages installed that gcc will want.

  7. I think you only need to install libmpc-dev to get what is needed beyond build-essential. Run something like this: sudo apt-get install build-essential libmpc-dev.
  8. If you run the next step (configure) and it blows up, send me the output and I’ll figure out what’s missing. There are really only a few minor packages and I think that’s the only one I have to install beyond the basic build tools.1. Configure gcc
  9. We’re going to install this in /usr/local/gcc/gcc-4.8.2. You’ll have to adjust some of the commands below if you want this to go somewhere else. This will be the install dir for the compiler.
  10. Run the following sequence of commands
  11. cd ~/src
  12. mkdir build-gcc-4.8.2
  13. cd build-gcc-4.8.2
  14. …/gcc-4.8.2/configure --prefix=/usr/local/gcc/gcc-4.8.21. Build and install gcc
  15. Run the following sequence
  16. assumes you’re still in ~/src/build-gcc-4.8.2

  17. make
  18. sudo make install1. Adjust your environment variables
  19. vim/emacs ~/.bashrc
  20. add the following lines to the bottom of your .bashrc file:

export PATH=/usr/local/gcc/gcc-4.8.2/bin:$PATH

export LD_LIBRARY_PATH=/usr/local/gcc/gcc-4.8.2/lib64:$LD_LIBRARY_PATH

At this point you can restart your shell and you should have a gcc 4.8.2 gcc/g++ compiler that gets picked up ahead of the Ubuntu 12.04 gcc 4.6.3. Verify this by running “g++ --version” at the command prompt. It should say that it is version 4.8.2. If for some reason you don’t get that to happen, make sure your .bash_profile (or .profile) is picking up the .bashrc file, and make sure we got all the paths right for where you installed gcc 4.8.2.

From here you should be able to run an LLDB configure/make or cmake/ninja build.

Let me know if you hit any trouble with that.

Sincerely,
Todd Fiala

In the event that you have more than a single processor for this (likely the case), you can adjust the ‘make’ command for gcc and use something like ‘make -j 10’, replacing the 10 with a number something like # procs + 2. On my end, I use -j 32 as I have 16 hyperthreaded cores. On VMs where I only allocate 4 cores, I’d use something like -j 6.

-Todd

Hi Todd,

It would be great to get these extra instructions into our trunk/www/build.html file. If anyone can take the time to update the issues they ran into, that would be great!

Greg Clayton

I’ll be happy to do it. That was my plan after I figured out how to do it, which you just gave me :slight_smile:

Thanks!

Thiago - glad that worked!!!