1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
From 10369b9a6b896dc79d7ae715fe67bf3b4c581c22 Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
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 <sys/prctl.h>
+#elif defined(HAVE_PTHREAD_GETNAME_NP)
+#define _GNU_SOURCE
+#include <pthread.h>
+#endif
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <signal.h>
#include <time.h>
-#if defined(HAVE_PRCTL)
-#include <sys/prctl.h>
-#elif defined(HAVE_PTHREAD_GETNAME_NP)
-#include <pthread.h>
-#endif
#include <glib.h>
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 <sys/prctl.h>')
cdata.set('HAVE_PRCTL', have_prctl)
have_pthread_getname_np = cc.links('''
+ #define _GNU_SOURCE
#include <pthread.h>
int main() {
char nm[17];
--
GitLab
|