[PATCH 02/27] gdb/testsuite: Use unprefixed runtest for a native Windows/MSVC build

Pedro Alves <[email protected]> Thu, 23 Jul 2026 14:00:53 +0100
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
This is the first of two pieces making plain "make check" Just Work
when testing a MinGW-hosted GDB targeting the MSVC ABI:

 --host=x86_64-w64-mingw32 --target=x86_64-pc-windows-msvc

When running the testsuite for a configuration where the host and
target triplets differ, the testsuite Makefile runs a target-prefixed
runtest -- e.g. x86_64-pc-windows-msvc-runtest, which fails with:

 /bin/sh: line 1: x86_64-pc-windows-msvc-runtest: command not found

For a MinGW-hosted GDB targeting the MSVC ABI, the two triplets
differ, but it's still a native configuration and the plain "runtest"
should be used.

This is the same native-vs-cross distinction that gdb/configure.ac
already makes for gdb_native, so fix this by factoring that logic into
a new GDB_AC_NATIVE m4 macro and use it in both places.
gdb/gdb-native.m4 is now included by both gdb/configure.ac (via
acinclude.m4) and gdb/testsuite/configure.ac (via aclocal.m4), the
same way transform.m4 is shared.

Change-Id: Ia2d8cc0c685d8dd0a070f570798817e620857ab1
---
 gdb/acinclude.m4           |  3 +++
 gdb/configure              | 40 +++++++++++++++++++-------------------
 gdb/configure.ac           | 23 +++-------------------
 gdb/gdb-native.m4          | 30 ++++++++++++++++++++++++++++
 gdb/testsuite/Makefile.in  |  3 ++-
 gdb/testsuite/aclocal.m4   |  1 +
 gdb/testsuite/configure    | 19 ++++++++++++++++++
 gdb/testsuite/configure.ac |  5 +++++
 8 files changed, 83 insertions(+), 41 deletions(-)
 create mode 100644 gdb/gdb-native.m4

diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 64cbab0b93a..c74e2d3dcba 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -15,6 +15,9 @@ m4_include(acx_configure_dir.m4)
 # This gets GDB_AC_TRANSFORM.
 m4_include(transform.m4)
 
+# This gets GDB_AC_NATIVE.
+m4_include(gdb-native.m4)
+
 # This get AM_GDB_COMPILER_TYPE.
 m4_include(../gdbsupport/compiler-type.m4)
 
diff --git a/gdb/configure b/gdb/configure
index 93b2df6f99b..f0f90b6be08 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -25218,26 +25218,26 @@ CPPFLAGS=$OLD_CPPFLAGS
 # configuration.
 gdb_host_obs=posix-hdep.o
 
-# Check whether the configuration is native -- i.e., whether GDB will
-# debug processes running on the same machine it runs on.  If so, we
-# let configure.host and configure.nat pull in the native-debug
-# support.
-gdb_native=no
-if test "${target}" = "${host}"; then
-  gdb_native=yes
-elif test "${host_cpu}" = "${target_cpu}"; then
-  # Debugging Windows binaries on a Windows host is native even when
-  # the host and target triplets differ across the mingw/cygwin/msvc
-  # ABI boundary.  E.g., a mingw32-hosted GDB targeting binaries
-  # produced by a compiler defaulting to windows-msvc.
-  case ${host_os} in
-    mingw* | cygwin*)
-      case ${target_os} in
-	mingw* | cygwin* | windows*)
-	  gdb_native=yes ;;
-      esac ;;
-  esac
-fi
+# Check whether the configuration is native.  If so, we let
+# configure.host and configure.nat pull in the native-debug support.
+
+  gdb_native=no
+  if test "${target}" = "${host}"; then
+    gdb_native=yes
+  elif test "${host_cpu}" = "${target_cpu}"; then
+    # Debugging Windows binaries on a Windows host is native even when
+    # the host and target triplets differ across the mingw/cygwin/msvc
+    # ABI boundary.  E.g., a mingw32-hosted GDB targeting binaries
+    # produced by a compiler defaulting to windows-msvc.
+    case ${host_os} in
+      mingw* | cygwin*)
+	case ${target_os} in
+	  mingw* | cygwin* | windows*)
+	    gdb_native=yes ;;
+	esac ;;
+    esac
+  fi
+
 
 . $srcdir/configure.host
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 50d04ff9027..30972e9a442 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -222,26 +222,9 @@ BFD_64_BIT
 # configuration.
 gdb_host_obs=posix-hdep.o
 
-# Check whether the configuration is native -- i.e., whether GDB will
-# debug processes running on the same machine it runs on.  If so, we
-# let configure.host and configure.nat pull in the native-debug
-# support.
-gdb_native=no
-if test "${target}" = "${host}"; then
-  gdb_native=yes
-elif test "${host_cpu}" = "${target_cpu}"; then
-  # Debugging Windows binaries on a Windows host is native even when
-  # the host and target triplets differ across the mingw/cygwin/msvc
-  # ABI boundary.  E.g., a mingw32-hosted GDB targeting binaries
-  # produced by a compiler defaulting to windows-msvc.
-  case ${host_os} in
-    mingw* | cygwin*)
-      case ${target_os} in
-	mingw* | cygwin* | windows*)
-	  gdb_native=yes ;;
-      esac ;;
-  esac
-fi
+# Check whether the configuration is native.  If so, we let
+# configure.host and configure.nat pull in the native-debug support.
+GDB_AC_NATIVE([gdb_native])
 
 . $srcdir/configure.host
 
diff --git a/gdb/gdb-native.m4 b/gdb/gdb-native.m4
new file mode 100644
index 00000000000..0849c04d14b
--- /dev/null
+++ b/gdb/gdb-native.m4
@@ -0,0 +1,30 @@
+# Copyright (C) 2026 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# GDB_AC_NATIVE([VAR])
+#
+# Determine whether this is a native configuration -- i.e., whether
+# GDB will debug processes running on the same machine it runs on.
+# Store "yes" or "no" in the output variable.
+
+AC_DEFUN([GDB_AC_NATIVE], [
+  $1=no
+  if test "${target}" = "${host}"; then
+    $1=yes
+  elif test "${host_cpu}" = "${target_cpu}"; then
+    # Debugging Windows binaries on a Windows host is native even when
+    # the host and target triplets differ across the mingw/cygwin/msvc
+    # ABI boundary.  E.g., a mingw32-hosted GDB targeting binaries
+    # produced by a compiler defaulting to windows-msvc.
+    case ${host_os} in
+      mingw* | cygwin*)
+	case ${target_os} in
+	  mingw* | cygwin* | windows*)
+	    $1=yes ;;
+	esac ;;
+    esac
+  fi
+])
diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in
index f103d7ddd65..b852dbceb50 100644
--- a/gdb/testsuite/Makefile.in
+++ b/gdb/testsuite/Makefile.in
@@ -28,6 +28,7 @@ program_transform_name = @program_transform_name@
 build_canonical = @build@
 host_canonical = @host@
 target_canonical = @target@
+gdb_native = @gdb_native@
 enable_libctf = @enable_libctf@
 
 SHELL = @SHELL@
@@ -66,7 +67,7 @@ RUNTEST_FOR_TARGET = `\
   if [ -f $${srcdir}/../../dejagnu/runtest ]; then \
     echo $${srcdir}/../../dejagnu/runtest; \
   else \
-    if [ "$(host_canonical)" = "$(target_canonical)" ]; then \
+    if [ "$(gdb_native)" = yes ]; then \
       echo runtest; \
     else \
       t='$(program_transform_name)'; echo runtest | sed -e $$t; \
diff --git a/gdb/testsuite/aclocal.m4 b/gdb/testsuite/aclocal.m4
index c5d3ba527a7..0fe30d7fc5c 100644
--- a/gdb/testsuite/aclocal.m4
+++ b/gdb/testsuite/aclocal.m4
@@ -2,6 +2,7 @@ m4_include(../../config/acx.m4)
 m4_include(../../config/override.m4)
 m4_include(../../config/enable.m4)
 m4_include(../transform.m4)
+m4_include(../gdb-native.m4)
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
diff --git a/gdb/testsuite/configure b/gdb/testsuite/configure
index 6ea9686516d..f2818fd0a0c 100755
--- a/gdb/testsuite/configure
+++ b/gdb/testsuite/configure
@@ -626,6 +626,7 @@ NM_TRANSFORM_NAME
 GAS_TRANSFORM_NAME
 READELF_TRANSFORM_NAME
 STRIP_TRANSFORM_NAME
+gdb_native
 EXTRA_RULES
 EGREP
 GREP
@@ -3449,6 +3450,24 @@ if test "${build}" = "${host}" -a "${host}" = "${target}"; then
 fi
 
 
+# Whether this is a native configuration.  When it is, the testsuite
+# runs the unprefixed "runtest" rather than a target-prefixed one.
+
+  gdb_native=no
+  if test "${target}" = "${host}"; then
+    gdb_native=yes
+  elif test "${host_cpu}" = "${target_cpu}"; then
+    case ${host_os} in
+      mingw* | cygwin*)
+	case ${target_os} in
+	  mingw* | cygwin* | windows*)
+	    gdb_native=yes ;;
+	esac ;;
+    esac
+  fi
+
+
+
 # Transform the name of some programs and generate the lib/pdtrace
 # test tool.
 test "$program_prefix" != NONE &&
diff --git a/gdb/testsuite/configure.ac b/gdb/testsuite/configure.ac
index 6eae19656df..8e64b216f95 100644
--- a/gdb/testsuite/configure.ac
+++ b/gdb/testsuite/configure.ac
@@ -86,6 +86,11 @@ if test "${build}" = "${host}" -a "${host}" = "${target}"; then
 fi
 AC_SUBST(EXTRA_RULES)
 
+# Whether this is a native configuration.  When it is, the testsuite
+# runs the unprefixed "runtest" rather than a target-prefixed one.
+GDB_AC_NATIVE([gdb_native])
+AC_SUBST(gdb_native)
+
 # Transform the name of some programs and generate the lib/pdtrace
 # test tool.
 AC_ARG_PROGRAM
-- 
2.54.0