Reputation: 2492
I recently built and installed llvm to my system with the expectation that this would be what is neccessary to build qtcreator: https://paste.ubuntu.com/p/23GCCS5xxS/
Based on what I saw there, I set the variable as such:
➜ qt6.2 git:(6.2) ✗ echo $LLVM_INSTALL_DIR
/usr/local/lib/cmake/llvm/
However when configuring Qt6.2, it still gives
WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.
Either set CMAKE_PREFIX_PATH or LLVM_INSTALL_DIR to the location of your llvm installation.
And from what I understand, when I built llvm, I didn't build Clang with it. Based on https://clang.llvm.org/get_started.html it gives the following line:
cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm
make
#This builds both LLVM and Clang for debug mode.
Which is frustrating because I now have to build it again, which takes forever. I'd just like the command that builds and installs everything from llvm, so I don't have to keep going back to these things. Is that possible?
Upvotes: 8
Views: 13844
Reputation: 19916
To build everything, do this:
$ git clone --depth 1 --branch llvmorg-19.1.0 https://github.com/llvm/llvm-project.git
$ cmake -S llvm-project/llvm -B llvm-project/build \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS=all \
-DLLVM_ENABLE_RUNTIMES=all
$ cmake --build llvm-project/build -j8
$ cmake --install llvm-project/build --prefix /usr/local # or somewhere else
You might also be interested in the following build flags for the first CMake command:
-DLLVM_ENABLE_ASSERTIONS=ON
-- good for debugging-DLLVM_ENABLE_EH=ON
-- enable if your application uses C++ exceptions-DLLVM_ENABLE_RTTI=ON
-- enable if your application uses C++ RTTIAlso see the upstream documentation: https://llvm.org/docs/CMake.html
Note that some of the LLVM projects can only be built with clang. I won't get into bootstrapping issues, but if the build fails, you can winnow down the list of projects from all
to a subset of the following: clang
, clang-tools-extra
, cross-project-tests
, libc
, libclc
, lld
, lldb
, openmp
, polly
, and pstl
.
You can also reduce the list of runtimes to a subset of compiler-rt
, libc
, libcxx
, libcxxabi
, libunwind
, and openmp
.
Note that LLVM_ENABLE_PROJECTS
and LLVM_ENABLE_RUNTIMES
should not overlap. The latter builds each target with the just-built clang.
Upvotes: 17
Reputation: 112
These are the steps I use taken from here:
mkdir llvm
cd llvm
git clone https://github.com/llvm/llvm-project.git .
git clone https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git
git clone https://github.com/intel/opencl-clang.git
git clone https://github.com/KhronosGroup/SPIRV-Headers.git ./llvm/projects/SPIRV-Headers
git clone https://github.com/intel/vc-intrinsics.git ./llvm/projects/vc-intrinsics
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=”X86″ -DLLVM_ENABLE_PROJECTS=”clang” -DLLVM_EXTERNAL_PROJECTS=”llvm-spirv;opencl-clang” -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=”../SPIRV-LLVM-Translator” -DLLVM_EXTERNAL_OPENCL_CLANG_SOURCE_DIR=”../opencl-clang” ../llvm
make opencl-clang
Upvotes: 2