[libcxx] r279999 - Turn On -DLIBCXX_ENABLE_BENCHMARKS by default.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 29 12:50:50 PDT 2016


Author: ericwf
Date: Mon Aug 29 14:50:49 2016
New Revision: 279999

URL: http://llvm.org/viewvc/llvm-project?rev=279999&view=rev
Log:
Turn On -DLIBCXX_ENABLE_BENCHMARKS by default.

This patch enables the `cxx-benchmarks` target by default. Note that the target
still has to be manually invoked since it isn't included in the default 'make'
rule.

This patch also gets the benchmarks building w/ GCC. The build previously
required the '-stdlib=libc++' flag but upstream patches to Google Benchmark
now allow the library to build w/ libc++ and GCC.

These changes should make the benchmarks easier to build and test.

Modified:
    libcxx/trunk/CMakeLists.txt
    libcxx/trunk/benchmarks/CMakeLists.txt
    libcxx/trunk/docs/BuildingLibcxx.rst
    libcxx/trunk/docs/TestingLibcxx.rst

Modified: libcxx/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=279999&r1=279998&r2=279999&view=diff
==============================================================================
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Aug 29 14:50:49 2016
@@ -57,7 +57,7 @@ option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRAR
 option(LIBCXX_ENABLE_FILESYSTEM
         "Build filesystem as part of libc++experimental.a" ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY})
 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
-option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependancies" OFF)
+option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependancies" ON)
 option(LIBCXX_BUILD_BENCHMARK_NATIVE_STDLIB "Build the benchmarks against the native STL" OFF)
 option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS})
 set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING

Modified: libcxx/trunk/benchmarks/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/CMakeLists.txt?rev=279999&r1=279998&r2=279999&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/CMakeLists.txt (original)
+++ libcxx/trunk/benchmarks/CMakeLists.txt Mon Aug 29 14:50:49 2016
@@ -4,21 +4,20 @@ include(CheckCXXCompilerFlag)
 #==============================================================================
 # Build Google Benchmark for libc++
 #==============================================================================
-check_cxx_compiler_flag(-stdlib=libc++ LIBCXX_HAS_NO_STDLIB_LIBCXX_FLAG)
-if (NOT LIBCXX_HAS_NO_STDLIB_LIBCXX_FLAG)
-  message(FATAL "Benchmark requires support for the -stdlib=libc++ flag")
-endif()
 
 set(BENCHMARK_LIBCXX_COMPILE_FLAGS
     -Wno-unused-command-line-argument
     -nostdinc++
-    -cxx-isystem ${LIBCXX_SOURCE_DIR}/include
-    -stdlib=libc++)
-set(BENCHMARK_LIBCXX_LINK_FLAGS
+    -isystem ${LIBCXX_SOURCE_DIR}/include
     -L${LIBCXX_LIBRARY_DIR}
-    -Wl,-rpath,${LIBCXX_LIBRARY_DIR})
+    -Wl,-rpath,${LIBCXX_LIBRARY_DIR}
+    )
+if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH)
+  list(APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS
+          -L${LIBCXX_CXX_ABI_LIBRARY_PATH}
+          -Wl,-rpath,${LIBCXX_CXX_ABI_LIBRARY_PATH})
+endif()
 split_list(BENCHMARK_LIBCXX_COMPILE_FLAGS)
-split_list(BENCHMARK_LIBCXX_LINK_FLAGS)
 
 ExternalProject_Add(google-benchmark-libcxx
         EXCLUDE_FROM_ALL ON
@@ -32,8 +31,7 @@ ExternalProject_Add(google-benchmark-lib
           -DCMAKE_BUILD_TYPE:STRING=RELEASE
           -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
           -DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_LIBCXX_COMPILE_FLAGS}
-          -DCMAKE_SHARED_LINK_FLAGS:STRING=${BENCHMARK_LIBCXX_LINK_FLAGS}
-          -DCMAKE_EXE_LINK_FLAGS:STRING=${BENCHMARK_LIBCXX_LINK_FLAGS}
+          -DBENCHMARK_USE_LIBCXX:BOOL=ON
           -DBENCHMARK_ENABLE_TESTING:BOOL=OFF)
 
 #==============================================================================
@@ -46,18 +44,17 @@ if (LIBCXX_BUILD_BENCHMARK_NATIVE_STDLIB
         SOURCE_DIR ${LIBCXX_SOURCE_DIR}/utils/google-benchmark
         INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native
         CMAKE_CACHE_ARGS
-          -DBENCHMARK_ENABLE_TESTING:BOOL=OFF
-        CMAKE_CACHE_ARGS
           -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
           -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
           -DCMAKE_BUILD_TYPE:STRING=RELEASE
-          -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>)
+          -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+          -DBENCHMARK_ENABLE_TESTING:BOOL=OFF)
 endif()
 
 #==============================================================================
 # Benchmark tests configuration
 #==============================================================================
-add_custom_target(libcxx-benchmarks)
+add_custom_target(cxx-benchmarks)
 
 set(BENCHMARK_LIBCXX_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx)
 set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native)
@@ -67,7 +64,7 @@ set(BENCHMARK_TEST_COMPILE_FLAGS
 )
 set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS
     -nostdinc++
-    -cxx-isystem ${LIBCXX_SOURCE_DIR}/include
+    -isystem ${LIBCXX_SOURCE_DIR}/include
     ${BENCHMARK_TEST_COMPILE_FLAGS}
     -Wno-user-defined-literals
 )
@@ -86,7 +83,7 @@ macro(add_benchmark_test name source_fil
   set(libcxx_target ${name}_libcxx)
   add_executable(${libcxx_target} EXCLUDE_FROM_ALL ${source_file})
   add_dependencies(${libcxx_target} cxx google-benchmark-libcxx)
-  add_dependencies(libcxx-benchmarks ${libcxx_target})
+  add_dependencies(cxx-benchmarks ${libcxx_target})
   if (LIBCXX_ENABLE_SHARED)
     target_link_libraries(${libcxx_target} cxx_shared)
   else()
@@ -106,7 +103,7 @@ macro(add_benchmark_test name source_fil
     if (LIBCXX_HAS_PTHREAD_LIB)
       target_link_libraries(${native_target} -pthread)
     endif()
-    add_dependencies(libcxx-benchmarks ${native_target})
+    add_dependencies(cxx-benchmarks ${native_target})
     set_target_properties(${native_target}
       PROPERTIES
           OUTPUT_NAME "${name}.native.out"
@@ -123,7 +120,7 @@ endmacro()
 file(GLOB BENCHMARK_TESTS "*.bench.cpp")
 foreach(test_path ${BENCHMARK_TESTS})
   get_filename_component(test_file "${test_path}" NAME)
-  message(STATUS "TEST: ${test_file}")
+  message(STATUS "-- Adding Benchmark: ${test_file}")
   string(REPLACE ".bench.cpp" "" test_name "${test_file}")
   add_benchmark_test(${test_name} ${test_file})
 endforeach()

Modified: libcxx/trunk/docs/BuildingLibcxx.rst
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/BuildingLibcxx.rst?rev=279999&r1=279998&r2=279999&view=diff
==============================================================================
--- libcxx/trunk/docs/BuildingLibcxx.rst (original)
+++ libcxx/trunk/docs/BuildingLibcxx.rst Mon Aug 29 14:50:49 2016
@@ -251,7 +251,7 @@ libc++ Feature Options
 
 .. option:: LIBCXX_INCLUDE_BENCHMARKS:BOOL
 
-  **Default**: ``OFF``
+  **Default**: ``ON``
 
   Build the libc++ benchmark tests and the Google Benchmark library needed
   to support them.

Modified: libcxx/trunk/docs/TestingLibcxx.rst
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/TestingLibcxx.rst?rev=279999&r1=279998&r2=279999&view=diff
==============================================================================
--- libcxx/trunk/docs/TestingLibcxx.rst (original)
+++ libcxx/trunk/docs/TestingLibcxx.rst Mon Aug 29 14:50:49 2016
@@ -214,17 +214,16 @@ For more information about using the Goo
 Building Benchmarks
 -------------------
 
-The benchmark tests are not enabled by default. To build the benchmarks
-libc++ must be configured using the CMake option ``-DLIBCXX_INCLUDE_BENCHMARKS=ON``.
-Then the benchmarks can be built using the ``libcxx-benchmarks`` target.
+The benchmark tests are not built by default. The benchmarks can be built using
+the ``cxx-benchmarks`` target.
 
 An example build would look like:
 
 .. code-block:: bash
 
   $ cd build
-  $ cmake [options] -DLIBCXX_INCLUDE_BENCHMARKS=ON <path to libcxx sources>
-  $ make libcxx-benchmarks
+  $ cmake [options] <path to libcxx sources>
+  $ make cxx-benchmarks
 
 This will build all of the benchmarks under ``<libcxx-src>/benchmarks`` to be
 built against the just-built libc++. The compiled tests are output into
@@ -252,7 +251,7 @@ For example:
 .. code-block:: bash
 
   $ cd build/benchmarks
-  $ make libcxx-benchmarks
+  $ make cxx-benchmarks
   $ ./algorithms.libcxx.out # Runs all the benchmarks
   $ ./algorithms.libcxx.out --benchmark_filter=BM_Sort.* # Only runs the sort benchmarks
 




More information about the cfe-commits mailing list