996ffc43ee515bcc063b188342909bc9a1bf749b
[openwrt/staging/rmilecki.git] /
1 From afe3f4c765b17ced23811fe652c7f7adf7a0c0cf Mon Sep 17 00:00:00 2001
2 From: Tony Ambardar <Tony.Ambardar@gmail.com>
3 Date: Mon, 14 Sep 2020 23:05:26 -0700
4 Subject: [PATCH] tools/arch/powerpc: fix EDEADLOCK redefinition errors in
5 errno.h
6
7 A few archs like powerpc have different errno.h values for macros
8 EDEADLOCK and EDEADLK. In code including both libc and linux versions of
9 errno.h, this can result in multiple definitions of EDEADLOCK in the
10 include chain. Definitions to the same value (e.g. seen with mips) do
11 not raise warnings, but on powerpc there are redefinitions changing the
12 value, which raise warnings and errors (with "-Werror").
13
14 Guard against these redefinitions to avoid build errors like the following,
15 first seen cross-compiling libbpf v5.8.9 for powerpc using GCC 8.4.0 with
16 musl 1.1.24:
17
18 In file included from ../../arch/powerpc/include/uapi/asm/errno.h:5,
19 from ../../include/linux/err.h:8,
20 from libbpf.c:29:
21 ../../include/uapi/asm-generic/errno.h:40: error: "EDEADLOCK" redefined [-Werror]
22 #define EDEADLOCK EDEADLK
23
24 In file included from toolchain-powerpc_8540_gcc-8.4.0_musl/include/errno.h:10,
25 from libbpf.c:26:
26 toolchain-powerpc_8540_gcc-8.4.0_musl/include/bits/errno.h:58: note: this is the location of the previous definition
27 #define EDEADLOCK 58
28
29 cc1: all warnings being treated as errors
30 make[5]: *** [target-powerpc_8540_musl/bpftools-5.8.9/tools/build/Makefile.build:97: /home/kodidev/openwrt-project/build_dir/target-powerpc_8540_musl/bpftools-minimal/bpftools-5.8.9//libbpf/staticobjs/libbpf.o] Error 1
31
32 Fixes: 95f28190aa01 ("tools include arch: Grab a copy of errno.h for arch's
33 supported by perf")
34 Fixes: c3617f72036c ("UAPI: (Scripted) Disintegrate arch/powerpc/include/asm")
35
36 Reported-by: Rosen Penev <rosenp@gmail.com>
37 Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com>
38 ---
39 tools/arch/powerpc/include/uapi/asm/errno.h | 1 +
40 1 file changed, 1 insertion(+)
41
42 --- a/tools/arch/powerpc/include/uapi/asm/errno.h
43 +++ b/tools/arch/powerpc/include/uapi/asm/errno.h
44 @@ -2,6 +2,7 @@
45 #ifndef _ASM_POWERPC_ERRNO_H
46 #define _ASM_POWERPC_ERRNO_H
47
48 +#undef EDEADLOCK
49 #include <asm-generic/errno.h>
50
51 #undef EDEADLOCK