diff options
author | Sam James <sam@gentoo.org> | 2022-09-13 19:37:59 +0100 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-09-15 20:45:42 +0300 |
commit | 4489757f1cc1fe4aa98d4c1ebbe0789b2b308e11 (patch) | |
tree | 0c2db842b736ebd346658677c6d8d8575e8efd66 /CMakeLists.txt | |
parent | afbb7e51cb286d899d48f67119f1dfa8e956715e (diff) | |
download | bdwgc-4489757f1cc1fe4aa98d4c1ebbe0789b2b308e11.tar.gz |
Fix 'call to undeclared pthread_setname_np' errors in configure and cmake
Issue #474 (bdwgc).
Clang 15 makes implicit function declarations an error by default
which leads to configure (and cmake script) falsely thinking
pthread_setname_np symbol is not present.
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT] (check_c_source_compiles):
Always define _GNU_SOURCE before include pthread.h (regardless of
__CYGWIN__, __linux__, __GLIBC__, __GNU__ macros).
* configure.ac [$THREADS==posix] (AC_COMPILE_IFELSE): Likewise.
* include/private/gc_priv.h [!_GNU_SOURCE
&& (HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID
|| HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG
|| HAVE_PTHREAD_SETNAME_NP_WITH_TID)] (_GNU_SOURCE): Define.
Co-authored-by: Ivan Maidanski <ivmai@mail.ru>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 29c31dde..a670acc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -482,6 +482,7 @@ endif() # pthread_setname_np, if available, may have 1, 2 or 3 arguments. if (CMAKE_USE_PTHREADS_INIT) check_c_source_compiles(" +#define _GNU_SOURCE 1\n #include <pthread.h>\n int main(void) { (void)pthread_setname_np(\"thread-name\"); return 0; }" HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID) @@ -490,6 +491,7 @@ int main(void) { (void)pthread_setname_np(\"thread-name\"); return 0; }" add_definitions("-DHAVE_PTHREAD_SETNAME_NP_WITHOUT_TID") else() check_c_source_compiles(" +#define _GNU_SOURCE 1\n #include <pthread.h>\n int main(void) {\n (void)pthread_setname_np(pthread_self(), \"thread-name-%u\", 0); return 0; }" @@ -499,9 +501,7 @@ int main(void) {\n add_definitions("-DHAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG") else() check_c_source_compiles(" -#if defined(__linux__) || defined(__GLIBC__) || defined(__GNU__) || defined(__CYGWIN__)\n #define _GNU_SOURCE 1\n -#endif\n #include <pthread.h>\n int main(void) {\n (void)pthread_setname_np(pthread_self(), \"thread-name\"); return 0; }" |