[compiler-rt] r202847 - [CMake] Test for libdl and libpthread presence

Alexey Samsonov samsonov at google.com
Tue Mar 4 05:28:21 PST 2014


Author: samsonov
Date: Tue Mar  4 07:28:21 2014
New Revision: 202847

URL: http://llvm.org/viewvc/llvm-project?rev=202847&view=rev
Log:
[CMake] Test for libdl and libpthread presence

Modified:
    compiler-rt/trunk/cmake/config-ix.cmake
    compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
    compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
    compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt

Modified: compiler-rt/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/config-ix.cmake?rev=202847&r1=202846&r2=202847&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/config-ix.cmake (original)
+++ compiler-rt/trunk/cmake/config-ix.cmake Tue Mar  4 07:28:21 2014
@@ -1,4 +1,5 @@
 include(CheckCXXCompilerFlag)
+include(CheckLibraryExists)
 include(CheckSymbolExists)
 
 # CodeGen options.
@@ -38,3 +39,7 @@ check_cxx_compiler_flag(/wd4722 COMPILER
 
 # 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)

Modified: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/CMakeLists.txt?rev=202847&r1=202846&r2=202847&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt Tue Mar  4 07:28:21 2014
@@ -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.

Modified: compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/CMakeLists.txt?rev=202847&r1=202846&r2=202847&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/msan/tests/CMakeLists.txt Tue Mar  4 07:28:21 2014
@@ -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

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt?rev=202847&r1=202846&r2=202847&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt Tue Mar  4 07:28:21 2014
@@ -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





More information about the llvm-commits mailing list