bpftrace: define _GNU_SOURCE for pthread_setname_np in testprogs

A test program uses pthread_setname_np(), a GNU extension that needs
_GNU_SOURCE defined before <pthread.h> is included to be declared.

AI-Generated: Uses Claude Code

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Khem Raj committed 2026-09-29 09:57:23 -07:00
1 parent d60e16154d
commit 804d00b5ba
2 files changed
+29

No files matched your search

@@ -0,0 +1,28 @@
From: Khem Raj <khem.raj@oss.qualcomm.com>
Date: Tue, 29 Sep 2026 01:56:02 +0000
Subject: [PATCH] tests/testprogs: define _GNU_SOURCE for pthread_setname_np
glibc exposes GNU/BSD extensions such as pthread_setname_np() by default
in its headers unless the build is put into a strict ISO mode, whereas
musl only exposes these extensions when _GNU_SOURCE is explicitly defined
before <pthread.h> is included. Without it, musl's <pthread.h> does not
declare pthread_setname_np(), causing an implicit-declaration error under
clang's -Werror=implicit-function-declaration (mandatory in C99 and
later). Define _GNU_SOURCE before the first include so the declaration is
visible on musl too.
Upstream-Status: Pending
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
tests/testprogs/multi_threads.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/testprogs/multi_threads.c b/tests/testprogs/multi_threads.c
index 1111111..2222222 100644
--- a/tests/testprogs/multi_threads.c
+++ b/tests/testprogs/multi_threads.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
@@ -21,6 +21,7 @@ SRC_URI = "git://github.com/iovisor/bpftrace;branch=release/0.26.x;protocol=http
file://0005-CMakeLists-Add-support-for-LLVM-23.patch \
file://0001-tests-pass-C-linker-flags-and-sysroot-to-raw-compile.patch \
file://0006-tests-do-not-embed-build-paths-in-split-DWARF-test-pr.patch \
file://0007-tests-testprogs-define-_GNU_SOURCE-for-pthread_setn.patch \
"
SRCREV = "1bac8a8daad6e0aa579980e877d0c9d5fc296593"