[PATCH 2/2] perf util: Explicitly include required headers

From: Dapeng Mi

Date: Tue Sep 15 2026 - 05:25:45 EST


Sashiko complains "the perf tool can be compiled with musl libc, which
enforces strict POSIX namespace separation and does not implicitly
include headers. Relying on implicit header inclusion can cause build
failures under musl."

Include the required headers explicitly to avoid such failures.

Signed-off-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>
---
tools/perf/util/parse-regs-options.c | 1 +
tools/perf/util/perf-regs-arch/perf_regs_x86.c | 2 ++
tools/perf/util/session.c | 5 +++++
3 files changed, 8 insertions(+)

diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c
index 709fcfb077a2..e70393388fae 100644
--- a/tools/perf/util/parse-regs-options.c
+++ b/tools/perf/util/parse-regs-options.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
+#include <strings.h>
#include <stdio.h>
#include "util/debug.h"
#include <dwarf-regs.h>
diff --git a/tools/perf/util/perf-regs-arch/perf_regs_x86.c b/tools/perf/util/perf-regs-arch/perf_regs_x86.c
index fb6cf34f42f2..ea1d402b0893 100644
--- a/tools/perf/util/perf-regs-arch/perf_regs_x86.c
+++ b/tools/perf/util/perf-regs-arch/perf_regs_x86.c
@@ -3,6 +3,8 @@
#include <errno.h>
#include <string.h>
#include <regex.h>
+#include <unistd.h>
+#include <stdbool.h>
#include <linux/kernel.h>
#include <linux/zalloc.h>

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index a5b596cd14be..04fba6fb02e8 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1,4 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <inttypes.h>
--
2.34.1