[PATCH v1 04/11] perf llvm: missing explicit POSIX headers in symbol__disassemble_llvm()
From: Ian Rogers
Date: Thu Sep 17 2026 - 00:54:07 EST
Sashiko reported:
When building the perf tool in an environment utilizing a strict C
library such as musl libc, compilation fails because
tools/perf/util/llvm.c omits explicit inclusion of <stdlib.h> and
<inttypes.h>.
The function symbol__disassemble_llvm() directly invokes free() for
memory deallocation and utilizes the PRIx64 macro for formatting
64-bit integers. While glibc often implicitly provides these POSIX
definitions via other includes, relying on transitive inclusion
creates a brittle dependency that violates perf subsystem
portability guidelines. On environments that do not implicitly pull
in these headers, the compiler encounters undeclared identifier and
unknown type name errors for free() and PRIx64, preventing
successful builds of the perf toolchain.
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/llvm.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/llvm.c b/tools/perf/util/llvm.c
index a0deb742a733..95efd089014b 100644
--- a/tools/perf/util/llvm.c
+++ b/tools/perf/util/llvm.c
@@ -1,5 +1,14 @@
// SPDX-License-Identifier: GPL-2.0
#include "llvm.h"
+
+#include <errno.h>
+#include <inttypes.h>
+#include <stdlib.h>
+
+#include <fcntl.h>
+#include <linux/zalloc.h>
+#include <unistd.h>
+
#include "annotate.h"
#include "debug.h"
#include "dso.h"
@@ -7,10 +16,6 @@
#include "namespaces.h"
#include "srcline.h"
#include "symbol.h"
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <linux/zalloc.h>
#ifdef HAVE_LIBLLVM_SUPPORT
#include "llvm-c-helpers.h"
--
2.55.0.1082.g2b9226bbc0-goog