[PATCH] When building with LLVM_ENABLE_CXX11 using cmake on OS X, try to use libc++. While the main LLVM code base does not required yet libc++ features, lld and lldb already rely on modern STL classes and so failed to compile on OS X if -stdlib=libc++ is...

Jean-Daniel Dupas devlists at shadowlab.org
Wed Dec 11 05:58:15 PST 2013


  Introduce a cmake LLVM_ENABLE_LIBCXX build parameter to compile using libc++ instead of the system default.

http://llvm-reviews.chandlerc.com/D2381

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2381?vs=6021&id=6022#toc

Files:
  CMakeLists.txt
  cmake/modules/HandleLLVMOptions.cmake

Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -180,6 +180,7 @@
 endif()
 
 option(LLVM_ENABLE_CXX11 "Compile with C++11 enabled." OFF)
+option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
 option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
 option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 
Index: cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- cmake/modules/HandleLLVMOptions.cmake
+++ cmake/modules/HandleLLVMOptions.cmake
@@ -250,6 +250,13 @@
     check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11)
     append_if(CXX_SUPPORTS_CXX11 "-std=c++11" CMAKE_CXX_FLAGS)
   endif (LLVM_ENABLE_CXX11)
+  if(LLVM_ENABLE_LIBCXX)
+    check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB)
+    append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_CXX_FLAGS)
+    append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_EXE_LINKER_FLAGS)
+    append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_SHARED_LINKER_FLAGS)
+    append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_MODULE_LINKER_FLAGS)
+  endif ()
 endif( MSVC )
 
 macro(append_common_sanitizer_flags)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2381.2.patch
Type: text/x-patch
Size: 1258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131211/7b7ca6cc/attachment.bin>


More information about the llvm-commits mailing list