[llvm] r262344 - Refactor duplicated code for linking with pthread.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 1 07:54:40 PST 2016


Author: rafael
Date: Tue Mar  1 09:54:40 2016
New Revision: 262344

URL: http://llvm.org/viewvc/llvm-project?rev=262344&view=rev
Log:
Refactor duplicated code for linking with pthread.

Modified:
    llvm/trunk/cmake/config-ix.cmake
    llvm/trunk/examples/ParallelJIT/CMakeLists.txt
    llvm/trunk/lib/CodeGen/CMakeLists.txt
    llvm/trunk/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt
    llvm/trunk/lib/Fuzzer/CMakeLists.txt
    llvm/trunk/lib/Support/CMakeLists.txt
    llvm/trunk/unittests/Support/CMakeLists.txt

Modified: llvm/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=262344&r1=262343&r2=262344&view=diff
==============================================================================
--- llvm/trunk/cmake/config-ix.cmake (original)
+++ llvm/trunk/cmake/config-ix.cmake Tue Mar  1 09:54:40 2016
@@ -107,6 +107,10 @@ if( NOT PURE_WINDOWS )
   check_library_exists(rt clock_gettime "" HAVE_LIBRT)
 endif()
 
+if(HAVE_LIBPTHREAD)
+  set(PTHREAD_LIB pthread)
+endif()
+
 # Don't look for these libraries on Windows. Also don't look for them if we're
 # using MSan, since uninstrmented third party code may call MSan interceptors
 # like strlen, leading to false positives.

Modified: llvm/trunk/examples/ParallelJIT/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ParallelJIT/CMakeLists.txt?rev=262344&r1=262343&r2=262344&view=diff
==============================================================================
--- llvm/trunk/examples/ParallelJIT/CMakeLists.txt (original)
+++ llvm/trunk/examples/ParallelJIT/CMakeLists.txt Tue Mar  1 09:54:40 2016
@@ -11,6 +11,4 @@ add_llvm_example(ParallelJIT
   ParallelJIT.cpp
   )
 
-if(HAVE_LIBPTHREAD)
-  target_link_libraries(ParallelJIT pthread)
-endif(HAVE_LIBPTHREAD)
+target_link_libraries(ParallelJIT ${PTHREAD_LIB})

Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=262344&r1=262343&r2=262344&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ llvm/trunk/lib/CodeGen/CMakeLists.txt Tue Mar  1 09:54:40 2016
@@ -1,8 +1,3 @@
-set(system_libs)
-if(CMAKE_HOST_UNIX AND LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD)
-  set(system_libs ${system_libs} pthread)
-endif()
-
 add_llvm_library(LLVMCodeGen
   AggressiveAntiDepBreaker.cpp
   AllocationOrder.cpp
@@ -135,7 +130,7 @@ add_llvm_library(LLVMCodeGen
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/CodeGen/PBQP
 
-  LINK_LIBS ${system_libs}
+  LINK_LIBS ${PTHREAD_LIB}
   )
 
 add_dependencies(LLVMCodeGen intrinsics_gen)

Modified: llvm/trunk/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt?rev=262344&r1=262343&r2=262344&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt (original)
+++ llvm/trunk/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt Tue Mar  1 09:54:40 2016
@@ -3,9 +3,9 @@ include_directories( ${CMAKE_CURRENT_SOU
 if( HAVE_LIBDL )
     set(LLVM_INTEL_JIT_LIBS ${CMAKE_DL_LIBS})
 endif()
-if( HAVE_LIBPTHREAD )
-    set(LLVM_INTEL_JIT_LIBS pthread ${LLVM_INTEL_JIT_LIBS})
-endif()
+
+set(LLVM_INTEL_JIT_LIBS ${PTHREAD_LIB} ${LLVM_INTEL_JIT_LIBS})
+
 
 add_llvm_library(LLVMIntelJITEvents
   IntelJITEventListener.cpp

Modified: llvm/trunk/lib/Fuzzer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/CMakeLists.txt?rev=262344&r1=262343&r2=262344&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/CMakeLists.txt (original)
+++ llvm/trunk/lib/Fuzzer/CMakeLists.txt Tue Mar  1 09:54:40 2016
@@ -18,16 +18,12 @@ if( LLVM_USE_SANITIZE_COVERAGE )
   add_library(LLVMFuzzerNoMain STATIC
     $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
     )
-  if( HAVE_LIBPTHREAD )
-    target_link_libraries(LLVMFuzzerNoMain pthread)
-  endif()
+  target_link_libraries(LLVMFuzzerNoMain ${PTHREAD_LIB})
   add_library(LLVMFuzzer STATIC
     FuzzerMain.cpp
     $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
     )
-  if( HAVE_LIBPTHREAD )
-    target_link_libraries(LLVMFuzzer pthread)
-  endif()
+  target_link_libraries(LLVMFuzzer ${PTHREAD_LIB})
 
   if( LLVM_INCLUDE_TESTS )
     add_subdirectory(test)

Modified: llvm/trunk/lib/Support/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=262344&r1=262343&r2=262344&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CMakeLists.txt (original)
+++ llvm/trunk/lib/Support/CMakeLists.txt Tue Mar  1 09:54:40 2016
@@ -17,9 +17,7 @@ elseif( CMAKE_HOST_UNIX )
   if( LLVM_ENABLE_THREADS AND HAVE_LIBATOMIC )
     set(system_libs ${system_libs} atomic)
   endif()
-  if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD )
-    set(system_libs ${system_libs} pthread)
-  endif()
+  set(system_libs ${system_libs} ${PTHREAD_LIB})
   if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
     set(system_libs ${system_libs} z)
   endif()

Modified: llvm/trunk/unittests/Support/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/CMakeLists.txt?rev=262344&r1=262343&r2=262344&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/CMakeLists.txt (original)
+++ llvm/trunk/unittests/Support/CMakeLists.txt Tue Mar  1 09:54:40 2016
@@ -53,6 +53,4 @@ add_llvm_unittest(SupportTests
   )
 
 # ManagedStatic.cpp uses <pthread>.
-if(LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD)
-  target_link_libraries(SupportTests pthread)
-endif()
+target_link_libraries(SupportTests ${PTHREAD_LIB})




More information about the llvm-commits mailing list