diff mbox series

[1/1] package/flashrom: fix redefinition of 'struct termios'

Message ID 20190723085516.17377-1-vadim4j@gmail.com
State Changes Requested
Headers show
Series [1/1] package/flashrom: fix redefinition of 'struct termios' | expand

Commit Message

Vadym Kochan July 23, 2019, 8:55 a.m. UTC
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/

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
---
 ...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

Comments

Thomas Petazzoni July 29, 2019, 7:13 a.m. UTC | #1
Hello,

+Waldemar in Cc.

On Tue, 23 Jul 2019 11:55:16 +0300
Vadim Kochan <vadim4j@gmail.com> wrote:

> 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.

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
Thomas Petazzoni Aug. 2, 2019, 8:57 a.m. UTC | #2
Hello Vadim,

On Tue, 23 Jul 2019 11:55:16 +0300
Vadim Kochan <vadim4j@gmail.com> wrote:

> 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/
> 
> Signed-off-by: Vadim Kochan <vadim4j@gmail.com>

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
Vadym Kochan Aug. 6, 2019, 8:55 a.m. UTC | #3
Hi Thomas,

On Fri, Aug 2, 2019 at 11:57 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello Vadim,
>
> On Tue, 23 Jul 2019 11:55:16 +0300
> Vadim Kochan <vadim4j@gmail.com> wrote:
>
> > 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/
> >
> > Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
>
> 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

I will try to handle this.

Regards,
Vadim Kochan
diff mbox series

Patch

diff --git a/package/flashrom/0002-custom_baud-fix-redefinition-of-struct-termios.patch b/package/flashrom/0002-custom_baud-fix-redefinition-of-struct-termios.patch
new file mode 100644
index 0000000000..5c4a681303
--- /dev/null
+++ b/package/flashrom/0002-custom_baud-fix-redefinition-of-struct-termios.patch
@@ -0,0 +1,36 @@ 
+From e94fd14bba4fe21dcb791a44d700ad7f036b8c7e Mon Sep 17 00:00:00 2001
+From: Vadim Kochan <vadim4j@gmail.com>
+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 <vadim4j@gmail.com>
+---
+ 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
+