Hi.
I’m building clang for the first time.
I just cloned llvm-project, mkdir build && cd build
and then cmake .. && make
when llvm build completed, then I cd clang && mkdir build && cd build
, then cmake ..
and make clang
. so clang built, I needed some libraries. some of them were built but some of them like clangParser.a
, clangTooling.a
and clangRewriteCore.a
that actually are necessary for me weren’t built. so I came back and run make clangTooling
but got me this error:
/home/rdwn/Projects/compiler/llvm-project-main/clang/include/clang/Basic/ObjCRuntime.h:21:10: fatal error: llvm/Support/HashBuilder.h: No such file or directory
21 | #include "llvm/Support/HashBuilder.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
usually at 28% of progress. all other libraries leads to this error. what should I do?
The preferred way to build llvm and clang is to use the following cmake options:
cmake -DLLVM_ENABLE_PROJECTS=clang ../llvm
make all
This will build all the enabled projects, if you later want to build LLD for example you just add that to the enable projects.
1 Like
As Tobias indicated, the preferred way is to build clang and LLVM in one shot with -DLLVM_ENABLE_PROJECTS=clang
.
What happens with your cmake
invocation for clang is that it is likely picking up an installed version of LLVM which is outdated.
You could point it to the LLVM you just built with other CMake arguments: it is a supported configuration, see here: RFC: Stand-alone build support
1 Like
tnx, I will try it.
so I must remove all previuse builds?
I just remove my old llvm project and clone it again.
then in root of project mkdir build && cd build
, then
cmake -DLLVM_ENABLE_PROJECTS=clang ../llvm
make all -j 8
but this error occurred and confused me:
make[2]: *** [tools/lto/CMakeFiles/LTO.dir/build.make:277: lib/libLTO.so.14] Error 1
make[2]: *** Deleting file 'lib/libLTO.so.14'
make[1]: *** [CMakeFiles/Makefile2:31475: tools/lto/CMakeFiles/LTO.dir/all] Error 2
collect2: fatal error: ld terminated with signal 9 [Killed]
compilation terminated.
this error occurred some other wheres. the progress percent is about 97%.
I’m completely confused, please help me
Your linker dies - most likely because it runs out of memory. You can fix this in a few different ways:
Use another linker: gold and lld is much more memory efficient
Turn off debug symbols since they use a lot of memory.