From: Hisam Mehboob <hisamshar@gmail.com>
To: Sean Christopherson <seanjc@google.com>,
Shuah Khan <skhan@linuxfoundation.org>
Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Aqib Faruqui <aqibaf@amazon.com>,
shuah@kernel.org, pbonzini@redhat.com,
Hisam Mehboob <hisamshar@gmail.com>
Subject: [PATCH v2] KVM: selftests: Guard execinfo.h inclusion for non-glibc builds
Date: Thu, 9 Apr 2026 20:38:47 +0500 [thread overview]
Message-ID: <20260409153846.1502656-2-hisamshar@gmail.com> (raw)
In-Reply-To: <20260319000842.1213426-2-hisamshar@gmail.com>
The backtrace() function and execinfo.h are GNU extensions available
in glibc but not in non-glibc C libraries such as musl. Building KVM
selftests with musl-gcc fails with:
lib/assert.c:9:10: fatal error: execinfo.h: No such file or directory
Fix this by guarding the inclusion of execinfo.h and the stack dumping
logic under #ifdef __GLIBC__. For non-glibc builds, provide a local
stub for test_dump_stack().
Suggested-by: Aqib Faruqui <aqibaf@amazon.com>
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Hisam Mehboob <hisamshar@gmail.com>
---
Changes in v2:
- Replaced the __weak stub approach with a single #ifdef __GLIBC__
and a local stub inside assert.c as suggested by Sean Christopherson.
tools/testing/selftests/kvm/lib/assert.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/lib/assert.c b/tools/testing/selftests/kvm/lib/assert.c
index b49690658c60..8be0d09ecf0f 100644
--- a/tools/testing/selftests/kvm/lib/assert.c
+++ b/tools/testing/selftests/kvm/lib/assert.c
@@ -6,11 +6,14 @@
*/
#include "test_util.h"
-#include <execinfo.h>
+
#include <sys/syscall.h>
#include "kselftest.h"
+#ifdef __GLIBC__
+#include <execinfo.h>
+
/* Dumps the current stack trace to stderr. */
static void __attribute__((noinline)) test_dump_stack(void);
static void test_dump_stack(void)
@@ -57,6 +60,9 @@ static void test_dump_stack(void)
system(cmd);
#pragma GCC diagnostic pop
}
+#else
+static void test_dump_stack(void) {}
+#endif
static pid_t _gettid(void)
{
--
2.51.0
prev parent reply other threads:[~2026-04-09 15:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 0:08 [PATCH] KVM: selftests: Guard execinfo.h inclusion for non-glibc builds Hisam Mehboob
2026-03-24 18:02 ` Shuah Khan
2026-03-25 18:03 ` Shuah Khan
2026-03-25 18:47 ` Hisam Mehboob
2026-03-31 23:09 ` Shuah Khan
2026-04-01 14:01 ` Sean Christopherson
2026-04-09 11:53 ` Hisam Mehboob
2026-04-09 15:38 ` Hisam Mehboob [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260409153846.1502656-2-hisamshar@gmail.com \
--to=hisamshar@gmail.com \
--cc=aqibaf@amazon.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox