[PATCH] perf arm pmu: fix build error on MUSL libc

Will Deacon will at kernel.org
Mon Dec 7 05:53:59 EST 2020


On Sun, Dec 06, 2020 at 11:45:27PM +0900, Chanho Park wrote:
> __always_inline can cause build error on musl libc. The fix patch has
> submitted but not merged yet[1]. To build perf tool with musl libc,
> <linux/stddef.h> inclusion is necessary and it should be included before
> perf_event.h.
> 
> from /usr/include/linux/byteorder/little_endian.h:13,
> from /usr/include/asm/byteorder.h:23,
> from tools/include/uapi/linux/perf_event.h:20,
> from arch/arm64/util/../../arm/util/pmu.c:9:
> 
> /usr/include/linux/swab.h:171:8: error: unknown type name '__always_inline'
>   171 | static __always_inline __u16 __swab16p(const __u16 *p)
>       |        ^~~~~~~~~~~~~~~
> 
> [1]: https://lkml.org/lkml/2018/9/13/78
> Cc: Mathieu Poirier <mathieu.poirier at linaro.org>
> Cc: Suzuki K Poulose <suzuki.poulose at arm.com>
> Cc: Mike Leach <mike.leach at linaro.org>
> Cc: Leo Yan <leo.yan at linaro.org>
> Cc: John Garry <john.garry at huawei.com>
> Cc: Will Deacon <will at kernel.org>
> Cc: Peter Zijlstra <peterz at infradead.org>
> Cc: Ingo Molnar <mingo at redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme at kernel.org>
> Cc: Mark Rutland <mark.rutland at arm.com>
> Cc: Jiri Olsa <jolsa at redhat.com>
> Cc: Namhyung Kim <namhyung at kernel.org>
> Cc: Khem Raj <raj.khem at gmail.com>
> Signed-off-by: Chanho Park <chanho61.park at samsung.com>
> ---
>  tools/perf/arch/arm/util/pmu.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/perf/arch/arm/util/pmu.c b/tools/perf/arch/arm/util/pmu.c
> index bbc297a7e2e3..4c0357e8c0ab 100644
> --- a/tools/perf/arch/arm/util/pmu.c
> +++ b/tools/perf/arch/arm/util/pmu.c
> @@ -6,6 +6,9 @@
>  
>  #include <string.h>
>  #include <linux/coresight-pmu.h>
> +#if !defined(__GLIBC__)
> +#include <linux/stddef.h>
> +#endif

Looks like other files just include this unconditionally, but have a comment
explaining why. See util/branch.h and util/event.h. Maybe we should do the
same for util/pmu.h, which is already included here?

Will



More information about the linux-arm-kernel mailing list