perf aslr: Add missing includes and sort headers
Ian Rogers
reviewerPATCH 1/11 perf aslr: Add missing includes and sort headers
Sashiko reported:
When building the perf utility against strict C standard libraries such as musl libc, compilation fails in tools/perf/util/aslr.c due to missing explicit inclusions of <stdlib.h> and <string.h>.
The implementation relies on standard memory management and string functions like malloc(), free(), memcpy(), and memset() in routines such as aslr_tool__findnew_mapping(), aslr_tool__process_sample(), and aslr_tool__delete(). Because the required headers are omitted, the compiler must resolve these calls via implicit function declarations. While glibc may transitively provide these definitions via other headers, musl libc does not. This violates strict C99+ standard compliance and triggers fatal build errors under modern compiler configurations.
Add the header files and use git clang-format to sort.
--- tools/perf/util/aslr.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)
tools/perf/util/aslr.c +18 -14
@@ -1,28 +1,32 @@// SPDX-License-Identifier: GPL-2.0 #include "aslr.h" +#include <errno.h> +#include <inttypes.h> +#include <stdlib.h> +#include <string.h> + +#include <byteswap.h> +#include <linux/compiler.h> +#include <linux/zalloc.h> +#include <unistd.h> + +#include <internal/lib.h> /* page_size */ +#include "addr_location.h" +#include "data.h" #include "debug.h" +#include "dso.h" #include "event.h" -#include "evsel.h" #include "evlist.h" +#include "evsel.h" #include "machine.h" #include "map.h" -#include "thread.h" -#include "tool.h" -#include "session.h" -#include "data.h" -#include "dso.h" #include "pmu.h" #include "pmus.h" - -#include <internal/lib.h> /* page_size */ -#include <linux/compiler.h> -#include <linux/zalloc.h> -#include <errno.h> -#include <inttypes.h> -#include <unistd.h> -#include <byteswap.h> +#include "session.h" +#include "thread.h" +#include "tool.h" /** * struct remap_addresses_key - Key for mapping original addresses to remapped ones.
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Ian Rogers
reviewerPATCH 2/11 perf bench messaging: Add missing includes and sort headers
Sashiko reported:
When building the perf tool on systems using musl libc, compilation of tools/perf/bench/sched-messaging.c fails due to missing signal-related header declarations.
The POSIX signal API and associated constants (SIGKILL, SIGINT, SIGTERM) are referenced in sig_handler() and bench_sched_messaging() but require an explicit inclusion of <signal.h>. While builds on glibc succeed because the header is implicitly pulled in via other includes, strict libc environments like musl do not provide this implicit namespace pollution. This results in undeclared identifier errors for kill() and signal() during the build process.
Add the header files and use git clang-format to sort.
--- tools/perf/bench/sched-messaging.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
tools/perf/bench/sched-messaging.c +11 -9
@@ -14,21 +14,23 @@#include "bench.h" /* Test groups of 20 processes spraying to 20 receivers */ -#include <pthread.h> +#include <errno.h> +#include <limits.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <errno.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/wait.h> -#include <sys/time.h> -#include <poll.h> -#include <limits.h> +#include <err.h> #include <linux/list.h> #include <linux/time64.h> +#include <poll.h> +#include <pthread.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> #define DATASIZE 100
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
[email protected]
AI reviewRe: [PATCH v1 02/11] perf bench messaging: Add missing includes and sort headers
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 14 lines
Sashiko reported:
When building the perf tool on systems using musl libc, compilation of
tools/perf/bench/sched-messaging.cfails due to missing signal-related header declarations.The POSIX signal API and associated constants (SIGKILL, SIGINT, SIGTERM) are referenced in
sig_handler()andbench_sched_messaging()but require an explicit inclusion of <signal.h>. While builds on glibc succeed because the header is implicitly pulled in via other includes, strict libc environments like musl do not provide this implicit namespace pollution. This results in undeclared identifier errors forkill()andsignal()during the build process.
Quoted 4 lines
Add the header files and use git clang-format to sort.
Reported-by [email protected]Signed-off-by Ian Rogers <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Ian Rogers
reviewerPATCH 3/11 perf unwind-libdw: missing <stdlib.h> in libdw_set_initial_registers()
In reply to Ian RogersSashiko reported:
When building the perf tool against strict C standard libraries (such as musl libc), compilation fails in tools/perf/util/unwind-libdw.c due to implicit declarations of memory allocation functions.
The libdw_set_initial_registers() function dynamically allocates an array of DWARF registers using calloc() and subsequently releases it with free(). However, the source file lacks an explicit #include <stdlib.h>. On build environments where standard headers do not implicitly chain-include <stdlib.h>, these functions remain undeclared, resulting in fatal implicit function declaration errors that break the build.
Add the header files and use git clang-format to sort.
--- tools/perf/util/unwind-libdw.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
tools/perf/util/unwind-libdw.c +15 -10
@@ -1,24 +1,29 @@// SPDX-License-Identifier: GPL-2.0 +#include "unwind-libdw.h" +#include <assert.h> +#include <errno.h> +#include <inttypes.h> +#include <stdlib.h> +#include <linux/compiler.h> +#include <linux/types.h> +#include <linux/zalloc.h> + +#include <dwarf-regs.h> #include <elfutils/libdw.h> #include <elfutils/libdwfl.h> -#include <inttypes.h> -#include <errno.h> + +#include "callchain.h" #include "debug.h" #include "dso.h" -#include <dwarf-regs.h> -#include "unwind.h" -#include "unwind-libdw.h" +#include "event.h" #include "machine.h" #include "map.h" +#include "perf_regs.h" #include "symbol.h" #include "thread.h" -#include <linux/types.h> -#include <linux/zalloc.h> -#include "event.h" -#include "perf_regs.h" -#include "callchain.h" +#include "unwind.h" #include "util/env.h" /*
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
[email protected]
AI reviewRe: [PATCH v1 03/11] perf unwind-libdw: missing <stdlib.h> in libdw_set_initial_registers()
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 15 lines
Sashiko reported:
When building the perf tool against strict C standard libraries (such as musl libc), compilation fails in
tools/perf/util/unwind-libdw.cdue to implicit declarations of memory allocation functions.The
libdw_set_initial_registers()function dynamically allocates an array of DWARF registers usingcalloc()and subsequently releases it withfree(). However, the source file lacks an explicit #include <stdlib.h>. On build environments where standard headers do not implicitly chain-include <stdlib.h>, these functions remain undeclared, resulting in fatal implicit function declaration errors that break the build.
Quoted 4 lines
Add the header files and use git clang-format to sort.
Reported-by [email protected]Signed-off-by Ian Rogers <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Ian Rogers
reviewerPATCH 4/11 perf llvm: missing explicit POSIX headers in symbol__disassemble_llvm()
In reply to Ian RogersSashiko 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.
--- tools/perf/util/llvm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
tools/perf/util/llvm.c +9 -4
@@ -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"
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
[email protected]
AI reviewRe: [PATCH v1 04/11] perf llvm: missing explicit POSIX headers in symbol__disassemble_llvm()
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 17 lines
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.comits explicit inclusion of <stdlib.h> and <inttypes.h>.The function
symbol__disassemble_llvm()directly invokesfree()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 forfree()and PRIx64, preventing successful builds of the perf toolchain.
Quoted 4 lines
Add the header files and use git clang-format to sort.
Reported-by [email protected]Signed-off-by Ian Rogers <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Ian Rogers
reviewerPATCH 5/11 perf dso: missing POSIX headers string.h and limits.h
In reply to Ian RogersSashiko reported:
When building the perf tool on a system using the musl C library, compilation of tools/perf/util/dso.c fails because it utilizes standard string operations and the PATH_MAX macro without explicitly including <string.h> and <limits.h>.
Functions like dso__read_binary_type_filename() allocate arrays sized by PATH_MAX and perform string manipulations using strncpy(), strlen(), and strdup(). While glibc implicitly exposes these POSIX definitions via other included standard library headers such as <stdlib.h>, musl enforces strict header dependency boundaries. Consequently, these macros and functions remain undeclared during preprocessing, resulting in a fatal compiler error.
Add the header files and use git clang-format to sort.
--- tools/perf/util/dso.c | 47 +++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-)
tools/perf/util/dso.c +27 -20
@@ -1,38 +1,45 @@// SPDX-License-Identifier: GPL-2.0 +#include "dso.h" + +#include <errno.h> +#include <limits.h> +#include <stdlib.h> +#include <string.h> +#include <asm/bug.h> +#include <fcntl.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/zalloc.h> -#include <sys/time.h> #include <sys/resource.h> -#include <sys/types.h> #include <sys/stat.h> +#include <sys/time.h> +#include <sys/types.h> #include <unistd.h> -#include <errno.h> -#include <fcntl.h> -#include <stdlib.h> -#ifdef HAVE_LIBBPF_SUPPORT -#include <bpf/libbpf.h> -#include "bpf-event.h" -#include "bpf-utils.h" -#endif + +#include "annotate-data.h" +#include "auxtrace.h" #include "compress.h" +#include "debug.h" +#include "dsos.h" #include "env.h" +#include "libdw.h" +#include "machine.h" +#include "map.h" #include "namespaces.h" #include "path.h" -#include "map.h" -#include "symbol.h" #include "srcline.h" -#include "dso.h" -#include "dsos.h" -#include "machine.h" -#include "auxtrace.h" -#include "util.h" /* O_CLOEXEC for older systems */ -#include "debug.h" #include "string2.h" +#include "symbol.h" +#include "util.h" /* O_CLOEXEC for older systems */ #include "vdso.h" -#include "annotate-data.h" -#include "libdw.h" + +#ifdef HAVE_LIBBPF_SUPPORT +#include <bpf/libbpf.h> + +#include "bpf-event.h" +#include "bpf-utils.h" +#endif static const char *const debuglink_paths[] = {"%.0s%s" ,
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
[email protected]
AI reviewRe: [PATCH v1 05/11] perf dso: missing POSIX headers string.h and limits.h
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 16 lines
Sashiko reported:
When building the perf tool on a system using the musl C library, compilation of
tools/perf/util/dso.cfails because it utilizes standard string operations and thePATH_MAXmacro without explicitly including <string.h> and <limits.h>.Functions like
dso__read_binary_type_filename()allocate arrays sized byPATH_MAXand perform string manipulations usingstrncpy(),strlen(), andstrdup(). While glibc implicitly exposes these POSIX definitions via other included standard library headers such as <stdlib.h>, musl enforces strict header dependency boundaries. Consequently, these macros and functions remain undeclared during preprocessing, resulting in a fatal compiler error.
Quoted 4 lines
Add the header files and use git clang-format to sort.
Reported-by [email protected]Signed-off-by Ian Rogers <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Ian Rogers
reviewerPATCH 6/11 perf test: missing stdio.h and signal.h inclusions in cmd_test()
In reply to Ian RogersSashiko 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.
--- tools/perf/tests/builtin-test.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/perf/tests/builtin-test.c +7 -4
@@ -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 ;
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
[email protected]
AI reviewRe: [PATCH v1 06/11] perf test: missing stdio.h and signal.h inclusions in cmd_test()
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 16 lines
Sashiko reported:
When compiling the perf tool against musl libc, the build fails in
tools/perf/tests/builtin-test.cdue to missing explicit inclusions of <stdio.h> and <signal.h>.The file relies on standard I/O functions like
fdopen()andfprintf(), as well as signal handling constructs likesignal(), 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.
Quoted 4 lines
Add the header files and use git clang-format to sort.
Reported-by [email protected]Signed-off-by Ian Rogers <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Ian Rogers
reviewerPATCH 7/11 perf ui annotate-data: missing explicit inclusion of stdlib.h and stdio.h
In reply to Ian RogersSashiko reported:
When compiling the Linux kernel performance tools (perf) on a system using musl libc, a build failure occurs in tools/perf/ui/browsers/annotate-data.c due to missing standard header inclusions.
The source file directly invokes standard POSIX library functions such as calloc(), free(), and snprintf() without explicitly including <stdlib.h> and <stdio.h>. While glibc implicitly pulls in these declarations via other included headers, musl libc strictly separates standard header declarations and does not implicitly expose them. This namespace isolation causes the compiler to generate implicit-function-declaration errors when encountering these undeclared identifiers, permanently failing the build.
Add the header files and use git clang-format to sort.
--- tools/perf/ui/browsers/annotate-data.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/ui/browsers/annotate-data.c +4 -1
@@ -1,6 +1,9 @@// SPDX-License-Identifier: GPL-2.0 #include <inttypes.h> +#include <stdio.h> +#include <stdlib.h> #include <string.h> +#include <linux/zalloc.h> #include <sys/ttydefaults.h>
@@ -10,8 +13,8 @@#include "ui/ui.h" #include "util/annotate.h" #include "util/annotate-data.h" -#include "util/evsel.h" #include "util/evlist.h" +#include "util/evsel.h" #include "util/sort.h" #define FOLDED_SIGN '+'
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
[email protected]
AI reviewRe: [PATCH v1 07/11] perf ui annotate-data: missing explicit inclusion of stdlib.h and stdio.h
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 16 lines
Sashiko reported:
When compiling the Linux kernel performance tools (perf) on a system using musl libc, a build failure occurs in
tools/perf/ui/browsers/annotate-data.cdue to missing standard header inclusions.The source file directly invokes standard POSIX library functions such as
calloc(),free(), andsnprintf()without explicitly including <stdlib.h> and <stdio.h>. While glibc implicitly pulls in these declarations via other included headers, musl libc strictly separates standard header declarations and does not implicitly expose them. This namespace isolation causes the compiler to generate implicit-function-declaration errors when encountering these undeclared identifiers, permanently failing the build.
Quoted 4 lines
Add the header files and use git clang-format to sort.
Reported-by [email protected]Signed-off-by Ian Rogers <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Ian Rogers
reviewerPATCH 8/11 perf annotate-data: missing <string.h> inclusion for libc string functions
In reply to Ian RogersSashiko 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.
--- tools/perf/util/annotate-data.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/perf/util/annotate-data.c +7 -4
@@ -4,20 +4,23 @@* * Written by Namhyung Kim <[email protected]> */ +#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"
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
[email protected]
AI reviewRe: [PATCH v1 08/11] perf annotate-data: missing <string.h> inclusion for libc string functions
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 15 lines
Sashiko reported:
When compiling the perf tool with musl libc,
tools/perf/util/annotate-data.cfails to build due to the missing <string.h> header.The source file utilizes standard C library string and memory functions, such as
memset()ininit_type_state()andstrcmp()indata_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.
Quoted 4 lines
Add the header files and use git clang-format to sort.
Reported-by [email protected]Signed-off-by Ian Rogers <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
Ian Rogers
reviewerPATCH 9/11 perf mem: missing stdio.h and limits.h in mem-events.c
In reply to Ian RogersSashiko reported:
When compiling the perf tool against a strict POSIX C library such as musl libc, tools/perf/util/mem-events.c fails to build due to the use of undeclared standard symbols.
The source file defines an array using PATH_MAX in perf_pmu__mem_events_supported(), and utilizes fprintf() with stderr in perf_pmu__mem_events_list():
Because the required <limits.h> and <stdio.h> headers are not explicitly included, these symbols remain undeclared. While glibc masks this omission by implicitly pulling in these definitions via other standard headers, musl libc adheres strictly to POSIX inclusions. This causes the compiler to reject the undeclared PATH_MAX macro, the stderr stream, and the fprintf() function, halting the build process on systems utilizing strict libc implementations.
Add the header files and use git clang-format to sort.
--- tools/perf/util/mem-events.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
tools/perf/util/mem-events.c +13 -7
@@ -1,22 +1,28 @@// SPDX-License-Identifier: GPL-2.0 +#include "mem-events.h" + +#include <errno.h> +#include <limits.h> #include <stddef.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <errno.h> -#include <sys/types.h> + +#include <linux/kernel.h> #include <sys/stat.h> +#include <sys/types.h> #include <unistd.h> +#include <api/fs/fs.h> -#include <linux/kernel.h> +#include "cpumap.h" -#include "map_symbol.h" -#include "mem-events.h" -#include "mem-info.h" #include "debug.h" #include "evsel.h" -#include "symbol.h" +#include "map_symbol.h" +#include "mem-info.h" #include "pmu.h" #include "pmus.h" +#include "symbol.h" unsigned int perf_mem_events__loads_ldlat =30 ;
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
[email protected]
AI reviewRe: [PATCH v1 09/11] perf mem: missing stdio.h and limits.h in mem-events.c
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 19 lines
Sashiko reported:
When compiling the perf tool against a strict POSIX C library such as musl libc,
tools/perf/util/mem-events.cfails to build due to the use of undeclared standard symbols.The source file defines an array using
PATH_MAXinperf_pmu__mem_events_supported(), and utilizesfprintf()with stderr inperf_pmu__mem_events_list():Because the required <
limits.h> and <stdio.h> headers are not explicitly included, these symbols remain undeclared. While glibc masks this omission by implicitly pulling in these definitions via other standard headers, musl libc adheres strictly to POSIX inclusions. This causes the compiler to reject the undeclaredPATH_MAXmacro, the stderr stream, and thefprintf()function, halting the build process on systems utilizing strict libc implementations.
Quoted 4 lines
Add the header files and use git clang-format to sort.
Reported-by [email protected]Signed-off-by Ian Rogers <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
Ian Rogers
reviewerPATCH 10/11 perf config: undeclared PATH_MAX due to missing <limits.h> inclusion
In reply to Ian RogersSashiko reported:
When compiling the perf tool against a strict C library such as musl libc, a build failure occurs in home_perfconfig() and perf_config__set_variable() due to an undeclared PATH_MAX identifier.
The PATH_MAX macro is defined in the standard POSIX <limits.h> header. Because tools/perf/util/config.c does not explicitly include this header, build environments that lack implicit header inclusion fail to resolve the identifier. This causes a compiler error when evaluating the size of stack-allocated path arrays, stopping the build.
Add the header file.
--- tools/perf/util/config.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/config.c +1 -0
@@ -12,6 +12,7 @@#include "config.h" #include <errno.h> +#include <limits.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h>
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
[email protected]
AI reviewRe: [PATCH v1 10/11] perf config: undeclared PATH_MAX due to missing <limits.h> inclusion
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 14 lines
Sashiko reported:
When compiling the perf tool against a strict C library such as musl libc, a build failure occurs in
home_perfconfig()andperf_config__set_variable()due to an undeclaredPATH_MAXidentifier.The
PATH_MAXmacro is defined in the standard POSIX <limits.h> header. Becausetools/perf/util/config.cdoes not explicitly include this header, build environments that lack implicit header inclusion fail to resolve the identifier. This causes a compiler error when evaluating the size of stack-allocated path arrays, stopping the build.
Quoted 4 lines
Add the header file.
Reported-by [email protected]Signed-off-by Ian Rogers <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Ian Rogers
reviewerPATCH 11/11 perf mem: missing standard POSIX headers in builtin-mem.c
In reply to Ian RogersSashiko reported:
When compiling the perf tool with musl libc, the build fails in tools/perf/builtin-mem.c due to missing explicit include directives for standard POSIX headers.
The source file directly invokes standard libc functions, including calloc() and free() (from stdlib.h), strcmp() and strdup() (from string.h), and printf-family functions (from stdio.h). While glibc often provides these declarations implicitly by pulling them transitively through other headers like <unistd.h>, musl libc strictly enforces POSIX namespace boundaries and does not expose them implicitly.
Because tools/perf/builtin-mem.c lacks explicit #include directives for <stdlib.h>, <string.h>, and <stdio.h>, compiling against musl libc results in undeclared identifier and implicit function declaration errors for these standard library routines, causing a fatal build failure.
Add the header files and use git clang-format to sort.
--- tools/perf/builtin-mem.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
tools/perf/builtin-mem.c +15 -10
@@ -1,30 +1,35 @@// SPDX-License-Identifier: GPL-2.0 #include <errno.h> #include <inttypes.h> -#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <linux/err.h> #include <sys/stat.h> +#include <sys/types.h> #include <unistd.h> -#include "builtin.h" -#include "perf.h" #include <subcmd/parse-options.h> + +#include "builtin.h" +#include "perf.h" #include "util/auxtrace.h" -#include "util/trace-event.h" -#include "util/tool.h" -#include "util/session.h" #include "util/data.h" -#include "util/map_symbol.h" -#include "util/mem-events.h" #include "util/debug.h" #include "util/dso.h" #include "util/map.h" -#include "util/symbol.h" +#include "util/map_symbol.h" +#include "util/mem-events.h" #include "util/pmus.h" #include "util/sample.h" +#include "util/session.h" #include "util/sort.h" #include "util/string2.h" +#include "util/symbol.h" +#include "util/tool.h" +#include "util/trace-event.h" #include "util/util.h" -#include <linux/err.h> #define MEM_OPERATION_LOAD 0x1#define MEM_OPERATION_STORE 0x2
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
[email protected]
AI reviewRe: [PATCH v1 11/11] perf mem: missing standard POSIX headers in builtin-mem.c
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 20 lines
Sashiko reported:
When compiling the perf tool with musl libc, the build fails in
tools/perf/builtin-mem.cdue to missing explicit include directives for standard POSIX headers.The source file directly invokes standard libc functions, including
calloc()andfree()(fromstdlib.h),strcmp()andstrdup()(fromstring.h), and printf-family functions (fromstdio.h). While glibc often provides these declarations implicitly by pulling them transitively through other headers like <unistd.h>, musl libc strictly enforces POSIX namespace boundaries and does not expose them implicitly.Because
tools/perf/builtin-mem.clacks explicit #include directives for <stdlib.h>, <string.h>, and <stdio.h>, compiling against musl libc results in undeclared identifier and implicit function declaration errors for these standard library routines, causing a fatal build failure.
Quoted 4 lines
Add the header files and use git clang-format to sort.
Reported-by [email protected]Signed-off-by Ian Rogers <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 16 lines
Sashiko reported:
When building the perf utility against strict C standard libraries such as musl libc, compilation fails in
tools/perf/util/aslr.cdue to missing explicit inclusions of <stdlib.h> and <string.h>.The implementation relies on standard memory management and string functions like
malloc(),free(),memcpy(), andmemset()in routines such asaslr_tool__findnew_mapping(),aslr_tool__process_sample(), andaslr_tool__delete(). Because the required headers are omitted, the compiler must resolve these calls via implicit function declarations. While glibc may transitively provide these definitions via other headers, musl libc does not. This violates strict C99+ standard compliance and triggers fatal build errors under modern compiler configurations.
Quoted 4 lines
Add the header files and use git clang-format to sort.
Reported-by [email protected]Signed-off-by Ian Rogers <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1