* [PATCH] perf parse-events: Include errno.h before kernel headers
@ 2026-10-26 17:48 Florian Fainelli
2026-10-26 18:25 ` James Clark
0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2026-10-26 17:48 UTC (permalink / raw)
To: linux-kernel
Cc: Florian Fainelli, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Thomas Richter, Faisal Bukhari, Qinxin Xia,
Thomas Falcon, open list:PERFORMANCE EVENTS SUBSYSTEM
Building perf against uClibc fails in config_term_common():
util/parse-events.c:954:30: error: 'ERANGE' undeclared
The kernel headers included before errno.h pull in asm/errno.h. uClibc's
bits/errno.h undefines EDOM, EILSEQ and ERANGE before including
linux/errno.h, but the kernel header include guards prevent these macros
from being defined again.
Include errno.h before the kernel headers so ERANGE remains defined.
Fixes: 6b9c0261b3fb ("perf record: Add ratio-to-prev term")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
tools/perf/util/parse-events.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index cc7ad331a49f..efb46ba9ba22 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
+#include <errno.h>
#include <linux/hw_breakpoint.h>
#include <linux/err.h>
#include <linux/list_sort.h>
#include <linux/zalloc.h>
#include <dirent.h>
-#include <errno.h>
#include <sys/ioctl.h>
#include <sys/param.h>
#include "cpumap.h"
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] perf parse-events: Include errno.h before kernel headers
2026-10-26 17:48 [PATCH] perf parse-events: Include errno.h before kernel headers Florian Fainelli
@ 2026-10-26 18:25 ` James Clark
0 siblings, 0 replies; 2+ messages in thread
From: James Clark @ 2026-10-26 18:25 UTC (permalink / raw)
To: Florian Fainelli, linux-kernel
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Thomas Richter, Faisal Bukhari,
Qinxin Xia, Thomas Falcon,
open list:PERFORMANCE EVENTS SUBSYSTEM
On 26/10/2026 17:48, Florian Fainelli wrote:
> Building perf against uClibc fails in config_term_common():
>
> util/parse-events.c:954:30: error: 'ERANGE' undeclared
>
> The kernel headers included before errno.h pull in asm/errno.h. uClibc's
> bits/errno.h undefines EDOM, EILSEQ and ERANGE before including
> linux/errno.h, but the kernel header include guards prevent these macros
> from being defined again.
>
> Include errno.h before the kernel headers so ERANGE remains defined.
>
> Fixes: 6b9c0261b3fb ("perf record: Add ratio-to-prev term")
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
> tools/perf/util/parse-events.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index cc7ad331a49f..efb46ba9ba22 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -1,10 +1,10 @@
> // SPDX-License-Identifier: GPL-2.0
> +#include <errno.h>
> #include <linux/hw_breakpoint.h>
> #include <linux/err.h>
> #include <linux/list_sort.h>
> #include <linux/zalloc.h>
> #include <dirent.h>
> -#include <errno.h>
> #include <sys/ioctl.h>
> #include <sys/param.h>
> #include "cpumap.h"
This seems like a bug in uClibc, if it undefs something but then
includes a header to re-define it that it expects hasn't already been
included. But I suppose even if you fixed it we'd still need some kind
of workaround for older versions.
There's another workaround that is slightly less fragile and doesn't
have to be applied every time linux/err.h is included in this order. If
you change the asm/errno.h include in tools/include/linux/err.h to
errno.h then the libc one will always be processed first. It probably
makes sense for the userspace copy of the header to use a libc errno anyway.
But maybe it's just as hacky as this fix.
Either way:
Reviewed-by: James Clark <james.clark@linaro.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-26 18:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 17:48 [PATCH] perf parse-events: Include errno.h before kernel headers Florian Fainelli
2026-10-26 18:25 ` James Clark
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®