diff --git a/meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0007-tests-testprogs-define-_GNU_SOURCE-for-pthread_setn.patch b/meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0007-tests-testprogs-define-_GNU_SOURCE-for-pthread_setn.patch
new file mode 100644
index 0000000000..d9d297055e
--- /dev/null
+++ b/meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace/0007-tests-testprogs-define-_GNU_SOURCE-for-pthread_setn.patch
@@ -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>
diff --git a/meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.26.1.bb b/meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.26.1.bb
index a2f6a93f66..e217ac150d 100644
--- a/meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.26.1.bb
+++ b/meta-oe/dynamic-layers/meta-python/recipes-devtools/bpftrace/bpftrace_0.26.1.bb
@@ -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"
 
