]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/ser-unix: fix musl build failure when setting custom baud rates
authorSunil Dora <sunilkumar.dora@windriver.com>
Tue, 24 Mar 2026 16:45:26 +0000 (09:45 -0700)
committerSam James <sam@gentoo.org>
Sun, 19 Apr 2026 16:24:45 +0000 (17:24 +0100)
On musl-based systems, <asm/termbits.h> may expose BOTHER even though
struct termios does not define c_ispeed/c_ospeed.  This causes the
Linux-specific custom baud rate path to be compiled and fail to build.

Fix the problem at the macro level by requiring
HAVE_STRUCT_TERMIOS_C_OSPEED (obtained via AC_CHECK_MEMBERS) together
with BOTHER in the HAVE_CUSTOM_BAUDRATE_SUPPORT guard.  This prevents
the Linux-specific code from being compiled on musl while leaving
set_custom_baudrate_linux unchanged.

This is a pure build fix with no functional or behavioural change on
any existing platform.

Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk>
Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com>
Approved-by: Kevin Buettner <kevinb@redhat.com>
gdb/config.in
gdb/configure
gdb/configure.ac
gdb/ser-unix.c

index b11fcf18372617af219139eda38c363928c38bf4..6ad5240397bfef644be04f2779b50f8e9165d31c 100644 (file)
 /* Define to 1 if `st_blocks' is a member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_BLOCKS
 
+/* Define to 1 if `c_ospeed' is a member of `struct termios'. */
+#undef HAVE_STRUCT_TERMIOS_C_OSPEED
+
 /* Define to 1 if `td_pcb' is a member of `struct thread'. */
 #undef HAVE_STRUCT_THREAD_TD_PCB
 
index abac48b92b25d9fb612d4388e7fa559cfb1c5b82..64470a856ad68eeb8278693c83bf6e0eb02d98e2 100755 (executable)
@@ -27730,6 +27730,19 @@ if test "$ac_res" != no; then :
 fi
 
 
+# Check for members required by the legacy Linux custom baud rate path.
+ac_fn_c_check_member "$LINENO" "struct termios" "c_ospeed" "ac_cv_member_struct_termios_c_ospeed" "#include <termios.h>
+"
+if test "x$ac_cv_member_struct_termios_c_ospeed" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_TERMIOS_C_OSPEED 1
+_ACEOF
+
+
+fi
+
+
 
 
 # Check whether --with-jit-reader-dir was given.
index cad343ebe8be46959a8a8bfa4fb5e00289b3edb1..76a22c9cf3ddfbe3fe22ca43e44e9b4ef86d14d9 100644 (file)
@@ -725,6 +725,9 @@ AC_CONFIG_FILES([jit-reader.h:jit-reader.in])
 
 AC_SEARCH_LIBS(dlopen, dl)
 
+# Check for members required by the legacy Linux custom baud rate path.
+AC_CHECK_MEMBERS([struct termios.c_ospeed], [], [], [[#include <termios.h>]])
+
 GDB_AC_WITH_DIR([JIT_READER_DIR], [jit-reader-dir],
                [directory to load the JIT readers from],
                [${libdir}/gdb])
index c295a9c5ba1ba86c95976f453c963b43e8319fb0..72c46d29e8f8ed659528a03b08d07a70dc48a5a7 100644 (file)
@@ -55,7 +55,9 @@
 
 #include "gdbsupport/scoped_ignore_sigttou.h"
 
-#if defined(HAVE_SYS_IOCTL_H) && (defined(BOTHER) || defined(IOSSIOSPEED))
+#if (defined(HAVE_SYS_IOCTL_H) \
+     && ((defined(BOTHER) && defined(HAVE_STRUCT_TERMIOS_C_OSPEED)) \
+         || defined(IOSSIOSPEED)))
 #  define HAVE_CUSTOM_BAUDRATE_SUPPORT 1
 #endif