summaryrefslogtreecommitdiffstats
path: root/Modules/FindThreads.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-02-27 12:28:05 (GMT)
committerBrad King <brad.king@kitware.com>2019-02-27 12:33:31 (GMT)
commit18320230ecb273233b1ccb133537daf16179262c (patch)
treea06bf23b515bfa4398fcb2b22a19a2035ca83073 /Modules/FindThreads.cmake
parente0267eb1d327befd9839c0d745c84e6550618104 (diff)
downloadCMake-18320230ecb273233b1ccb133537daf16179262c.zip
CMake-18320230ecb273233b1ccb133537daf16179262c.tar.gz
CMake-18320230ecb273233b1ccb133537daf16179262c.tar.bz2
FindThreads: Revert libc symbol check to pthread_create
Since commit e9a1ddc594 (FindThreads: Replace the pthread symbol checking in libc., 2018-11-18, v3.14.0-rc1~292^2) we check libc for `pthread_kill` instead of `pthread_create`. However, on FreeBSD `pthread_kill` is in libc but not `pthread_create`. Discussion in the original merge request for the above commit also considered `pthread_key_create`, `pthread_self`, and `pthread_attr_init`. Every symbol seems to have some reason it is not an appropriate choice. Revert to the pre-3.14 behavior of using `pthread_create` pending further investigation.
Diffstat (limited to 'Modules/FindThreads.cmake')
-rw-r--r--Modules/FindThreads.cmake16
1 files changed, 3 insertions, 13 deletions
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index a2f3fa3..919392a 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -118,18 +118,8 @@ if(CMAKE_HAVE_PTHREAD_H)
set(CMAKE_HAVE_THREADS_LIBRARY)
if(NOT THREADS_HAVE_PTHREAD_ARG)
# Check if pthread functions are in normal C library.
- # If the pthread functions already exist in C library, we could just use
- # them instead of linking to the additional pthread library. We could
- # try to check any pthread symbol name, but here is an exception. If we
- # use clang asan build, we will find the pthread_create() symbol in the
- # libc(libasan). However, it doesn't have the full pthread implementation.
- # So, we can't assume that we have the pthread implementation in libc
- # using the pthread_create() checking here. Then, we turn to check the
- # pthread_kill() symbol instead. It is in the "signal.h" header, but
- # the purpose of this check is to verify that the pthread API works with
- # pure libc, so verify that "pthread.h" can be included too.
- CHECK_SYMBOL_EXISTS(pthread_kill "signal.h;pthread.h" CMAKE_HAVE_LIBC_PTHREAD_KILL)
- if(CMAKE_HAVE_LIBC_PTHREAD_KILL)
+ CHECK_SYMBOL_EXISTS(pthread_create pthread.h CMAKE_HAVE_LIBC_CREATE)
+ if(CMAKE_HAVE_LIBC_CREATE)
set(CMAKE_THREAD_LIBS_INIT "")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
@@ -154,7 +144,7 @@ if(CMAKE_HAVE_PTHREAD_H)
_check_pthreads_flag()
endif()
-if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_PTHREAD_KILL)
+if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE)
set(CMAKE_USE_PTHREADS_INIT 1)
set(Threads_FOUND TRUE)
endif()