[libcxx] r346744 - Attempt to make benchmarks fall back to -std=c++1z when C++17 isn't supported.

Eric Fiselier eric at efcs.ca
Mon Nov 12 23:03:17 PST 2018


Author: ericwf
Date: Mon Nov 12 23:03:16 2018
New Revision: 346744

URL: http://llvm.org/viewvc/llvm-project?rev=346744&view=rev
Log:
Attempt to make benchmarks fall back to -std=c++1z when C++17 isn't supported.

The benchmarks currently require C++17, however Clang 3.9 doesn't
support -std=c++17 while still supporting all the C++17 features needed
to compile the benchmarks.

This patch makes the benchmark build attempt to fall back to -std=c++1z
when -std=c++17 isn't supported.

See llvm.org/PR39629

Modified:
    libcxx/trunk/benchmarks/CMakeLists.txt

Modified: libcxx/trunk/benchmarks/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/CMakeLists.txt?rev=346744&r1=346743&r2=346744&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/CMakeLists.txt (original)
+++ libcxx/trunk/benchmarks/CMakeLists.txt Mon Nov 12 23:03:16 2018
@@ -67,8 +67,19 @@ add_custom_target(cxx-benchmarks)
 set(BENCHMARK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
 set(BENCHMARK_LIBCXX_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx)
 set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native)
+
+check_flag_supported("-std=c++17")
+mangle_name("LIBCXX_SUPPORTS_STD_EQ_c++17_FLAG" BENCHMARK_SUPPORTS_STD_CXX17_FLAG)
+if (${BENCHMARK_SUPPORTS_STD_CXX17_FLAG})
+  set(BENCHMARK_DIALECT_FLAG "-std=c++17")
+else()
+  # If the compiler doesn't support -std=c++17, attempt to fall back to -std=c++1z while still
+  # requiring C++17 language features.
+  set(BENCHMARK_DIALECT_FLAG "-std=c++1z")
+endif()
+
 set(BENCHMARK_TEST_COMPILE_FLAGS
-    -std=c++17 -O2
+    ${BENCHMARK_DIALECT_FLAG} -O2
     -I${BENCHMARK_LIBCXX_INSTALL}/include
     -I${LIBCXX_SOURCE_DIR}/test/support
 )




More information about the libcxx-commits mailing list