[openwrt/openwrt] uboot-mvebu: backport patch to fix compilation on non glibc system

LEDE Commits lede-commits at lists.infradead.org
Mon Oct 3 15:13:38 PDT 2022


hauke pushed a commit to openwrt/openwrt.git, branch openwrt-22.03:
https://git.openwrt.org/1ff2993edb89b616f1fc7847fe40195ece1a1974

commit 1ff2993edb89b616f1fc7847fe40195ece1a1974
Author: Josef Schlehofer <pepe.schlehofer at gmail.com>
AuthorDate: Wed Sep 14 15:19:56 2022 +0200

    uboot-mvebu: backport patch to fix compilation on non glibc system
    
    This issue was reported by @paper42, who is using Void Linux with musl
    to compile OpenWrt and its packages and found out it is not possible to
    compile U-boot for Turris Omnia (neither any other).
    
    It fixes following output:
    ```
      HOSTCC  tools/kwboot
    tools/kwboot.c: In function 'kwboot_tty_change_baudrate':
    tools/kwboot.c:662:6: error: 'struct termios' has no member named 'c_ospeed'
      662 |   tio.c_ospeed = tio.c_ispeed = baudrate;
          |      ^
    tools/kwboot.c:662:21: error: 'struct termios' has no member named 'c_ispeed'
      662 |   tio.c_ospeed = tio.c_ispeed = baudrate;
          |                     ^
    tools/kwboot.c:690:31: error: 'struct termios' has no member named 'c_ospeed'
      690 |  if (!_is_within_tolerance(tio.c_ospeed, baudrate, 3))
          |                               ^
    tools/kwboot.c:693:31: error: 'struct termios' has no member named 'c_ispeed'
      693 |  if (!_is_within_tolerance(tio.c_ispeed, baudrate, 3))
          |
    ```
    
    Tested-by: Michal Vasilek <michal.vasilek at nic.cz>
    Signed-off-by: Josef Schlehofer <pepe.schlehofer at gmail.com>
    (cherry picked from commit 9c7472950b01c5b3a461f4e29b3b62bac9e35b46)
---
 ...os_linux.h-Fix-compilation-on-non-glibc-s.patch | 44 ++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/package/boot/uboot-mvebu/patches/0001-tools-termios_linux.h-Fix-compilation-on-non-glibc-s.patch b/package/boot/uboot-mvebu/patches/0001-tools-termios_linux.h-Fix-compilation-on-non-glibc-s.patch
new file mode 100644
index 0000000000..e2f8a08bea
--- /dev/null
+++ b/package/boot/uboot-mvebu/patches/0001-tools-termios_linux.h-Fix-compilation-on-non-glibc-s.patch
@@ -0,0 +1,44 @@
+From 82a6da13c3a113eefdb378ff53635f32a6184d6f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali at kernel.org>
+Date: Thu, 8 Sep 2022 16:59:36 +0200
+Subject: [PATCH] tools: termios_linux.h: Fix compilation on non-glibc systems
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+TCGETS2 is defined in header file asm/ioctls.h provided by linux kernel.
+On glib systems it is automatically included by some other glibc include
+header file and therefore TCGETS2 is present in termios_linux.h when
+linux kernel provides it.
+
+On non-glibc systems (e.g. musl) asm/ioctls.h is not automatically included
+which results in the strange error that BOTHER is supported, TCGETS2 not
+defined and struct termios does not provide c_ispeed member.
+
+    tools/kwboot.c: In function 'kwboot_tty_change_baudrate':
+    tools/kwboot.c:662:6: error: 'struct termios' has no member named 'c_ospeed'
+      662 |   tio.c_ospeed = tio.c_ispeed = baudrate;
+          |      ^
+
+Fix this issue by explicitly including asm/ioctls.h file which provides
+TCGETS2 macro (if supported on selected architecture) to not depending on
+glibc auto-include behavior and because termios_linux.h requires it.
+
+With this change it is possible compile kwboot with musl libc.
+
+Reported-by: Michal Vasilek <michal.vasilek at nic.cz>
+Signed-off-by: Pali Rohár <pali at kernel.org>
+---
+ tools/termios_linux.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/tools/termios_linux.h
++++ b/tools/termios_linux.h
+@@ -29,6 +29,7 @@
+ #include <errno.h>
+ #include <sys/ioctl.h>
+ #include <sys/types.h>
++#include <asm/ioctls.h>
+ #include <asm/termbits.h>
+ 
+ #if defined(BOTHER) && defined(TCGETS2)




More information about the lede-commits mailing list