Description
As a result of
llvm/llvm-zorg#325
llvm/llvm-zorg#342
The cmake option -DLIBC_INCLUDE_BENCHMARKS=ON
now fails to build when using llvm-projects/runtimes/
as the cmake root.
CMake Error at /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/benchmarks/CMakeLists.txt:35 (add_executable):
Target "libc-benchmark-test" links to target "benchmark::benchmark" but the
target was not found. Perhaps a find_package() call is missing for an
IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/benchmarks/CMakeLists.txt:111 (add_libc_benchmark_unittest)
I was able to fix this via:
diff --git a/libc/benchmarks/CMakeLists.txt b/libc/benchmarks/CMakeLists.txt
index 60f522d7d8c6..8dae3ea94a20 100644
--- a/libc/benchmarks/CMakeLists.txt
+++ b/libc/benchmarks/CMakeLists.txt
@@ -100,7 +100,7 @@ target_include_directories(libc-benchmark
)
target_link_libraries(libc-benchmark
PUBLIC
- benchmark::benchmark
+ benchmark
LLVMSupport
LLVMTargetParser
Threads::Threads
(Not sure if that's correct?). We can then configure the build, but ninja libc-benchmark-test
fails because it can't find the headers. Ok, fixed with:
diff --git a/libc/benchmarks/CMakeLists.txt b/libc/benchmarks/CMakeLists.txt
index 60f522d7d8c6..ccdb00459c8a 100644
--- a/libc/benchmarks/CMakeLists.txt
+++ b/libc/benchmarks/CMakeLists.txt
@@ -96,11 +96,11 @@ add_library(libc-benchmark
)
target_include_directories(libc-benchmark
- PUBLIC ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}
+ PUBLIC ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/libc/benchmarks/google-benchmark-libc/include/
)
target_link_libraries(libc-benchmark
PUBLIC
- benchmark::benchmark
+ benchmark
LLVMSupport
LLVMTargetParser
Threads::Threads
and then we fail to find llvm/ADT/ArrayRef.h. It turns out, llvm-project/libc/benchmarks/LibcBenchmark.h depends on llvm/ADT/ArrayRef.h and llvm/ADT/SmallVector.h.
That was surprising. To ensure llvm-libc doesn't have dependencies on LLVM itself, we should move the benchmark code to use our cpp::array and cpp::vector. Until then, I'm just going to remove -DLIBC_INCLUDE_BENCHMARKS=ON
and ninja libc-benchmark-test
from post submit to unblock the fullbuild builders. cc @gchatelet