summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-03-04 13:28:21 +0000
committerAlexey Samsonov <samsonov@google.com>2014-03-04 13:28:21 +0000
commit0e4063eb09c0b47d2e52b3b92478d993db76c163 (patch)
tree3958dc768a4136998581bdb9e2ce8dc335eea43d
parent4aed4a399b640ab5ca301a525b1054470da0fd18 (diff)
[CMake] Test for libdl and libpthread presence
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202847 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--cmake/config-ix.cmake5
-rw-r--r--lib/asan/tests/CMakeLists.txt8
-rw-r--r--lib/msan/tests/CMakeLists.txt4
-rw-r--r--lib/sanitizer_common/tests/CMakeLists.txt6
4 files changed, 14 insertions, 9 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index 3d514ecdd..7753c38f1 100644
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -1,4 +1,5 @@
include(CheckCXXCompilerFlag)
+include(CheckLibraryExists)
include(CheckSymbolExists)
# CodeGen options.
@@ -38,3 +39,7 @@ check_cxx_compiler_flag(/wd4722 COMPILER_RT_HAS_WD4722_FLAG)
# Symbols.
check_symbol_exists(__func__ "" COMPILER_RT_HAS_FUNC_SYMBOL)
+
+# Libraries.
+check_library_exists(dl dlopen "" COMPILER_RT_HAS_LIBDL)
+check_library_exists(pthread pthread_create "" COMPILER_RT_HAS_LIBPTHREAD)
diff --git a/lib/asan/tests/CMakeLists.txt b/lib/asan/tests/CMakeLists.txt
index d5040f036..15864c4be 100644
--- a/lib/asan/tests/CMakeLists.txt
+++ b/lib/asan/tests/CMakeLists.txt
@@ -69,11 +69,9 @@ if(NOT ANDROID)
endif()
set(ASAN_UNITTEST_NOINST_LINKFLAGS
- ${ASAN_UNITTEST_COMMON_LINKFLAGS}
- -ldl -lm)
-if(NOT ANDROID)
- list(APPEND ASAN_UNITTEST_NOINST_LINKFLAGS -lpthread)
-endif()
+ ${ASAN_UNITTEST_COMMON_LINKFLAGS} -lm)
+append_if(ASAN_UNITTEST_NOINST_LINKFLAGS COMPILER_RT_HAS_LIBDL -ldl)
+append_if(ASAN_UNITTEST_NOINST_LINKFLAGS COMPILER_RT_HAS_LIBPTHREAD -lpthread)
# Compile source for the given architecture, using compiler
# options in ${ARGN}, and add it to the object list.
diff --git a/lib/msan/tests/CMakeLists.txt b/lib/msan/tests/CMakeLists.txt
index 38eb0d141..0ae96d812 100644
--- a/lib/msan/tests/CMakeLists.txt
+++ b/lib/msan/tests/CMakeLists.txt
@@ -23,11 +23,11 @@ set(MSAN_LIBCXX_CFLAGS
-mno-omit-leaf-frame-pointer)
set(MSAN_LIBCXX_LINK_FLAGS
-nodefaultlibs
- -lpthread
-lrt
-lc
-lstdc++
-fsanitize=memory)
+append_if(MSAN_LIBCXX_LINK_FLAGS COMPILER_RT_HAS_LIBPTHREAD -lpthread)
# Unittest sources and build flags.
set(MSAN_UNITTEST_SOURCES msan_test.cc msan_test_main.cc)
@@ -61,10 +61,10 @@ set(MSAN_UNITTEST_INSTRUMENTED_CFLAGS
)
set(MSAN_UNITTEST_LINK_FLAGS
-fsanitize=memory
- -ldl
# FIXME: we build libcxx without cxxabi and need libstdc++ to provide it.
-lstdc++
)
+append_if(MSAN_UNITTEST_LINK_FLAGS COMPILER_RT_HAS_LIBDL -ldl)
set(MSAN_LOADABLE_LINK_FLAGS
-fsanitize=memory
-shared
diff --git a/lib/sanitizer_common/tests/CMakeLists.txt b/lib/sanitizer_common/tests/CMakeLists.txt
index 54287956e..1e6b38b61 100644
--- a/lib/sanitizer_common/tests/CMakeLists.txt
+++ b/lib/sanitizer_common/tests/CMakeLists.txt
@@ -41,7 +41,9 @@ set(SANITIZER_TEST_CFLAGS_COMMON
-Wall -Werror -Werror=sign-compare)
set(SANITIZER_TEST_LINK_FLAGS_COMMON
- -lstdc++ -ldl)
+ -lstdc++)
+append_if(SANITIZER_TEST_LINK_FLAGS_COMMON COMPILER_RT_HAS_LIBDL -ldl)
+append_if(SANITIZER_TEST_LINK_FLAGS_COMMON COMPILER_RT_HAS_LIBPTHREAD -lpthread)
include_directories(..)
include_directories(../..)
@@ -96,7 +98,7 @@ macro(add_sanitizer_tests_for_arch arch)
${SANITIZER_COMMON_LIB_NAME}
DEPS ${SANITIZER_TEST_OBJECTS} ${SANITIZER_COMMON_LIB}
LINK_FLAGS ${SANITIZER_TEST_LINK_FLAGS_COMMON}
- -lpthread ${TARGET_FLAGS})
+ ${TARGET_FLAGS})
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND "${arch}" STREQUAL "x86_64")
# Test that the libc-independent part of sanitizer_common is indeed