diff options
author | Pavel Labath <labath@google.com> | 2018-04-18 13:13:27 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2018-04-18 13:13:27 +0000 |
commit | 646d5bb4d19f092a4b0849b0160774d8a16f4056 (patch) | |
tree | 1351888235c1030fd3087049de674fb0cc8a1bdd /cmake | |
parent | c108ab6989b81e4da03795a1e3c4466fcf25b228 (diff) |
[cmake] Improve pthread_[gs]etname_np detection code
Summary:
Due to some android peculiarities, in some build configurations
(statically linked executables targeting older releases) we could detect
the presence of these functions (because they are present in libc.a,
where check_library_exists searches), but then fail to build because the
headers did not include the definition.
This attempts to remedy that by upgrading the check_library_exists to
check_symbol_exists, which will check that the function is declared too.
I am hoping that a more thorough check will make the messy #ifdef we
have accumulated in the code obsolete, so I optimistically try to remove
them.
Reviewers: zturner, kparzysz, danalbert
Subscribers: srhines, mgorny, krytarowski, llvm-commits
Differential Revision: https://reviews.llvm.org/D45359
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330251 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/config-ix.cmake | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index b6f0c369560..aa4f8257d8e 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -252,12 +252,15 @@ endif() # This check requires _GNU_SOURCE check_symbol_exists(sched_getaffinity sched.h HAVE_SCHED_GETAFFINITY) check_symbol_exists(CPU_COUNT sched.h HAVE_CPU_COUNT) -if(HAVE_LIBPTHREAD) - check_library_exists(pthread pthread_getname_np "" HAVE_PTHREAD_GETNAME_NP) - check_library_exists(pthread pthread_setname_np "" HAVE_PTHREAD_SETNAME_NP) -elseif(PTHREAD_IN_LIBC) - check_library_exists(c pthread_getname_np "" HAVE_PTHREAD_GETNAME_NP) - check_library_exists(c pthread_setname_np "" HAVE_PTHREAD_SETNAME_NP) +if (NOT PURE_WINDOWS) + if (LLVM_PTHREAD_LIB) + list(APPEND CMAKE_REQUIRED_LIBRARIES ${LLVM_PTHREAD_LIB}) + endif() + check_symbol_exists(pthread_getname_np pthread.h HAVE_PTHREAD_GETNAME_NP) + check_symbol_exists(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP) + if (LLVM_PTHREAD_LIB) + list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${LLVM_PTHREAD_LIB}) + endif() endif() # available programs checks |