Problems compiling within the clang source tree


I am trying to compile the example 'clang-interpreter' from path 'tools/clang/examples'. I copied that folder into the build-llvm folder I created for building llvm and clang, specifically in folder 'tools/clang/tools/'. When I do 'make' all I get is

make: *** No rule to make target `/home/blah/llvm/tools/clang/tools/clang-interpreter/Makefile', needed by `Makefile'. Stop.

I thought that my build was broken, but it was not. I tried downloading this example and placed it under the same 'tools/clang/tools/' folder as the clang interpreter. When I did 'make' it just compiled, created the Debug+Asserts folder in 'tools/clang/tools/LibToolingExample/Debug+Asserts/' and placed the binary under the '$LLVM_ROOT/Debug+Asserts/bin/' folder, and it works fine.

I tried copying the makefile from that LibToolingExample and changed only the name of source file to be compiled, it didn't work, I get the same error I described above.

From this I can tell that I'm doing something wrong as I don't fully understand the llvm-clang build system yet, I was able to compile an example but not the example provided in clang directory. Do you have any idea on what the problem is? Or do you have a hint of what Makefile or Documentation I should read to solve this?


P.D. I am able to able to compile the clang examples out of the llvm-clang source tree by providing the correct compiler flags, but I'd like to use the llvm-clang build system :slight_smile:

Can you give the list of commands you're using to do the "copying" and
the configuration etc? Might help figure out where you're going wrong.


I tried copying both with commands and from the Dolphin file manager (I use KDE), same result. I am also adding some commands so you can see the file permissions:

blah@blah-desktop:~/Projects/build-llvm/tools/clang/tools > cp -R ~/Projects/llvm/tools/clang/examples/clang-interpreter/ .
blah@blah-desktop:~/Projects/build-llvm/tools/clang/tools > cd clang-interpreter/
blah@blah-desktop:~/Projects/build-llvm/tools/clang/tools/clang-interpreter > make
make: *** No rule to make target `/home/aortegag/Projects/llvm/tools/clang/tools/clang-interpreter/Makefile', needed by `Makefile'. Stop.
blah@blah-desktop:~/Projects/build-llvm/tools/clang/tools/clang-interpreter > cd ../LibToolingExample/
blah@blah-desktop:~/Projects/build-llvm/tools/clang/tools/LibToolingExample > make
make: Nothing to be done for `all'.
blah@blah-desktop:~/Projects/build-llvm/tools/clang/tools/LibToolingExample > make clean
blah@blah-desktop:~/Projects/build-llvm/tools/clang/tools/LibToolingExample > make
llvm[0]: Compiling Example.cpp for Debug+Asserts build
llvm[0]: Linking Debug+Asserts executable example
llvm[0]: ======= Finished Linking Debug+Asserts Executable example
blah@blah-desktop:~/Projects/build-llvm/tools/clang/tools/LibToolingExample >
blah@blah-desktop:~/Projects/build-llvm/tools/clang/tools/LibToolingExample > ll
total 28

drwxr-xr-x 2 blah blah 4096 feb 20 21:16 Debug+Asserts
-rw-r--r-- 1 blah blah 4251 feb 17 22:04 Example.cpp
-rw-r--r-- 1 blah blah 545 feb 17 22:22 Makefile
-rw-r--r-- 1 blah blah 540 feb 17 22:04
-rwxr-xr-x 1 blah blah 128 feb 17 22:25
-rw-r--r-- 1 blah blah 118 feb 17 22:04 test.c
blah@blah-desktop:~/Projects/build-llvm/tools/clang/tools/LibToolingExample > ll ../clang-interpreter/
total 24
-rw-r--r-- 1 blah blah 578 feb 20 21:13 CMakeLists.txt
-rw-r--r-- 1 blah blah 5842 feb 20 21:13 main.cpp
-rw-r--r-- 1 blah blah 968 feb 20 21:13 Makefile
-rw-r--r-- 1 blah blah 653 feb 20 21:13 README.txt
-rw-r--r-- 1 blah blah 56 feb 20 21:13 test.c
blah@blah-desktop:~/Projects/build-llvm/tools/clang/tools/LibToolingExample >

The command line I used to configure llvm, and clang was:

../llvm/configure --enable-targets=host --prefix=$HOME/llvm CC=gcc CXX=g++ --enable-shared --enable-debug-symbols --enable-jit --enable-doxygen --enable-cxx11 --enable-keep-symbols

Yes, I want to step through clang code with the debugger :slight_smile:

Once again, thanks for the help and your time. I hope this info can help spot the problem.

Yeah, that copy should be into the source tree, not the build tree.