[libcxx] r269070 - [libcxx] Prefer C++14 over C++11 when building libc++experimental.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Tue May 10 09:17:44 PDT 2016


Author: ericwf
Date: Tue May 10 11:17:43 2016
New Revision: 269070

URL: http://llvm.org/viewvc/llvm-project?rev=269070&view=rev
Log:
[libcxx] Prefer C++14 over C++11 when building libc++experimental.

Summary:
Currently libc++experimental builds with C++11. This patch changes that to C++14 when supported by the compiler. Although nothing currently requires C++14 the upcoming <experimental/memory_resource> implementation would benefit from it. [1]

Note that libc++.so continues to build with C++11 and is unaffected by this change.

[1] <experimental/memory_resource> provides global resources which must exist for the entire lifetime of the program. In order to ensure that a global resource can be used during program termination there destructors must never be invoked. The only way to do this, while also allowing "constant initialization", is to use a C++14 union.


Reviewers: mclow.lists

Subscribers: pete, cfe-commits

Differential Revision: http://reviews.llvm.org/D19992

Modified:
    libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake
    libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake?rev=269070&r1=269069&r2=269070&view=diff
==============================================================================
--- libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake Tue May 10 11:17:43 2016
@@ -35,6 +35,11 @@ macro(remove_flags)
   endforeach()
 endmacro(remove_flags)
 
+macro(check_flag_supported flag)
+    mangle_name("${flag}" flagname)
+    check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
+endmacro()
+
 # Add a macro definition if condition is true.
 macro(define_if condition def)
   if (${condition})

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=269070&r1=269069&r2=269070&view=diff
==============================================================================
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Tue May 10 11:17:43 2016
@@ -142,9 +142,15 @@ if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp)
   add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES})
   target_link_libraries(cxx_experimental cxx)
+
+  set(experimental_flags "${LIBCXX_COMPILE_FLAGS}")
+  check_flag_supported(-std=c++14)
+  if (NOT MSVC AND LIBCXX_SUPPORTS_STD_EQ_CXX14_FLAG)
+    string(REPLACE "-std=c++11" "-std=c++14" experimental_flags "${LIBCXX_COMPILE_FLAGS}")
+  endif()
   set_target_properties(cxx_experimental
     PROPERTIES
-      COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
+      COMPILE_FLAGS "${experimental_flags}"
       OUTPUT_NAME   "c++experimental"
   )
 endif()




More information about the cfe-commits mailing list