[libc-commits] [PATCH] D122481: [NFC][libc] Disable benchmarks when the LLVM benchmark target is not available

Guillaume Chatelet via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Mar 29 01:46:11 PDT 2022


gchatelet updated this revision to Diff 418820.
gchatelet added a comment.

rebase with all the diffs


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122481/new/

https://reviews.llvm.org/D122481

Files:
  libc/CMakeLists.txt
  libc/benchmarks/CMakeLists.txt


Index: libc/benchmarks/CMakeLists.txt
===================================================================
--- libc/benchmarks/CMakeLists.txt
+++ libc/benchmarks/CMakeLists.txt
@@ -43,6 +43,27 @@
 # 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 @@
     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
Index: libc/CMakeLists.txt
===================================================================
--- libc/CMakeLists.txt
+++ libc/CMakeLists.txt
@@ -161,7 +161,9 @@
   add_subdirectory(fuzzing)
 endif()
 
-add_subdirectory(benchmarks)
+if(LIBC_INCLUDE_BENCHMARKS)
+  add_subdirectory(benchmarks)
+endif()
 
 if (LIBC_INCLUDE_DOCS)
   add_subdirectory(docs)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122481.418820.patch
Type: text/x-patch
Size: 2048 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220329/918db158/attachment.bin>


More information about the libc-commits mailing list