Refactor duplicated code for linking with pthread.

llvm-svn: 262344
This commit is contained in:
Rafael Espindola 2016-03-01 15:54:40 +00:00
parent 15d5943a07
commit c165498992
7 changed files with 13 additions and 24 deletions

View File

@ -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.

View File

@ -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})

View File

@ -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)

View File

@ -3,9 +3,9 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
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

View File

@ -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)

View File

@ -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()

View File

@ -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})