[libcxx-commits] [libcxx] r374053 - [libc++] Add missing link-time dependencies to the benchmarks

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 8 07:28:57 PDT 2019


Author: ldionne
Date: Tue Oct  8 07:28:56 2019
New Revision: 374053

URL: http://llvm.org/viewvc/llvm-project?rev=374053&view=rev
Log:
[libc++] Add missing link-time dependencies to the benchmarks

Since the benchmarks build with -nostdlib, they need to manually link
against some system libraries that are used by the benchmarks and the
GoogleBenchmark library itself.

Previously, we'd rely on the fact that these libraries were linked
through the PUBLIC dependencies of cxx_shared/cxx_static. However,
if we were to make these dependencies PRIVATE (as they should be
because they are implementation details of libc++), the benchmarks
would fail to link. This commit remediates that.

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=374053&r1=374052&r2=374053&view=diff
==============================================================================
--- libcxx/trunk/benchmarks/CMakeLists.txt (original)
+++ libcxx/trunk/benchmarks/CMakeLists.txt Tue Oct  8 07:28:56 2019
@@ -146,6 +146,15 @@ function(add_benchmark_test name source_
   if (LLVM_USE_SANITIZER)
     target_link_libraries(${libcxx_target} PRIVATE -ldl)
   endif()
+  if (LIBCXX_HAS_C_LIB)
+    target_link_libraries(${libcxx_target} PRIVATE -lc)
+  endif()
+  if (LIBCXX_HAS_M_LIB)
+    target_link_libraries(${libcxx_target} PRIVATE -lm)
+  endif()
+  if (LIBCXX_HAS_PTHREAD_LIB)
+    target_link_libraries(${libcxx_target} PRIVATE -lpthread)
+  endif()
   set_target_properties(${libcxx_target}
     PROPERTIES
           OUTPUT_NAME "${name}.libcxx.out"




More information about the libcxx-commits mailing list