From 10369b9a6b896dc79d7ae715fe67bf3b4c581c22 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Tue, 9 May 2023 15:48:56 -0400 Subject: [PATCH] build: Define _GNU_SOURCE for pthread_getname_np With clang-16, implicit function definitions are treated as errors. As a result, the check for pthread_getname_np fails because pthread_getname_np is only provided under _GNU_SOURCE (see pthread_getname_np(3)) > Checking if "pthread_getname_np" : links: NO The compilation failure is > error: implicit declaration of function 'pthread_getname_np' [-Werror,-Wimplicit-function-declaration] The inclusion of pthread.h lib/rb-debug.c must be moved above the system headers because they may include pthread.h themselves (and in practice unistd.h does). If that change is not done, lib/rb-debug.c will fail to compile for the same reason as the configure test. Note that to test this, one must disable prctl() detection. Bug: https://bugs.gentoo.org/898926 --- lib/rb-debug.c | 11 ++++++----- meson.build | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/rb-debug.c b/lib/rb-debug.c index a5b4ccac6..b9e0ec81d 100644 --- a/lib/rb-debug.c +++ b/lib/rb-debug.c @@ -30,17 +30,18 @@ #include "config.h" +#if defined(HAVE_PRCTL) +#include +#elif defined(HAVE_PTHREAD_GETNAME_NP) +#define _GNU_SOURCE +#include +#endif #include #include #include #include #include #include -#if defined(HAVE_PRCTL) -#include -#elif defined(HAVE_PTHREAD_GETNAME_NP) -#include -#endif #include diff --git a/meson.build b/meson.build index 681e084e8..bbe014246 100644 --- a/meson.build +++ b/meson.build @@ -110,6 +110,7 @@ have_prctl = cc.has_function('prctl', prefix: '#include ') cdata.set('HAVE_PRCTL', have_prctl) have_pthread_getname_np = cc.links(''' + #define _GNU_SOURCE #include int main() { char nm[17]; -- GitLab