CMake warning when compiling Clang/LLVM


when I run cmake I get the following warning:


when I run cmake I get the following warning:

CMake Warning at cmake/modules/HandleLLVMStdlib.cmake:24 (message):
  Can't specify libc++ with '-stdlib='
Call Stack (most recent call first):
  cmake/config-ix.cmake:15 (include)
  CMakeLists.txt:580 (include)

I am using GCC 4.8.5 to build on a x86_64 machine with RedHat OS.

Any idea why?

What arguments are you passing to CMake and which version of LLVM are you
trying to build?


That's probably -DLLVM_ENABLE_LIBCXX=ON and the warning tells you the reason: -stdlib= is only supported if compiling with Clang, you can't specify it with GCC.


Thanks, that’s the reason.

So to clarify, I should use -DLLVM_ENABLE_LIBCXX=ON only if I am building clang with clang?
I got confused, I thought it was for building libc++, but having that under projects seems to be enough.


If libc++ is under projects/ it will get built. What LLVM_ENABLE_LIBCXX does is to enable _linking_ all LLVM libraries and binaries to libc++ as the C++ STL and that's only supported with Clang. You can specify the option when building with GCC, it just won't work and issue the warning you are seeing.


I had problems building the llvm libcxx libraries with gcc 5.3. I then used gcc 7 and my problems went away. That doesn’t answer your question, but might be helpful down the road. :slight_smile: Ciao Nat!