[PATCH v1 06/11] perf test: missing stdio.h and signal.h inclusions in cmd_test()
From: Ian Rogers
Date: Thu Sep 17 2026 - 00:56:16 EST
Sashiko reported:
When compiling the perf tool against musl libc, the build fails in
tools/perf/tests/builtin-test.c due to missing explicit inclusions
of <stdio.h> and <signal.h>.
The file relies on standard I/O functions like fdopen() and
fprintf(), as well as signal handling constructs like signal(),
SIGINT, and SIGTERM within __cmd_test() and related helpers. While
glibc may implicitly pull in these definitions through other
standard headers such as <stdlib.h> or <unistd.h>, musl libc
strictly enforces POSIX namespace separation and avoids implicit
header inclusion. Because the required headers are absent, the
compiler cannot resolve these standard library types and macros,
resulting in a direct compilation failure on musl-based systems.
Add the header files and use git clang-format to sort.
Reported-by: sashiko-bot@xxxxxxxxxx
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/tests/builtin-test.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 4d0784b16723..ca3e7b84d5d7 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -5,16 +5,15 @@
* Builtin regression testing command: ever growing number of sanity tests
*/
#include <ctype.h>
-#include <fcntl.h>
#include <errno.h>
-#ifdef HAVE_BACKTRACE_SUPPORT
-#include <execinfo.h>
-#endif
#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
+#include <fcntl.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/zalloc.h>
@@ -44,6 +43,10 @@
#include "util/strbuf.h"
#include "util/term.h"
+#ifdef HAVE_BACKTRACE_SUPPORT
+#include <execinfo.h>
+#endif
+
static const char *junit_filename;
static struct strbuf junit_xml_buf = STRBUF_INIT;
--
2.55.0.1082.g2b9226bbc0-goog