package/flashrom: fix redefinition of 'struct termios'
PATCH 1/1 package/flashrom: fix redefinition of 'struct termios'
Both libc and linux defines 'struct termios', in termbits.h and termios.h which leads to the compilation error:
In file included from custom_baud.c:23:0:
/home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/asm-generic/termbits.h:12:8:
error: redefinition of 'struct termios'
struct termios {
^~~~~~~
In file included from
/home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/termios.h:39:0,
from
/home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/bits/ioctl-types.h:5,
from
/home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/sys/ioctl.h:29,
from custom_baud.c:21:
/home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/bits/termios.h:33:8:
note: originally defined here
struct termios {
^~~~~~~So fix it by renaming 'termios' to 'asmtermios' before termbits.h only, because 'struct termios2' is used only.
Fixes:
http://autobuild.buildroot.net/results/797dde5cbf0e94162c7cc7b557841605c78ac2f3/
--- ...d-fix-redefinition-of-struct-termios.patch | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 package/flashrom/0002-custom_baud-fix-redefinition-of-struct-termios.patch
package/flashrom/0002-custom_baud-fix-redefinition-of-struct-termios.patch new file +36 -0
@@ -0,0 +1,36 @@ +From e94fd14bba4fe21dcb791a44d700ad7f036b8c7e Mon Sep 17 00:00:00 2001 +From: Vadim Kochan <[email protected]> +Date: Tue, 23 Jul 2019 11:37:17 +0300 +Subject: [PATCH] custom_baud: fix redefinition of 'struct termios' + +both libc and linux kernel defines 'struct termios', once it is defined +via termbits.h and second time it is re-defined via sys/ioctl.h. But +because only termios2 is used so hide 'struct termios' by renaming it as +'struct asmtermios'. + +Signed-off-by: Vadim Kochan <[email protected]> +--- + custom_baud.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/custom_baud.c b/custom_baud.c +index caf2b78..22fb74f 100644 +--- a/custom_baud.c ++++ b/custom_baud.c +@@ -18,10 +18,12 @@ + #include "custom_baud.h" + + #if IS_LINUX +-#include <sys/ioctl.h> + #include <fcntl.h> ++#define termios asmtermios + #include <asm-generic/termbits.h> + #include <asm-generic/ioctls.h> ++#undef termios ++#include <sys/ioctl.h> + + /* + * This include hell above is why this is in a separate source file. See eg. +-- +2.17.1 +
Signature · 1 line
2.17.1
PATCH 1/1 package/flashrom: fix redefinition of 'struct termios'
Hello,
+Waldemar in Cc.
Quoted 21 lines · On Tue, 23 Jul 2019 11:55:16 +0300 Vadim Kochan <[email protected]> wrote:
Both libc and linux defines 'struct termios', in
termbits.handtermios.hwhich leads to the compilation error:In file included from custom_baud.c:23:0:
/home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/asm-generic/termbits.h:12:8: error: redefinition of 'struct termios' struct termios { ^~~~~~~ In file included from /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/termios.h:39:0, from /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/bits/ioctl-types.h:5, from /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/sys/ioctl.h:29, from custom_baud.c:21: /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/bits/termios.h:33:8: note: originally defined here struct termios { ^~~~~~~
Quoted 2 lines
So fix it by renaming 'termios' to 'asmtermios' before
termbits.honly, because 'struct termios2' is used only.
This issue only happens on PowerPC/uClibc, and on no other architecture. Do we have any idea why ? Couldn't this issue instead be a problem in uClibc headers ?
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/1 package/flashrom: fix redefinition of 'struct termios'
In reply to Vadim KochanHello Vadim,
Quoted 21 lines · On Tue, 23 Jul 2019 11:55:16 +0300 Vadim Kochan <[email protected]> wrote:
Both libc and linux defines 'struct termios', in
termbits.handtermios.hwhich leads to the compilation error:In file included from custom_baud.c:23:0:
/home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/asm-generic/termbits.h:12:8: error: redefinition of 'struct termios' struct termios { ^~~~~~~ In file included from /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/termios.h:39:0, from /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/bits/ioctl-types.h:5, from /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/sys/ioctl.h:29, from custom_baud.c:21: /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/bits/termios.h:33:8: note: originally defined here struct termios { ^~~~~~~
Quoted 7 lines
So fix it by renaming 'termios' to 'asmtermios' before
termbits.honly, because 'struct termios2' is used only.Fixes:
http://autobuild.buildroot.net/results/797dde5cbf0e94162c7cc7b557841605c78ac2f3/Signed-off-by Vadim Kochan <[email protected]>
Peter and I had a look at the issue, and our conclusion is that the actual problem is in uClibc-ng, and should be fixed here.
The problem is that the powerpc-specific ioctl-types.h in uClibc-ng includes <termios.h>,
see ./libc/sysdeps/linux/powerpc/bits/ioctl-types.h. But neither the MIPS-specific or the generic ioctl-types.h in uClibc-ng do that.
If you look at the history of libc/sysdeps/linux/powerpc/bits/ioctl-types.h, before commit e66d628551d918d4ee89d67fe62b627cae27d210, it was like the generic and MIPS ioctl-types.h, i.e defining a number of macros and structures, but certainly not including <termios.h>.
Then, if you look at glibc, indeed until commit d4795e4a43e6f0c221bc5dc64c612206a21a177b, the powerpc-specific ioctl-types.h was just including <termios.h>, but in this commit, they changed it back to define the different macros and structures.
So basically, the powerpc-specific ioctl-types.h in uClibc-ng needs to be resync'ed with the one from glibc, and it should fix the issue, in a proper way.
Could you test this, and if it works, send the patch to upstream uClibc-ng, and add it in package/uclibc/ in Buildroot, until uClibc-ng integrates it in a release ?
Thanks a lot!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/1 package/flashrom: fix redefinition of 'struct termios'
Hi Thomas,
Quoted 58 lines · Thomas Petazzoni
Hello Vadim,
Quoted 21 lines · On Tue, 23 Jul 2019 11:55:16 +0300 Vadim Kochan <[email protected]> wrote:
Both libc and linux defines 'struct termios', in
termbits.handtermios.hwhich leads to the compilation error:In file included from custom_baud.c:23:0:
/home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/asm-generic/termbits.h:12:8: error: redefinition of 'struct termios' struct termios { ^~~~~~~ In file included from /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/termios.h:39:0, from /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/bits/ioctl-types.h:5, from /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/sys/ioctl.h:29, from custom_baud.c:21: /home/buildroot/autobuild/instance-3/output/host/powerpc-buildroot-linux-uclibc/sysroot/usr/include/bits/termios.h:33:8: note: originally defined here struct termios { ^~~~~~~Quoted 7 lines
So fix it by renaming 'termios' to 'asmtermios' before
termbits.honly, because 'struct termios2' is used only.Fixes:
http://autobuild.buildroot.net/results/797dde5cbf0e94162c7cc7b557841605c78ac2f3/Signed-off-by Vadim Kochan <[email protected]>Peter and I had a look at the issue, and our conclusion is that the actual problem is in uClibc-ng, and should be fixed here.
The problem is that the powerpc-specific
ioctl-types.hin uClibc-ng includes <termios.h>,
see./libc/sysdeps/linux/powerpc/bits/ioctl-types.h. But neither the MIPS-specific or the genericioctl-types.hin uClibc-ng do that.If you look at the history of
libc/sysdeps/linux/powerpc/bits/ioctl-types.h, before commite66d628551d918d4ee89d67fe62b627cae27d210, it was like the generic and MIPSioctl-types.h, i.e defining a number of macros and structures, but certainly not including <termios.h>.Then, if you look at glibc, indeed until commit
d4795e4a43e6f0c221bc5dc64c612206a21a177b, the powerpc-specificioctl-types.hwas just including <termios.h>, but in this commit, they changed it back to define the different macros and structures.So basically, the powerpc-specific
ioctl-types.hin uClibc-ng needs to be resync'ed with the one from glibc, and it should fix the issue, in a proper way.
Quoted 7 lines
Could you test this, and if it works, send the patch to upstream uClibc-ng, and add it in package/uclibc/ in Buildroot, until uClibc-ng integrates it in a release ?
Thanks a lot!
Thomas
I will try to handle this.
Regards,
Vadim Kochan