Compiling and running clangs unit tests

Hey all,

in preparation of working on clang, I want to compile and run the unit tests,
specifically those for the clang-c part.

I read and tried to run `make clang-test`
in my external build folder, but that fails at link time:

This is using the latest versions of the release_37 branches in both, LLVM and
clang. Could someone tell me what's going wrong here?


How did you configure? I’m a bit surprised by bulid/clang path. It looks like you’re building Clang but not LLVM?

How did you configure? I'm a bit surprised by bulid/clang path. It looks
like you're building Clang but not LLVM?

Yes, I'm building Clang.

I have:


The former two are checkouts of the release_37 branches of the corresponding*.git repositories. I configured them basically

build/llvm$ cmake ../../src/llvm -DCMAKE_BUILD_TYPE=RelWithDebInfo -

and then same for clang. Everything compiles and works just fine, except for
the unit tests. And those are only compiled for me when I run `make clang-
test` manually, i.e. they are not included in the "normal" make call - is this

Or does clang not support out of source builds?

  1. – Found LLVM_CONFIG as /home/milian/projects/compiled/other/bin/llvm-config

This makes me believe your clang build is not using the llvm you just built? Do you have installed version of LLVM on your distro?

I used to build Clang out of source on Windows and you had to provide path to LLVM but I can’t see that in CMake gui anymore (on Linux). The only thing I can suggest is to move clang inside llvm/tools and build in-tree. That will work 100%

Sorry Nikola,

the email I wrote was written by hand and used a made up prefix. In reality, I
install into the prefix you see there. Here are my CMakeCache.txt files:


Sorry for the confusion, hope this is more explicit.


So I have no idea what the problem is. It might be using autotools, it might be the fact that you’re installing llvm. Here’s what I tried on my Ubuntu VM.

Source from branches/release_37
llvm in ~/llvm
clang in ~/clang
inside ~/build_llvm: cmake -g Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo …/llvm
inside ~/build_llvm: ninja
inside ~/build_clang: cmake -g Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_CONFIG=~/build_llvm/bin/llvm-config …/clang
inside ~/build_clang: ninja clang-test

This works for me. I strongly suggest passing the following flags to both cmake configure steps as it makes building much faster:


Hope this helps.

If you checkout clang into llvm/tools/clang, configuring and building llvm will also do the same for clang.
You cna then test everything with make -check-all.