On attempt to cross-compiler perf utility of Linux kernel sources in a range from v5.15 to v6.0 the following happens on CentOS 7.x machines (there host GCC is of version 4.8.5):
HOSTCC pmu-events/jevents.o
In file included from .../tools/include/linux/compiler_types.h:36:0,
from .../tools/include/linux/compiler.h:5,
from pmu-events/jevents.c:48:
.../tools/include/linux/compiler-gcc.h:19:20: error: missing binary operator before token "("
#if __has_attribute(__error__)
^
make[3]: *** [pmu-events/jevents.o] Error 1
That happens because tools/perf/pmu-events/jevents.c (JSON events parser) gets compiled by HOSTCC (and that's not a bug - it's by design).
On attempt to cross-compiler
perf
utility of Linux kernel sources in a range from v5.15 to v6.0 the following happens on CentOS 7.x machines (there host GCC is of version 4.8.5):That happens because
tools/perf/pmu-events/jevents.c
(JSON events parser) gets compiled byHOSTCC
(and that's not a bug - it's by design).Before the Linux kernel v5.15 there used to be a work-around for older GCC versions, which got removed with https://github.com/torvalds/linux/commit/4e59869aa655 (and subsequent fix for CLANG introduced also not supported by older GCC's
__has_attribute
construction via https://github.com/torvalds/linux/commit/d0ee23f9d78be5531c4b055ea424ed0b489dfe9b).Luckily in the kernel v6.0 JSON events parser was rewritten in Python (https://github.com/torvalds/linux/commit/00facc760903be6675870c2749e2cd72140e396e) and so, there's no more
HOSTCC
to get in the way. I.e.perf
is again cross-compilable even on CentOS 7.x.But surely there're more cases like that and basically the only robust solution is to use GCC newer than v5.1.0 on a build host!