Trunk: LLVM build is failing with a lot of `undefined reference` errors

Hello

I'm trying to compile LLVM, Clang and LLDB on Ubuntu 14.04 LTS as
described on llvm.org [1][2]:

sudo apt-get install subversion cmake ninja-build doxygen \
  swig libedit-dev libncurses5-dev libxml2-dev
mkdir llvm-src
cd llvm-src
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
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
cd clang/tools
svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
cd ../../../projects
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
cd ../..
mkdir build
cd build
cmake ../llvm -G Ninja -DLLDB_DISABLE_CURSES:BOOL=TRUE \
  -DCMAKE_C_COMPILER=/usr/bin/clang-3.6 \
  -DCMAKE_CXX_COMPILER=/usr/bin/clang++-3.6
ninja -j4

After some time (ninja shows 1836/3922) I got a lot of `undefined
reference` errors:

http://paste.ubuntu.com/15402351/

I also tried to use `gcc` instead of `clang` and `make` instead of
`ninja` --- same result.

What am I doing wrong?

[1] http://clang.llvm.org/get_started.html#build
[2] http://lldb.llvm.org/build.html#BuildingLldbOnLinux

Try checking out libcxxabi as well.

-Krzysztof

Hi Aleksander,

You have not checked out libcxxabi. It must be checked out together with libcxx.
See http://www.llvm.org/docs/GettingStarted.html p8.

Kind regards,
Evgeny Astigeevich

Try checking out libcxxabi as well.

It helped, thanks.

But I have another problem now. Regression tests don't pass:

http://paste.ubuntu.com/15406485/

Also I discovered that build process sometimes consumes about 10 Gb of
RAM. Luckily I have total 16 Gb of RAM. Still I had to close Google
Chrome and kill KVM guest systems to compile a project. I think its
just an insanity.

Hi Aleksander,

By default the build type is Debug. It uses a lot of memory because object files contain debug information. Each linking process consumes up to 4 GB of memory. Ninja runs several linking processes at the same time.
If you want to build debug builds and work with them I recommend you to have 32 GB or more for comfortable work.
Solutions to memory problems:
1. Build a release version giving the following to cmake: -DCMAKE_BUILD_TYPE=Release
    Other options for type are RelWithDebInfo and MinSizeRel. And of course Debug.
2. Use gold instead of ld for linking.

The failed tests are MemorySanitizer tests. They were failing on Ubuntu 14.04 during preparation of 3.8.0 release. I don't know their current status.
I think you can ignore this if you are not going to use MemorySanitizer.

Kind regards,
Evgeny Astigeevich

Hello, Eugeny

Thanks for your answer.

The failed tests are MemorySanitizer tests. They were failing on
Ubuntu 14.04 during preparation of 3.8.0 release. I don't know their
current status. I think you can ignore this if you are not going to
use MemorySanitizer.

I discovered that same regression tests are broken not only in trunk
bat also in RELEASE_380/final (as you mentioned) and RELEASE_371/final.
You see, I wanted to test sanitizers from latests LLVM releases (which
are unavailable out of the box on Ubuntu 14.04) on our project. It is
the reason why I'm compiling LLVM from source in the first place.

Maybe you could recommend a relatively fresh LLVM release where all
sanitizers are still working?

Hi Aleksander,

Unfortunately, I cannot help you with this. I have not used sanitizers.
Have you tried to use them despite these failures? Are they working?
I think people who develop sanitizers can help you.
Ask their advice.

Kind regards,
Evgeny