[PATCH v1 08/11] perf annotate-data: missing <string.h> inclusion for libc string functions
From: Ian Rogers
Date: Thu Sep 17 2026 - 00:54:38 EST
Sashiko reported:
When compiling the perf tool with musl libc,
tools/perf/util/annotate-data.c fails to build due to the missing
<string.h> header.
The source file utilizes standard C library string and memory
functions, such as memset() in init_type_state() and strcmp() in
data_type_cmp(). While glibc implicitly pulls in <string.h> via
other standard headers, musl libc enforces stricter header
separation. Because the header is not explicitly included at the top
of the file, the compiler encounters implicit function declarations
for these standard string functions. This results in a direct
compile-time build error.
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/util/annotate-data.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
index aff60a630fd0..02df833504be 100644
--- a/tools/perf/util/annotate-data.c
+++ b/tools/perf/util/annotate-data.c
@@ -4,20 +4,23 @@
*
* Written by Namhyung Kim <namhyung@xxxxxxxxxx>
*/
+#include "annotate-data.h"
+
#include <errno.h>
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
-#include <inttypes.h>
+#include <string.h>
+
#include <linux/zalloc.h>
#include "annotate.h"
-#include "annotate-data.h"
-#include "debuginfo.h"
#include "debug.h"
+#include "debuginfo.h"
#include "dso.h"
#include "dwarf-regs.h"
-#include "evsel.h"
#include "evlist.h"
+#include "evsel.h"
#include "map.h"
#include "map_symbol.h"
#include "sort.h"
--
2.55.0.1082.g2b9226bbc0-goog