Building clang and llvm

Hello all

I’m new to clang and llvm. Yesterday I built the newest version of clang and llvm (version 7.0). But today I came to know clang uses -libstdc++ as a default c++ standard library. Unfortunately, my gcc is 5.4.0, so clang still points to the old libstdc++ which doesn’t support some features of c++17. Is there any way to build clang and llvm based on already pre-installed clang,llvm and make it use libc++ by default?

There was one solution I came across the internet but it suggests me to update the gcc to the newest version, so that clang can use the newest version of libstdc++ and I can make use of c++17 features. But I don’t want to update gcc. I would like to have a solution with clang and llvm. Any answers or suggestions are highly appreciated.


Hi Praveen,

When configuring your LLVM & Clang build you can set the CMAKE_CXX_COMPILER and CMAKE_C_COMPILER options on your CMake command line. To use libc++, you can set LLVM_ENABLE_LIBCXX=On during configuration time.

If you haven’t already, I suggest you look over the documentation of LLVM’s build system here:

It lists many commonly used options and gives a basic explanation of how to use CMake.