new file mode 100644
@@ -0,0 +1,35 @@
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Date: Tue, 29 Sep 2026 02:14:39 +0000
+Subject: [PATCH] modbus-rtu: pull in TCGETS2/TCSETS2 from asm/ioctls.h on musl
+
+When HAVE_STRUCT_TERMIOS2 is set, this file issues the TCGETS2/TCSETS2
+ioctl requests together with struct termios2. On musl, <sys/ioctl.h>
+only declares the plain (non-termios2) TCGETS/TCSETS request codes;
+TCGETS2/TCSETS2 are only available from the kernel uapi ioctls header,
+so the build fails with "use of undeclared identifier 'TCGETS2'".
+
+Include <asm/ioctls.h> in this case. It is safe to add unconditionally
+here: it redefines TCGETS/TCSETS with the same values musl's
+<sys/ioctl.h> already uses, and glibc ships (and already indirectly
+includes) the very same header, so this is a no-op there.
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+diff --git a/src/modbus-rtu.c b/src/modbus-rtu.c
+index 87e0887..1e98e74 100644
+--- a/src/modbus-rtu.c
++++ b/src/modbus-rtu.c
+@@ -14,6 +14,12 @@
+ #endif
+ #if defined(HAVE_STRUCT_TERMIOS2)
+ #include <sys/ioctl.h>
++/* On musl, <sys/ioctl.h> only provides the plain (non-termios2) TCGETS/
++ * TCSETS request codes; TCGETS2/TCSETS2 (used below with struct termios2)
++ * come from the kernel uapi ioctls header. <asm/ioctls.h> is safe to add
++ * unconditionally here: it redefines TCGETS/TCSETS with the same values
++ * musl already uses, and glibc ships the same header too. */
++#include <asm/ioctls.h>
+ #endif
+ #include "modbus-private.h"
+ #include <assert.h>
@@ -6,7 +6,9 @@ SECTION = "libs"
LICENSE = "LGPL-2.1-or-later"
LIC_FILES_CHKSUM = "file://COPYING.LESSER;md5=4fbd65380cdd255951079008b364516c"
-SRC_URI = "git://github.com/stephane/libmodbus;branch=master;protocol=https;tag=v${PV}"
+SRC_URI = "git://github.com/stephane/libmodbus;branch=master;protocol=https;tag=v${PV} \
+ file://0001-modbus-rtu-pull-in-TCGETS2-TCSETS2-from-asm-ioctls.h.patch \
+ "
SRCREV = "a9b025d12289855490b10d77461c99e001abfc0f"
modbus-rtu.c uses the Linux-specific TCGETS2/TCSETS2 ioctls, which glibc's <asm/termbits.h>/<asm/ioctls.h> chain declares transitively via <termios.h>, but musl's don't. AI-Generated: Uses Claude Code Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com> --- ...in-TCGETS2-TCSETS2-from-asm-ioctls.h.patch | 35 +++++++++++++++++++ .../libmodbus/libmodbus_3.2.0.bb | 4 ++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-extended/libmodbus/files/0001-modbus-rtu-pull-in-TCGETS2-TCSETS2-from-asm-ioctls.h.patch