Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit caa8e2c

Browse files
committed
[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. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@374053 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c788361 commit caa8e2c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

benchmarks/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ function(add_benchmark_test name source_file)
146146
if (LLVM_USE_SANITIZER)
147147
target_link_libraries(${libcxx_target} PRIVATE -ldl)
148148
endif()
149+
if (LIBCXX_HAS_C_LIB)
150+
target_link_libraries(${libcxx_target} PRIVATE -lc)
151+
endif()
152+
if (LIBCXX_HAS_M_LIB)
153+
target_link_libraries(${libcxx_target} PRIVATE -lm)
154+
endif()
155+
if (LIBCXX_HAS_PTHREAD_LIB)
156+
target_link_libraries(${libcxx_target} PRIVATE -lpthread)
157+
endif()
149158
set_target_properties(${libcxx_target}
150159
PROPERTIES
151160
OUTPUT_NAME "${name}.libcxx.out"

0 commit comments

Comments
 (0)