[PATCH] D21478: [build] Link main executable with libpthread
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 21 12:41:33 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273302: [build] Make sure to link main executable with pthreads (authored by tra).
Changed prior to commit:
http://reviews.llvm.org/D21478?vs=61412&id=61427#toc
Repository:
rL LLVM
http://reviews.llvm.org/D21478
Files:
llvm/trunk/cmake/config-ix.cmake
llvm/trunk/cmake/modules/AddLLVM.cmake
llvm/trunk/tools/llvm-config/CMakeLists.txt
Index: llvm/trunk/cmake/config-ix.cmake
===================================================================
--- llvm/trunk/cmake/config-ix.cmake
+++ llvm/trunk/cmake/config-ix.cmake
@@ -110,7 +110,13 @@
endif()
if(HAVE_LIBPTHREAD)
- set(PTHREAD_LIB pthread)
+ # We want to find pthreads library and at the moment we do want to
+ # have it reported as '-l<lib>' instead of '-pthread'.
+ # TODO: switch to -pthread once the rest of the build system can deal with it.
+ set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
+ set(THREADS_HAVE_PTHREAD_ARG Off)
+ find_package(Threads REQUIRED)
+ set(PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
endif()
# Don't look for these libraries on Windows. Also don't look for them if we're
Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -670,6 +670,12 @@
if(NOT ARG_IGNORE_EXTERNALIZE_DEBUGINFO)
llvm_externalize_debuginfo(${name})
endif()
+ if (PTHREAD_LIB)
+ # libpthreads overrides some standard library symbols, so main
+ # executable must be linked with it in order to provide consistent
+ # API for all shared libaries loaded by this executable.
+ target_link_libraries(${name} ${PTHREAD_LIB})
+ endif()
endmacro(add_llvm_executable name)
function(export_executable_symbols target)
@@ -953,7 +959,10 @@
add_llvm_executable(${test_name} IGNORE_EXTERNALIZE_DEBUGINFO ${ARGN})
set(outdir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
set_output_directory(${test_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir})
- target_link_libraries(${test_name} gtest_main gtest)
+ # libpthreads overrides some standard library symbols, so main
+ # executable must be linked with it in order to provide consistent
+ # API for all shared libaries loaded by this executable.
+ target_link_libraries(${test_name} gtest_main gtest ${PTHREAD_LIB})
add_dependencies(${test_suite} ${test_name})
get_target_property(test_suite_folder ${test_suite} FOLDER)
Index: llvm/trunk/tools/llvm-config/CMakeLists.txt
===================================================================
--- llvm/trunk/tools/llvm-config/CMakeLists.txt
+++ llvm/trunk/tools/llvm-config/CMakeLists.txt
@@ -14,7 +14,13 @@
if(MSVC)
set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}.lib")
else()
- set(SYSTEM_LIBS ${SYSTEM_LIBS} "-l${l}")
+ if (l MATCHES "^-")
+ # If it's an option, pass it without changes.
+ set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}")
+ else()
+ # Otherwise assume it's a library name we need to link with.
+ set(SYSTEM_LIBS ${SYSTEM_LIBS} "-l${l}")
+ endif()
endif()
endforeach()
string(REPLACE ";" " " SYSTEM_LIBS "${SYSTEM_LIBS}")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21478.61427.patch
Type: text/x-patch
Size: 2774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160621/2d43949c/attachment.bin>
More information about the llvm-commits
mailing list