[llvm] r330761 - [cmake] Fix libc++ detection

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 24 12:47:39 PDT 2018


Author: smeenai
Date: Tue Apr 24 12:47:39 2018
New Revision: 330761

URL: http://llvm.org/viewvc/llvm-project?rev=330761&view=rev
Log:
[cmake] Fix libc++ detection

-stdlib=libc++ is added to both the compilation and the link flags, but
the logic for adding it was only checking if it was supported during
compilation and not linking. This could lead to false positives, for
example when using clang with libstdc++ (where the compiler would
support -stdlib=libc++ but then linking would fail because of libc++
actually being unavailable).

Modified:
    llvm/trunk/cmake/modules/HandleLLVMStdlib.cmake

Modified: llvm/trunk/cmake/modules/HandleLLVMStdlib.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMStdlib.cmake?rev=330761&r1=330760&r2=330761&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMStdlib.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMStdlib.cmake Tue Apr 24 12:47:39 2018
@@ -13,10 +13,12 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
   endfunction()
 
   include(CheckCXXCompilerFlag)
+  include(CheckLinkerFlag)
   if(LLVM_ENABLE_LIBCXX)
     if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
-      check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB)
-      if(CXX_SUPPORTS_STDLIB)
+      check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
+      check_linker_flag("-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
+      if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
         append("-stdlib=libc++"
           CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
           CMAKE_MODULE_LINKER_FLAGS)




More information about the llvm-commits mailing list