diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 62fa66c7af3..f9812c182eb 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -21,6 +21,9 @@ m4_include(../gdbsupport/compiler-type.m4)
 # This gets AM_GDB_WARNINGS.
 m4_include(../gdbsupport/warning.m4)
 
+dnl This gets GDB_PKGVERSION_SUFFIX.
+m4_include(../gdbsupport/pkgversion-suffix.m4)
+
 # AM_GDB_UBSAN
 m4_include(sanitize.m4)
 
diff --git a/gdb/config.in b/gdb/config.in
index 736e6be1c48..163e780aa7f 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -642,6 +642,9 @@
 /* Additional package description */
 #undef PKGVERSION
 
+/* A string to append to the version number */
+#undef PKGVERSION_SUFFIX
+
 /* Define to 1 if the "%H, %D and %DD" formats work to print decfloats. */
 #undef PRINTF_HAS_DECFLOAT
 
diff --git a/gdb/configure b/gdb/configure
index b54ac671fe3..65caca4bdf5 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -923,6 +923,7 @@ enable_profiling
 enable_codesign
 with_pkgversion
 with_bugurl
+with_pkgversion_suffix
 with_system_zlib
 with_zstd
 enable_rpath
@@ -1682,6 +1683,8 @@ Optional Packages:
                           library
   --with-pkgversion=PKG   Use PKG in the version string in place of "GDB"
   --with-bugurl=URL       Direct users to URL to report a bug
+  --with-pkgversion-suffix=STRING
+                          Append STRING to the end of the version number
   --with-system-zlib      use installed libz
   --with-zstd             support zstd compressed debug sections
                           (default=auto)
@@ -11451,7 +11454,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11454 "configure"
+#line 11457 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11557,7 +11560,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11560 "configure"
+#line 11563 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16997,6 +17000,26 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+
+
+# Check whether --with-pkgversion-suffix was given.
+if test "${with_pkgversion_suffix+set}" = set; then :
+  withval=$with_pkgversion_suffix; case "$withval" in
+    yes) as_fn_error $? "version suffix not specified" "$LINENO" 5 ;;
+    no)  PKGVERSION_SUFFIX= ;;
+    *)   PKGVERSION_SUFFIX="$withval" ;;
+   esac
+else
+  PKGVERSION_SUFFIX=""
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define PKGVERSION_SUFFIX "$PKGVERSION_SUFFIX"
+_ACEOF
+
+
+
 # --------------------- #
 # Checks for programs.  #
 # --------------------- #
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 12561d4d2de..eaa79c6701a 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -427,6 +427,8 @@ ACX_BUGURL([https://www.gnu.org/software/gdb/bugs/])
 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
 
+GDB_PKGVERSION_SUFFIX
+
 # --------------------- #
 # Checks for programs.  #
 # --------------------- #
diff --git a/gdb/top.c b/gdb/top.c
index e9794184f07..9ead29be033 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1444,7 +1444,8 @@ print_gdb_version (struct ui_file *stream, bool interactive)
      program to parse, and is just canonical program name and version
      number, which starts after last space.  */
 
-  std::string v_str = string_printf ("GNU gdb %s%s", PKGVERSION, version);
+  std::string v_str = string_printf ("GNU gdb %s%s%s", PKGVERSION, version,
+				     PKGVERSION_SUFFIX);
   gdb_printf (stream, "%ps\n",
 	      styled_string (version_style.style (), v_str.c_str ()));
 
diff --git a/gdbserver/acinclude.m4 b/gdbserver/acinclude.m4
index 32d5d14ca6e..d49e606a88f 100644
--- a/gdbserver/acinclude.m4
+++ b/gdbserver/acinclude.m4
@@ -13,6 +13,9 @@ m4_include(../gdbsupport/compiler-type.m4)
 dnl This gets AM_GDB_WARNINGS.
 m4_include(../gdbsupport/warning.m4)
 
+dnl This gets GDB_PKGVERSION_SUFFIX.
+m4_include(../gdbsupport/pkgversion-suffix.m4)
+
 dnl codeset.m4 is needed for common.m4, but not for
 dnl anything else in gdbserver.
 m4_include(../config/codeset.m4)
diff --git a/gdbserver/config.in b/gdbserver/config.in
index 39ddc7c0edb..14414ff4ffa 100644
--- a/gdbserver/config.in
+++ b/gdbserver/config.in
@@ -402,6 +402,9 @@
 /* Additional package description */
 #undef PKGVERSION
 
+/* A string to append to the version number */
+#undef PKGVERSION_SUFFIX
+
 /* Define to 1 if the "%ll" format works to print long longs. */
 #undef PRINTF_HAS_LONG_LONG
 
diff --git a/gdbserver/configure b/gdbserver/configure
index 050264ed7da..0644a058d76 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -761,6 +761,7 @@ enable_build_warnings
 enable_gdb_build_warnings
 with_pkgversion
 with_bugurl
+with_pkgversion_suffix
 with_libthread_db
 enable_inprocess_agent
 '
@@ -1425,6 +1426,8 @@ Optional Packages:
   --with-ust-lib=PATH   Specify the directory for the installed UST library
   --with-pkgversion=PKG   Use PKG in the version string in place of "GDB"
   --with-bugurl=URL       Direct users to URL to report a bug
+  --with-pkgversion-suffix=STRING
+                          Append STRING to the end of the version number
   --with-libthread-db=PATH
                           use given libthread_db directly
 
@@ -10276,6 +10279,26 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+
+
+# Check whether --with-pkgversion-suffix was given.
+if test "${with_pkgversion_suffix+set}" = set; then :
+  withval=$with_pkgversion_suffix; case "$withval" in
+    yes) as_fn_error $? "version suffix not specified" "$LINENO" 5 ;;
+    no)  PKGVERSION_SUFFIX= ;;
+    *)   PKGVERSION_SUFFIX="$withval" ;;
+   esac
+else
+  PKGVERSION_SUFFIX=""
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define PKGVERSION_SUFFIX "$PKGVERSION_SUFFIX"
+_ACEOF
+
+
+
 # Check for various supplementary target information (beyond the
 # triplet) which might affect the choices in configure.srv.
 case "${target}" in
diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac
index dc33f1a235b..d53ea96316f 100644
--- a/gdbserver/configure.ac
+++ b/gdbserver/configure.ac
@@ -194,6 +194,8 @@ ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
 
+GDB_PKGVERSION_SUFFIX
+
 # Check for various supplementary target information (beyond the
 # triplet) which might affect the choices in configure.srv.
 case "${target}" in
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index aaef38e0062..c76edae08f2 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -3412,12 +3412,12 @@ handle_status (char *own_buf)
 static void
 gdbserver_version (void)
 {
-  printf ("GNU gdbserver %s%s\n"
+  printf ("GNU gdbserver %s%s%s\n"
 	  "Copyright (C) 2022 Free Software Foundation, Inc.\n"
 	  "gdbserver is free software, covered by the "
 	  "GNU General Public License.\n"
 	  "This gdbserver was configured as \"%s\"\n",
-	  PKGVERSION, version, host_name);
+	  PKGVERSION, version, PKGVERSION_SUFFIX, host_name);
 }
 
 static void
diff --git a/gdbsupport/pkgversion-suffix.m4 b/gdbsupport/pkgversion-suffix.m4
new file mode 100644
index 00000000000..f05ac495ab3
--- /dev/null
+++ b/gdbsupport/pkgversion-suffix.m4
@@ -0,0 +1,33 @@
+dnl Autoconf configure script for GDB, the GNU debugger.
+dnl Copyright (C) 2022 Free Software Foundation, Inc.
+dnl
+dnl This file is part of GDB.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+dnl Add support for the --with-pkgversion-suffix configure option.  Allows
+dnl the user to specify a string that is appended to the version number.
+AC_DEFUN([GDB_PKGVERSION_SUFFIX],[
+  AC_ARG_WITH(pkgversion-suffix,
+    AS_HELP_STRING([--with-pkgversion-suffix=STRING],
+                   [Append STRING to the end of the version number]),
+  [case "$withval" in
+    yes) AC_MSG_ERROR([version suffix not specified]) ;;
+    no)  PKGVERSION_SUFFIX= ;;
+    *)   PKGVERSION_SUFFIX="$withval" ;;
+   esac],
+    PKGVERSION_SUFFIX="")
+  AC_DEFINE_UNQUOTED([PKGVERSION_SUFFIX], ["$PKGVERSION_SUFFIX"],
+                     [A string to append to the version number])
+])
