You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by uw...@apache.org on 2019/01/27 20:38:46 UTC
[arrow] branch master updated: ARROW-4330: [C++] More robust
discovery of pthreads
This is an automated email from the ASF dual-hosted git repository.
uwe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new b427864 ARROW-4330: [C++] More robust discovery of pthreads
b427864 is described below
commit b4278641a6a56c56d2007469b0eb840d52cc007d
Author: Wes McKinney <we...@apache.org>
AuthorDate: Sun Jan 27 21:38:37 2019 +0100
ARROW-4330: [C++] More robust discovery of pthreads
I found when using a non-system gcc (e.g. the `gcc_linux-64` and `gxx_linux-64` gcc7 conda packages) that CMake is not able to discover pthreads. The conda-forge community regards this as a bug in CMake, but there is another better way to do this using the built-in `FindThreads.cmake`.
There's a chance this might also resolve the missing thread symbol in the Gandiva windows build, but I haven't tried it yet
Author: Wes McKinney <we...@apache.org>
Closes #3494 from wesm/pthreads-cmake and squashes the following commits:
828d6bf1 <Wes McKinney> Code review
38349ad8 <Wes McKinney> Restore jemalloc dependencies on pthreads
122e2647 <Wes McKinney> Clean up system link libraries for pthread, librt
7522a60a <Wes McKinney> Use FindThreads.cmake to handle -pthread
---
cpp/CMakeLists.txt | 52 +++++++++--------------------
cpp/cmake_modules/ThirdpartyToolchain.cmake | 14 +++-----
2 files changed, 19 insertions(+), 47 deletions(-)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 5309c35..3ec430e 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -839,50 +839,28 @@ if (ARROW_BUILD_BENCHMARKS)
${ARROW_TEST_LINK_LIBS})
endif()
+set(ARROW_SYSTEM_LINK_LIBS)
+
if (ARROW_JEMALLOC)
add_definitions(-DARROW_JEMALLOC)
add_definitions(-DARROW_JEMALLOC_INCLUDE_DIR=${JEMALLOC_INCLUDE_DIR})
-
- if (NOT WIN32 AND NOT APPLE)
- set(ARROW_JEMALLOC_LINK_LIBS
- jemalloc_static
- # For glibc <2.17 we need to link to librt.
- # As we compile with --as-needed by default, the linker will omit this
- # dependency if not required.
- rt
- )
- else()
- set(ARROW_JEMALLOC_LINK_LIBS
- jemalloc_static
- )
- endif()
- list(APPEND
- ARROW_SHARED_PRIVATE_LINK_LIBS
- ${ARROW_JEMALLOC_LINK_LIBS})
- list(APPEND
- ARROW_STATIC_LINK_LIBS
- ${ARROW_JEMALLOC_LINK_LIBS})
- list(APPEND
- ARROW_STATIC_INSTALL_INTERFACE_LIBS
- jemalloc
- rt)
+ list(APPEND ARROW_SYSTEM_LINK_LIBS jemalloc_static)
endif(ARROW_JEMALLOC)
-if (PTHREAD_LIBRARY)
- list(APPEND
- ARROW_LINK_LIBS
- pthreadshared)
- list(APPEND
- ARROW_SHARED_INSTALL_INTERFACE_LIBS
- pthread)
- list(APPEND
- ARROW_STATIC_LINK_LIBS
- pthreadshared)
- list(APPEND
- ARROW_STATIC_INSTALL_INTERFACE_LIBS
- pthread)
+if (THREADS_FOUND)
+ list(APPEND ARROW_SYSTEM_LINK_LIBS Threads::Threads)
endif()
+if (NOT WIN32 AND NOT APPLE)
+ # Pass -lrt on Linux only
+ list(APPEND ARROW_SYSTEM_LINK_LIBS rt)
+endif()
+
+list(APPEND ARROW_LINK_LIBS ${ARROW_SYSTEM_LINK_LIBS})
+list(APPEND ARROW_STATIC_LINK_LIBS ${ARROW_SYSTEM_LINK_LIBS})
+list(APPEND ARROW_SHARED_INSTALL_INTERFACE_LIBS ${ARROW_SYSTEM_LINK_LIBS})
+list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS ${ARROW_SYSTEM_LINK_LIBS})
+
############################################################
# Subdirectories
############################################################
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 5a75a9b..13a6a47 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -334,14 +334,8 @@ endif()
# ----------------------------------------------------------------------
# Find pthreads
-if (WIN32)
- set(PTHREAD_LIBRARY "PTHREAD_LIBRARY-NOTFOUND")
-else()
- find_library(PTHREAD_LIBRARY pthread)
- message(STATUS "Found pthread: ${PTHREAD_LIBRARY}")
- add_library(pthreadshared SHARED IMPORTED)
- set_target_properties(pthreadshared PROPERTIES IMPORTED_LOCATION ${PTHREAD_LIBRARY})
-endif()
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads REQUIRED)
# ----------------------------------------------------------------------
# Add Boost dependencies (code adapted from Apache Kudu (incubating))
@@ -802,7 +796,7 @@ if (ARROW_JEMALLOC)
ADD_THIRDPARTY_LIB(jemalloc
STATIC_LIB ${JEMALLOC_STATIC_LIB}
SHARED_LIB ${JEMALLOC_SHARED_LIB}
- DEPS ${PTHREAD_LIBRARY})
+ DEPS Threads::Threads)
add_dependencies(jemalloc_static jemalloc_ep)
endif()
@@ -1532,7 +1526,7 @@ if (ARROW_USE_GLOG)
set(GLOG_STATIC_LIB "${GLOG_BUILD_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}glog${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(GLOG_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(GLOG_CMAKE_C_FLAGS "${EP_C_FLAGS} -fPIC")
- if (PTHREAD_LIBRARY)
+ if (Threads::Threads)
set(GLOG_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -pthread")
set(GLOG_CMAKE_C_FLAGS "${EP_C_FLAGS} -fPIC -pthread")
endif()