Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: sunilkumar.dora@windriver.com
To: gdb-patches@sourceware.org
Cc: SunilKumar.Dora@windriver.com, kevinb@redhat.com,
	macro@orcam.me.uk, eliz@gnu.org, Randy.MacLeod@windriver.com,
	Sundeep.Kokkonda@windriver.com, schwab@linux-m68k.org,
	tromey@sourceware.org, simark@simark.ca
Subject: [PATCH v5 1/2] gdb/ser-unix: fix musl build failure when setting custom baud rates
Date: Tue, 24 Mar 2026 09:45:26 -0700	[thread overview]
Message-ID: <20260324164527.1446549-2-sunilkumar.dora@windriver.com> (raw)
In-Reply-To: <20260324164527.1446549-1-sunilkumar.dora@windriver.com>

From: Sunil Dora <sunilkumar.dora@windriver.com>

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>
---
 gdb/config.in    |  3 +++
 gdb/configure    | 13 +++++++++++++
 gdb/configure.ac |  3 +++
 gdb/ser-unix.c   |  4 +++-
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/gdb/config.in b/gdb/config.in
index b11fcf18372..6ad5240397b 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -517,6 +517,9 @@
 /* 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
 
diff --git a/gdb/configure b/gdb/configure
index 12c54521682..72e69c9749f 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -27728,6 +27728,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.
diff --git a/gdb/configure.ac b/gdb/configure.ac
index cf8078e1d89..277eb945e84 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -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])
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
index c295a9c5ba1..72c46d29e8f 100644
--- a/gdb/ser-unix.c
+++ b/gdb/ser-unix.c
@@ -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
 
-- 
2.49.0


  reply	other threads:[~2026-03-24 16:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24 16:45 [PATCH v5 0/2] PR gdb/33747: gdb/ser-unix: fix musl build failure and add POSIX custom baud rate support sunilkumar.dora
2026-03-24 16:45 ` sunilkumar.dora [this message]
2026-03-24 16:45 ` [PATCH v5 2/2] gdb/ser-unix: add POSIX cfsetispeed/cfsetospeed support for custom baud rates sunilkumar.dora
2026-03-24 17:15   ` Eli Zaretskii
2026-03-27 18:15 ` [PATCH v5 0/2] PR gdb/33747: gdb/ser-unix: fix musl build failure and add POSIX custom baud rate support Kevin Buettner
2026-03-27 19:26   ` Sunil Kumar Dora
2026-04-14 16:28   ` Sunil Kumar Dora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260324164527.1446549-2-sunilkumar.dora@windriver.com \
    --to=sunilkumar.dora@windriver.com \
    --cc=Randy.MacLeod@windriver.com \
    --cc=Sundeep.Kokkonda@windriver.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=kevinb@redhat.com \
    --cc=macro@orcam.me.uk \
    --cc=schwab@linux-m68k.org \
    --cc=simark@simark.ca \
    --cc=tromey@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox