Re: [PATCH v2] powerpc: fix EDEADLOCK redefinition error in uapi/asm/errno.h
On Thu, 17 Sep 2020 at 07:34, Andreas Schwab wrote: > > On Sep 17 2020, Arnd Bergmann wrote: > > > The errno man page says they are supposed to be synonyms, > > and glibc defines it that way, while musl uses the numbers > > from the kernel. > > glibc also uses whatever the kernel defines. > That's right, and from my investigation this isn't a libc issue. The various libc flavours simply try to follow POSIX and the PPC ABI and aren't doing anything wrong. See errno.h for example (https://man7.org/linux/man-pages/man3/errno.3.html): EDEADLK: Resource deadlock avoided (POSIX.1-2001). EDEADLOCK: On most architectures, a synonym for EDEADLK. On some architectures (e.g., Linux MIPS, PowerPC, SPARC), it is a separate error code "File locking deadlock error". The root cause is unique to the Linux PPC code in arch/powerpc/include/uapi/asm/errno.h: >/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ >#ifndef _ASM_POWERPC_ERRNO_H >#define _ASM_POWERPC_ERRNO_H > >#include > >#undef EDEADLOCK >#define EDEADLOCK 58 /* File locking deadlock error */ > >#endif /* _ASM_POWERPC_ERRNO_H */ It includes "" to pull in various definitions but has the side-effect of redefining EDEADLOCK to a non-ABI value which conflicts with the libc errno.h, as I outline in the patch description. Other arches which also use different EDEADLOCK and EDEADLK values (mips,sparc) do not do this. They define EDEADLOCK *once*, with an ABI-consistent value, and don't have the same issue. The problem goes back a ways (as Arnd points out), affecting current stable and all LTS branches, so would be nice to get this sorted out. I'm certainly interested if there's a better way than proposed in this patch. > Andreas. > > -- > Andreas Schwab, sch...@linux-m68k.org > GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 > "And now for something completely different."
Re: [PATCH v2] powerpc: fix EDEADLOCK redefinition error in uapi/asm/errno.h
On Sep 17 2020, Arnd Bergmann wrote: > The errno man page says they are supposed to be synonyms, > and glibc defines it that way, while musl uses the numbers > from the kernel. glibc also uses whatever the kernel defines. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Re: [PATCH v2] powerpc: fix EDEADLOCK redefinition error in uapi/asm/errno.h
On Thu, Sep 17, 2020 at 1:55 PM Michael Ellerman wrote: > > [ Cc += linux-arch & Arnd ] > > Hi Tony, > > This looks OK to me, but I'm always a bit nervous about changes in uapi. > I've Cc'ed linux-arch and Arnd who look after the asm-generic headers, > which this is slightly related to, just in case. > > One minor comment below. > > Tony Ambardar writes: > > A few archs like powerpc have different errno.h values for macros > > EDEADLOCK and EDEADLK. In code including both libc and linux versions of > > errno.h, this can result in multiple definitions of EDEADLOCK in the > > include chain. Definitions to the same value (e.g. seen with mips) do > > not raise warnings, but on powerpc there are redefinitions changing the > > value, which raise warnings and errors (if using "-Werror"). > > > > Guard against these redefinitions to avoid build errors like the following, > > first seen cross-compiling libbpf v5.8.9 for powerpc using GCC 8.4.0 with > > musl 1.1.24: > > > > In file included from ../../arch/powerpc/include/uapi/asm/errno.h:5, > >from ../../include/linux/err.h:8, > >from libbpf.c:29: > > ../../include/uapi/asm-generic/errno.h:40: error: "EDEADLOCK" redefined > > [-Werror] > >#define EDEADLOCK EDEADLK > > > > In file included from > > toolchain-powerpc_8540_gcc-8.4.0_musl/include/errno.h:10, > >from libbpf.c:26: > > toolchain-powerpc_8540_gcc-8.4.0_musl/include/bits/errno.h:58: note: this > > is the location of the previous definition > >#define EDEADLOCK 58 > > > > cc1: all warnings being treated as errors > > > > Fixes: 95f28190aa01 ("tools include arch: Grab a copy of errno.h for arch's > > supported by perf") > > Fixes: c3617f72036c ("UAPI: (Scripted) Disintegrate > > arch/powerpc/include/asm") > > I suspect that's not the right commit to tag. It just moved errno.h from > arch/powerpc/include/asm to arch/powerpc/include/uapi/asm. It's content > was almost identical, and entirely identical as far as EDEADLOCK was > concerned. > > Prior to that the file lived in asm-powerpc/errno.h, eg: > > $ git cat-file -p b8b572e1015f^:include/asm-powerpc/errno.h > > Before that it was include/asm-ppc64/errno.h, content still the same. > > To go back further we'd have to look at the historical git trees, which > is probably overkill. I'm pretty sure it's always had this problem. > > So we should probably drop the Fixes tags and just Cc: stable, that > means please backport it as far back as possible. I can see that the two numbers (35 and 58) were consistent across multiple architectures (i386, m68k, ppc32) up to linux-2.0.1, while other architectures had two unique numbers (alpha, mips, sparc) at the time, and sparc had BSD and Solaris compatible numbers in addition. In linux-2.0.2, alpha and i386 got changed to use 35 for both, but the other architectures remained unchanged. All later architectures followed x86 in using the same number for both. I foudn a message about tcl breaking at compile time when it changed: http://lkml.iu.edu/hypermail/linux/kernel/9607.3/0500.html The errno man page says they are supposed to be synonyms, and glibc defines it that way, while musl uses the numbers from the kernel. Arnd
Re: [PATCH v2] powerpc: fix EDEADLOCK redefinition error in uapi/asm/errno.h
On Thu, 17 Sep 2020 at 04:55, Michael Ellerman wrote: > > [ Cc += linux-arch & Arnd ] > > Hi Tony, > > This looks OK to me, but I'm always a bit nervous about changes in uapi. > I've Cc'ed linux-arch and Arnd who look after the asm-generic headers, > which this is slightly related to, just in case. > I agree with the caution and would welcome any other insights. > One minor comment below. > > Tony Ambardar writes: > > A few archs like powerpc have different errno.h values for macros > > EDEADLOCK and EDEADLK. In code including both libc and linux versions of > > errno.h, this can result in multiple definitions of EDEADLOCK in the > > include chain. Definitions to the same value (e.g. seen with mips) do > > not raise warnings, but on powerpc there are redefinitions changing the > > value, which raise warnings and errors (if using "-Werror"). > > > > Guard against these redefinitions to avoid build errors like the following, > > first seen cross-compiling libbpf v5.8.9 for powerpc using GCC 8.4.0 with > > musl 1.1.24: > > > > In file included from ../../arch/powerpc/include/uapi/asm/errno.h:5, > >from ../../include/linux/err.h:8, > >from libbpf.c:29: > > ../../include/uapi/asm-generic/errno.h:40: error: "EDEADLOCK" redefined > > [-Werror] > >#define EDEADLOCK EDEADLK > > > > In file included from > > toolchain-powerpc_8540_gcc-8.4.0_musl/include/errno.h:10, > >from libbpf.c:26: > > toolchain-powerpc_8540_gcc-8.4.0_musl/include/bits/errno.h:58: note: this > > is the location of the previous definition > >#define EDEADLOCK 58 > > > > cc1: all warnings being treated as errors > > > > Fixes: 95f28190aa01 ("tools include arch: Grab a copy of errno.h for arch's > > supported by perf") > > Fixes: c3617f72036c ("UAPI: (Scripted) Disintegrate > > arch/powerpc/include/asm") > > I suspect that's not the right commit to tag. It just moved errno.h from > arch/powerpc/include/asm to arch/powerpc/include/uapi/asm. It's content > was almost identical, and entirely identical as far as EDEADLOCK was > concerned. > > Prior to that the file lived in asm-powerpc/errno.h, eg: > > $ git cat-file -p b8b572e1015f^:include/asm-powerpc/errno.h > > Before that it was include/asm-ppc64/errno.h, content still the same. > > To go back further we'd have to look at the historical git trees, which > is probably overkill. I'm pretty sure it's always had this problem. > > So we should probably drop the Fixes tags and just Cc: stable, that > means please backport it as far back as possible. > Yes, you're right. Those two commits were simply where I stopped tracing back the long chain. I'll drop them as you suggest and request a backport instead in the next version of the patch. Thanks for your feedback! > cheers > > > > Reported-by: Rosen Penev > > Signed-off-by: Tony Ambardar > > --- > > v1 -> v2: > > * clean up commit description formatting > > --- > > arch/powerpc/include/uapi/asm/errno.h | 1 + > > tools/arch/powerpc/include/uapi/asm/errno.h | 1 + > > 2 files changed, 2 insertions(+) > > > > diff --git a/arch/powerpc/include/uapi/asm/errno.h > > b/arch/powerpc/include/uapi/asm/errno.h > > index cc79856896a1..4ba87de32be0 100644 > > --- a/arch/powerpc/include/uapi/asm/errno.h > > +++ b/arch/powerpc/include/uapi/asm/errno.h > > @@ -2,6 +2,7 @@ > > #ifndef _ASM_POWERPC_ERRNO_H > > #define _ASM_POWERPC_ERRNO_H > > > > +#undef EDEADLOCK > > #include > > > > #undef EDEADLOCK > > diff --git a/tools/arch/powerpc/include/uapi/asm/errno.h > > b/tools/arch/powerpc/include/uapi/asm/errno.h > > index cc79856896a1..4ba87de32be0 100644 > > --- a/tools/arch/powerpc/include/uapi/asm/errno.h > > +++ b/tools/arch/powerpc/include/uapi/asm/errno.h > > @@ -2,6 +2,7 @@ > > #ifndef _ASM_POWERPC_ERRNO_H > > #define _ASM_POWERPC_ERRNO_H > > > > +#undef EDEADLOCK > > #include > > > > #undef EDEADLOCK > > -- > > 2.25.1
Re: [PATCH v2] powerpc: fix EDEADLOCK redefinition error in uapi/asm/errno.h
[ Cc += linux-arch & Arnd ] Hi Tony, This looks OK to me, but I'm always a bit nervous about changes in uapi. I've Cc'ed linux-arch and Arnd who look after the asm-generic headers, which this is slightly related to, just in case. One minor comment below. Tony Ambardar writes: > A few archs like powerpc have different errno.h values for macros > EDEADLOCK and EDEADLK. In code including both libc and linux versions of > errno.h, this can result in multiple definitions of EDEADLOCK in the > include chain. Definitions to the same value (e.g. seen with mips) do > not raise warnings, but on powerpc there are redefinitions changing the > value, which raise warnings and errors (if using "-Werror"). > > Guard against these redefinitions to avoid build errors like the following, > first seen cross-compiling libbpf v5.8.9 for powerpc using GCC 8.4.0 with > musl 1.1.24: > > In file included from ../../arch/powerpc/include/uapi/asm/errno.h:5, >from ../../include/linux/err.h:8, >from libbpf.c:29: > ../../include/uapi/asm-generic/errno.h:40: error: "EDEADLOCK" redefined > [-Werror] >#define EDEADLOCK EDEADLK > > In file included from > toolchain-powerpc_8540_gcc-8.4.0_musl/include/errno.h:10, >from libbpf.c:26: > toolchain-powerpc_8540_gcc-8.4.0_musl/include/bits/errno.h:58: note: this > is the location of the previous definition >#define EDEADLOCK 58 > > cc1: all warnings being treated as errors > > Fixes: 95f28190aa01 ("tools include arch: Grab a copy of errno.h for arch's > supported by perf") > Fixes: c3617f72036c ("UAPI: (Scripted) Disintegrate arch/powerpc/include/asm") I suspect that's not the right commit to tag. It just moved errno.h from arch/powerpc/include/asm to arch/powerpc/include/uapi/asm. It's content was almost identical, and entirely identical as far as EDEADLOCK was concerned. Prior to that the file lived in asm-powerpc/errno.h, eg: $ git cat-file -p b8b572e1015f^:include/asm-powerpc/errno.h Before that it was include/asm-ppc64/errno.h, content still the same. To go back further we'd have to look at the historical git trees, which is probably overkill. I'm pretty sure it's always had this problem. So we should probably drop the Fixes tags and just Cc: stable, that means please backport it as far back as possible. cheers > Reported-by: Rosen Penev > Signed-off-by: Tony Ambardar > --- > v1 -> v2: > * clean up commit description formatting > --- > arch/powerpc/include/uapi/asm/errno.h | 1 + > tools/arch/powerpc/include/uapi/asm/errno.h | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/arch/powerpc/include/uapi/asm/errno.h > b/arch/powerpc/include/uapi/asm/errno.h > index cc79856896a1..4ba87de32be0 100644 > --- a/arch/powerpc/include/uapi/asm/errno.h > +++ b/arch/powerpc/include/uapi/asm/errno.h > @@ -2,6 +2,7 @@ > #ifndef _ASM_POWERPC_ERRNO_H > #define _ASM_POWERPC_ERRNO_H > > +#undef EDEADLOCK > #include > > #undef EDEADLOCK > diff --git a/tools/arch/powerpc/include/uapi/asm/errno.h > b/tools/arch/powerpc/include/uapi/asm/errno.h > index cc79856896a1..4ba87de32be0 100644 > --- a/tools/arch/powerpc/include/uapi/asm/errno.h > +++ b/tools/arch/powerpc/include/uapi/asm/errno.h > @@ -2,6 +2,7 @@ > #ifndef _ASM_POWERPC_ERRNO_H > #define _ASM_POWERPC_ERRNO_H > > +#undef EDEADLOCK > #include > > #undef EDEADLOCK > -- > 2.25.1
[PATCH v2] powerpc: fix EDEADLOCK redefinition error in uapi/asm/errno.h
A few archs like powerpc have different errno.h values for macros EDEADLOCK and EDEADLK. In code including both libc and linux versions of errno.h, this can result in multiple definitions of EDEADLOCK in the include chain. Definitions to the same value (e.g. seen with mips) do not raise warnings, but on powerpc there are redefinitions changing the value, which raise warnings and errors (if using "-Werror"). Guard against these redefinitions to avoid build errors like the following, first seen cross-compiling libbpf v5.8.9 for powerpc using GCC 8.4.0 with musl 1.1.24: In file included from ../../arch/powerpc/include/uapi/asm/errno.h:5, from ../../include/linux/err.h:8, from libbpf.c:29: ../../include/uapi/asm-generic/errno.h:40: error: "EDEADLOCK" redefined [-Werror] #define EDEADLOCK EDEADLK In file included from toolchain-powerpc_8540_gcc-8.4.0_musl/include/errno.h:10, from libbpf.c:26: toolchain-powerpc_8540_gcc-8.4.0_musl/include/bits/errno.h:58: note: this is the location of the previous definition #define EDEADLOCK 58 cc1: all warnings being treated as errors Fixes: 95f28190aa01 ("tools include arch: Grab a copy of errno.h for arch's supported by perf") Fixes: c3617f72036c ("UAPI: (Scripted) Disintegrate arch/powerpc/include/asm") Reported-by: Rosen Penev Signed-off-by: Tony Ambardar --- v1 -> v2: * clean up commit description formatting --- arch/powerpc/include/uapi/asm/errno.h | 1 + tools/arch/powerpc/include/uapi/asm/errno.h | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/powerpc/include/uapi/asm/errno.h b/arch/powerpc/include/uapi/asm/errno.h index cc79856896a1..4ba87de32be0 100644 --- a/arch/powerpc/include/uapi/asm/errno.h +++ b/arch/powerpc/include/uapi/asm/errno.h @@ -2,6 +2,7 @@ #ifndef _ASM_POWERPC_ERRNO_H #define _ASM_POWERPC_ERRNO_H +#undef EDEADLOCK #include #undef EDEADLOCK diff --git a/tools/arch/powerpc/include/uapi/asm/errno.h b/tools/arch/powerpc/include/uapi/asm/errno.h index cc79856896a1..4ba87de32be0 100644 --- a/tools/arch/powerpc/include/uapi/asm/errno.h +++ b/tools/arch/powerpc/include/uapi/asm/errno.h @@ -2,6 +2,7 @@ #ifndef _ASM_POWERPC_ERRNO_H #define _ASM_POWERPC_ERRNO_H +#undef EDEADLOCK #include #undef EDEADLOCK -- 2.25.1