diff mbox

[OpenWrt-Devel] target/linux/mpc85xx: fix EDEADLOCK define collisions with musl

Message ID 1461659069-31664-1-git-send-email-ardeleanalex@gmail.com
State Rejected
Headers show

Commit Message

Alexandru Ardelean April 26, 2016, 8:24 a.m. UTC
libbpf fails to build.
perf just emits a warning and carries on.

This is a collision between linux's <errno.h> and musl's <errno.h>
when building for powerpc.

For powerpc, EDEADLOCK has value 58.
The initial definition in the kernel
  include/uapi/asm-generic/errno.h : #define EDEADLOCK EDEADLK
Then this gets overriden:
  arch/powerpc/include/uapi/asm/errno.h : #define EDEADLOCK  58

And in musl:
  arch/powerpc/bits/errno.h : #define EDEADLOCK       58

There would be 2 ways to solve this:
 1. Patch perf, libbpf and other tools to change the inclusion order of <errno.h>
 2. Patch the kernel just for the powerpc arch to not re-define EDEADLOCK if defined

I chose 2.
diff mbox


Build failure is:
  CC       libbpf.o
In file included from /home/sandu/work/Wrt1/openwrt/build_dir/target-powerpc_8540_musl-1.1.14_ewok/linux-mpc85xx_ewok/linux-4.4.6/arch/powerpc/include/uapi/asm/errno.h:4:0,
                 from /home/sandu/work/Wrt1/openwrt/build_dir/target-powerpc_8540_musl-1.1.14_ewok/linux-mpc85xx_ewok/linux-4.4.6/tools/include/linux/err.h:7,
                 from libbpf.h:13,
                 from libbpf.c:24:
/home/sandu/work/Wrt1/openwrt/build_dir/target-powerpc_8540_musl-1.1.14_ewok/linux-mpc85xx_ewok/linux-4.4.6/include/uapi/asm-generic/errno.h:39:0: error: "EDEADLOCK" redefined [-Werror]
In file included from /home/sandu/work/Wrt1/openwrt/staging_dir/toolchain-powerpc_8540_gcc-5.3.0_musl-1.1.14/include/errno.h:10:0,
                 from libbpf.c:16:
/home/sandu/work/Wrt1/openwrt/staging_dir/toolchain-powerpc_8540_gcc-5.3.0_musl-1.1.14/include/bits/errno.h:58:0: note: this is the location of the previous definition
    #define EDEADLOCK       58
cc1: all warnings being treated as errors
  CC       bpf.o
  LD       libbpf-in.o
powerpc-openwrt-linux-musl-ld: cannot find libbpf.o: No such file or directory

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
 .../301-fix-edeadlock-define-collisions-with-musl.patch   | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 target/linux/mpc85xx/patches-4.4/301-fix-edeadlock-define-collisions-with-musl.patch

diff --git a/target/linux/mpc85xx/patches-4.4/301-fix-edeadlock-define-collisions-with-musl.patch b/target/linux/mpc85xx/patches-4.4/301-fix-edeadlock-define-collisions-with-musl.patch
new file mode 100644
index 0000000..57a35f6
--- /dev/null
+++ b/target/linux/mpc85xx/patches-4.4/301-fix-edeadlock-define-collisions-with-musl.patch
@@ -0,0 +1,15 @@ 
+diff --git a/include/uapi/asm-generic/errno.h b/include/uapi/asm-generic/errno.h
+index 88e0914..7549bec 100644
+--- a/include/uapi/asm-generic/errno.h
++++ b/include/uapi/asm-generic/errno.h
+@@ -36,7 +36,9 @@
+ #define	EBADRQC		56	/* Invalid request code */
+ #define	EBADSLT		57	/* Invalid slot */
++#ifndef EDEADLOCK
++#define	EDEADLOCK	58
+ #define	EBFONT		59	/* Bad font file format */
+ #define	ENOSTR		60	/* Device not a stream */