diff options
authorLyude Paul <>2019-04-24 16:11:31 -0400
committerLyude Paul <>2019-05-07 17:38:01 -0400
commitef7c18b0361394567e2b964366ea3314c54b46a2 (patch)
parent6d404244a0e22601ffa121ee5c1e337451339719 (diff)
meson: Don't redefine gettid if the C library provides it
glibc 2.30+ will actually include a definition for gettid() that makes it so that users don't have to manually define a wrapper for it themselves with syscall(). We don't currently check for this, and as a result will end up redefining gettid() on the latest versions of glibc, causing the build to fail: FAILED: lib/76b5a35@@igt-igt_kmod_c@sta/igt_kmod.c.o In file included from /usr/include/unistd.h:1170, from ../../mnt/vol/lib/igt_core.h:43, from ../../mnt/vol/lib/igt_kmod.c:28: /usr/include/bits/unistd_ext.h:34:28: error: macro "gettid" passed 1 arguments, but takes just 0 34 | extern __pid_t gettid (void) __THROW; | ^ In file included from ../../mnt/vol/lib/igt_kmod.c:27: ../../mnt/vol/lib/igt_aux.h:40: note: macro "gettid" defined here 40 | #define gettid() syscall(__NR_gettid) | [36/771] Compiling C object 'lib/76b5a35@@igt-igt_kms_c@sta/igt_kms.c.o'. ninja: build stopped: subcommand failed. So, fix this by by adding some meson checks to define HAVE_GETTID whenever the host defines its own gettid(), and avoid redefining gettid() when HAVE_GETTID is defined. This fixes build igt-gpu-tools for me on Fedora Rawhide Reviewed-by: Daniel Vetter <> Reviewed-by: Petri Latvala <> Signed-off-by: Lyude Paul <>
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 24711aa2..04d22904 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -33,6 +33,7 @@
#include <stddef.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <unistd.h>
#ifdef __linux__
# include <sys/syscall.h>
@@ -41,7 +42,9 @@
/* signal interrupt helpers */
#ifdef __linux__
-# define gettid() (pid_t)(syscall(__NR_gettid))
+# ifndef HAVE_GETTID
+# define gettid() (pid_t)(syscall(__NR_gettid))
+# endif
#define sigev_notify_thread_id _sigev_un._tid
diff --git a/ b/
index be6dff9d..3d466d52 100644
--- a/
+++ b/
@@ -223,6 +223,9 @@ if cc.has_header('cpuid.h')
# FIXME: Do we need the example link test from
config.set('HAVE_CPUID_H', 1)
+if cc.has_header_symbol('unistd.h', 'gettid', args : '-D_GNU_SOURCE')
+ config.set('HAVE_GETTID', 1)
if cc.has_member('struct sysinfo', 'totalram',
prefix : '#include <sys/sysinfo.h>')