Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2022-03-25 16:21:20 +0300
committerGuillaume Chatelet <gchatelet@google.com>2022-03-29 11:45:53 +0300
commitdf838dbcfa9da0c15d5115fe3e643ee032d39a79 (patch)
treee9fbc78653e53f7cc6af23da2bade1021a63c66e /libc
parent6a01b676cfb227bf7ca8a7b6ff1b466e33a33d1f (diff)
[NFC][libc] Disable benchmarks when the LLVM benchmark target is not available
Fixes https://github.com/llvm/llvm-project/issues/53686 Differential Revision: https://reviews.llvm.org/D122481
Diffstat (limited to 'libc')
-rw-r--r--libc/CMakeLists.txt4
-rw-r--r--libc/benchmarks/CMakeLists.txt26
2 files changed, 27 insertions, 3 deletions
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 6ce6c149113e..ca9a81991fa9 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -161,7 +161,9 @@ if(LLVM_INCLUDE_TESTS)
add_subdirectory(fuzzing)
endif()
-add_subdirectory(benchmarks)
+if(LIBC_INCLUDE_BENCHMARKS)
+ add_subdirectory(benchmarks)
+endif()
if (LIBC_INCLUDE_DOCS)
add_subdirectory(docs)
diff --git a/libc/benchmarks/CMakeLists.txt b/libc/benchmarks/CMakeLists.txt
index 0e9ec5a1f790..c67dadf0f1f8 100644
--- a/libc/benchmarks/CMakeLists.txt
+++ b/libc/benchmarks/CMakeLists.txt
@@ -43,6 +43,27 @@ endfunction()
# Build Google Benchmark for libc
#==============================================================================
+include(ExternalProject)
+ExternalProject_Add(google-benchmark-libc
+ EXCLUDE_FROM_ALL ON
+ PREFIX google-benchmark-libc
+ SOURCE_DIR ${LLVM_THIRD_PARTY_DIR}/benchmark
+ INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/google-benchmark-libc
+ CMAKE_CACHE_ARGS
+ -DBENCHMARK_ENABLE_EXCEPTIONS:BOOL=OFF
+ -DBENCHMARK_ENABLE_LTO:BOOL=OFF
+ -DBENCHMARK_ENABLE_TESTING:BOOL=OFF
+ -DBENCHMARK_ENABLE_WERROR:BOOL=${LLVM_ENABLE_WERROR}
+ -DBENCHMARK_FORCE_WERROR:BOOL=OFF
+ -DBENCHMARK_USE_LIBCXX:BOOL=OFF
+ -DCMAKE_BUILD_TYPE:STRING=RELEASE
+ -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
+ -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
+ -DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_LIBC_COMPILE_FLAGS}
+ -DCMAKE_CXX_STANDARD:STRING=14
+ -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+ )
+
add_custom_target(libc-benchmark-util-tests)
# libc-benchmark
@@ -52,13 +73,14 @@ add_library(libc-benchmark
LibcBenchmark.cpp
LibcBenchmark.h
)
-add_dependencies(libc-benchmark benchmark)
+
target_link_libraries(libc-benchmark
PUBLIC
- benchmark
+ benchmark::benchmark
LLVMSupport
Threads::Threads
)
+add_dependencies(libc-benchmark google-benchmark-libc)
llvm_update_compile_flags(libc-benchmark)
add_libc_benchmark_unittest(libc-benchmark-test