gdb: new --with-pkgversion-suffix configure option

Message ID 86a03c4f56f167a7c08ce40200425d92a2ac39e8.1668165880.git.aburgess@redhat.com
State New
Headers
Series gdb: new --with-pkgversion-suffix configure option |

Commit Message

Andrew Burgess Nov. 11, 2022, 11:24 a.m. UTC
  Once GDB 13.1 is released, then the version string, for a build of GDB
made from the release branch should look like this:

  $ gdb --version
  GNU gdb (GDB) 13.1

We provide a configure option, --with-pkgversion, which allows control
over the 'GDB' string within '(GDB) ', and so, if we configure like
this:

  $ ../src/configure --with-pkgversion="My Distro"

then the final GDB's version string would look like this:

  $ gdb --version
  GNU gdb (My Distro) 13.1

It is not unreasonable to think that somebody building a distribution
specific version of GDB like this might want to also augment the
version number (13.1) in order to indicate a local patch level.

Now, the existing configure option, --with-pkgversion, clearly seems
to indicate that the package specific version number should be
included here, however, I don't find this result satisfactory.

Here are some possibilities.  I could include the full version number,
including my local patch number, like this:

  GNU gdb (My Distro 13.1.5) 13.1

I don't like this because of the duplication.  I could drop the
upstream version number, like this:

  GNU gdb (My Distro 5) 13.1

But I don't like this because it (IMHO) can lead to confusion, is this
GDB version 5?  Version 13.1?  I think this can potentially cause
confusion for a user.

I propose that a far better solution is to add a new configure option
that will allow me to attach additional content at the end of the
version string, like this:

  GNU gdb (My Distro) 13.1.5

This, I think, is much clearer.  To support this I propose adding a
new configure option, --with-pkgversion-suffix.  This option takes a
string, which is then appended to the version number.  And so, we now
configure like this:

  $ ../src/configure --with-pkgversion="My Distro" \
                     --with-pkgversion-suffix=".xx.yy"

And we now get the desired version output from both GDB and GDBServer:

  $ gdb --version
  GNU gdb (My Distro) 13.1.xx.yy
  $ gdbserver --version
  GNU gdbserver (My Distro) 13.1.xx.yy

Obviously, the new configure option is optional.  When it is not used
the suffix defaults to the empty string, so GDB's output will be
unchanged.
---
 gdb/acinclude.m4                |  3 +++
 gdb/config.in                   |  3 +++
 gdb/configure                   | 27 +++++++++++++++++++++++++--
 gdb/configure.ac                |  2 ++
 gdb/top.c                       |  3 ++-
 gdbserver/acinclude.m4          |  3 +++
 gdbserver/config.in             |  3 +++
 gdbserver/configure             | 23 +++++++++++++++++++++++
 gdbserver/configure.ac          |  2 ++
 gdbserver/server.cc             |  4 ++--
 gdbsupport/pkgversion-suffix.m4 | 33 +++++++++++++++++++++++++++++++++
 11 files changed, 101 insertions(+), 5 deletions(-)
 create mode 100644 gdbsupport/pkgversion-suffix.m4


base-commit: db2e277d1a840091f56185d94f9d39c6736d2556
  

Comments

Tom Tromey Nov. 16, 2022, 4:19 p.m. UTC | #1
>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:

Andrew> I propose that a far better solution is to add a new configure option
Andrew> that will allow me to attach additional content at the end of the
Andrew> version string, like this:

Andrew>   GNU gdb (My Distro) 13.1.5

Andrew> This, I think, is much clearer.  To support this I propose adding a
Andrew> new configure option, --with-pkgversion-suffix.  This option takes a
Andrew> string, which is then appended to the version number.  And so, we now
Andrew> configure like this:

This seems fine to me.

thanks,
Tom
  
Mike Frysinger Nov. 16, 2022, 4:58 p.m. UTC | #2
On 11 Nov 2022 11:24, Andrew Burgess via Gdb-patches wrote:
> Once GDB 13.1 is released, then the version string, for a build of GDB
> made from the release branch should look like this:
> 
>   $ gdb --version
>   GNU gdb (GDB) 13.1
> 
> We provide a configure option, --with-pkgversion, which allows control
> over the 'GDB' string within '(GDB) ', and so, if we configure like
> this:
> 
>   $ ../src/configure --with-pkgversion="My Distro"
> 
> then the final GDB's version string would look like this:
> 
>   $ gdb --version
>   GNU gdb (My Distro) 13.1
> 
> It is not unreasonable to think that somebody building a distribution
> specific version of GDB like this might want to also augment the
> version number (13.1) in order to indicate a local patch level.
> 
> Now, the existing configure option, --with-pkgversion, clearly seems
> to indicate that the package specific version number should be
> included here, however, I don't find this result satisfactory.
> 
> Here are some possibilities.  I could include the full version number,
> including my local patch number, like this:
> 
>   GNU gdb (My Distro 13.1.5) 13.1
> 
> I don't like this because of the duplication.  I could drop the
> upstream version number, like this:
> 
>   GNU gdb (My Distro 5) 13.1
> 
> But I don't like this because it (IMHO) can lead to confusion, is this
> GDB version 5?  Version 13.1?  I think this can potentially cause
> confusion for a user.
> 
> I propose that a far better solution is to add a new configure option
> that will allow me to attach additional content at the end of the
> version string, like this:
> 
>   GNU gdb (My Distro) 13.1.5

i strongly dislike this proposal because it's smooshing distro versions and
official versions with no clear separation at all.  this is bad for us, bad
for our users, and imo bad for even the distros/vendors.

if --with-pkgversion= isn't specified, the users will see the bare version only.
(yes, i'm aware people can patch the source to display whatever they want, but
that doesn't mean we have to encourage or make it easy to do)

even if it is specified, users will say things like "i'm using GDB 13.1.5",
and then we'll have to figure out whose "13.1.5" that is.  users will also do
things like search for "GDB version 13.1.5" and then get confused when no such
release exists.

it also means once we release a GDB version X, we can never release a point
version after that (e.g. X.Y).  which is what these docs, albeit perhaps
outdated, explain:
https://sourceware.org/gdb/wiki/Internals%20Versions
i'm aware that currently we've moved to X.Y and don't seem to ever plan on
doing plain X or X.Y.Z, but that doesn't mean we should cede the entire
future to random vendors.

backing up a bit, the example you provided is:
> GNU gdb (My Distro 13.1.5) 13.1
first off, i don't see a problem with the duplication, but that's me.
second, it sounds like your distro is claiming version numbers it shouldn't ?
why are you calling it version "13.1.5" instead of "13.1 patch 5" or "13.1-5"
or something like that ?  this sounds like a bug in the distro/vendor that
you're working on.

in Gentoo we use:
> GNU gdb (Gentoo 12.1 p3) 12.1
> GNU gdb (Gentoo 12.1 vanilla) 12.1
to make it very clear to everyone involved:
(1) it's a Gentoo build
(2) what our upstream base version is
(3) what the Gentoo packaging version is
(4) how we've patched it, or not

personally i've never found the "(GDB)" to be useful information.  seems like
we could do away with it entirely ?  i'll admit i haven't looked at the history
of it at all though.

if we want to avoid changing existing behavior/format in the --version strings,
maybe we should have a new configure option that inserts a new line so it's
very clear what's going on ?

$ gdb --version
GNU gdb (GDB) 12.1
Vendor: Gentoo 12.1 p3
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

> --- /dev/null
> +++ b/gdbsupport/pkgversion-suffix.m4
> +
> +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]),

i really dislike how this is made into a gdb-only thing.  the existing options
--with-pkgversion= & --with-bugurl= are pretty standard across the GNU toolchain
project space and are extremely helpful to keep consistent.  can we please look
for a solution that maintains that consistency ?
-mike
  
Andrew Burgess Nov. 17, 2022, 3:49 p.m. UTC | #3
Mike Frysinger <vapier@gentoo.org> writes:

> On 11 Nov 2022 11:24, Andrew Burgess via Gdb-patches wrote:
>> Once GDB 13.1 is released, then the version string, for a build of GDB
>> made from the release branch should look like this:
>> 
>>   $ gdb --version
>>   GNU gdb (GDB) 13.1
>> 
>> We provide a configure option, --with-pkgversion, which allows control
>> over the 'GDB' string within '(GDB) ', and so, if we configure like
>> this:
>> 
>>   $ ../src/configure --with-pkgversion="My Distro"
>> 
>> then the final GDB's version string would look like this:
>> 
>>   $ gdb --version
>>   GNU gdb (My Distro) 13.1
>> 
>> It is not unreasonable to think that somebody building a distribution
>> specific version of GDB like this might want to also augment the
>> version number (13.1) in order to indicate a local patch level.
>> 
>> Now, the existing configure option, --with-pkgversion, clearly seems
>> to indicate that the package specific version number should be
>> included here, however, I don't find this result satisfactory.
>> 
>> Here are some possibilities.  I could include the full version number,
>> including my local patch number, like this:
>> 
>>   GNU gdb (My Distro 13.1.5) 13.1
>> 
>> I don't like this because of the duplication.  I could drop the
>> upstream version number, like this:
>> 
>>   GNU gdb (My Distro 5) 13.1
>> 
>> But I don't like this because it (IMHO) can lead to confusion, is this
>> GDB version 5?  Version 13.1?  I think this can potentially cause
>> confusion for a user.
>> 
>> I propose that a far better solution is to add a new configure option
>> that will allow me to attach additional content at the end of the
>> version string, like this:
>> 
>>   GNU gdb (My Distro) 13.1.5
>
> i strongly dislike this proposal because it's smooshing distro versions and
> official versions with no clear separation at all.  this is bad for us, bad
> for our users, and imo bad for even the distros/vendors.
>
> if --with-pkgversion= isn't specified, the users will see the bare version only.

I guess you mean the new --with-pkgversion-suffix here?

> (yes, i'm aware people can patch the source to display whatever they want, but
> that doesn't mean we have to encourage or make it easy to do)
>
> even if it is specified, users will say things like "i'm using GDB 13.1.5",
> and then we'll have to figure out whose "13.1.5" that is.

I disagree with your use of "have" here.  I think it's a subtle but
important distinction.  So long as vendor version numbers are different
from upstream version numbers, "we" (the upstream GDB community) can
just refer users to their vendors (For issues that are not reproducible
in upstream GDB - we are after all a pretty helpful community I think).

>                                                              users will also do
> things like search for "GDB version 13.1.5" and then get confused when no such
> release exists.

I think my choice of ".5" here as an example was not a good choice.  The
configure option takes any string and just appends it at the end of the
version number.  So we could use "-p5", or " patch 5".  You talk about
this more below and list strings like that as being a better choice than
something like ".5".

If a vendor chooses to use a particular version number, and that ends up
confusing users, then that is unfortunate, but surely that's a vendor
issue?

>
> it also means once we release a GDB version X, we can never release a point
> version after that (e.g. X.Y).  which is what these docs, albeit perhaps
> outdated, explain:

I'm not sure who you mean by "we" in this sentence.  I really don't see
the existence of some additional customisation as being a blocker for
upstream GDB making whatever releases it wants, so I reject your
assertion that having this feature would mean "...we can never release a
point version after that...".

> https://sourceware.org/gdb/wiki/Internals%20Versions
> i'm aware that currently we've moved to X.Y and don't seem to ever plan on
> doing plain X or X.Y.Z, but that doesn't mean we should cede the entire
> future to random vendors.

I think this is the idea that confuses me the most: by what mechanism do
you think vendors would block us making a point release?

These vendors are downstream of us, we make a release and they pick that
up.  Those vendors are free to come to this list and express an opinion,
just like anyone else, but at the end of the day, we'll continue to make
decisions as a group, in the best interest of GDB, just like we always
have.

>
> backing up a bit, the example you provided is:
>> GNU gdb (My Distro 13.1.5) 13.1
> first off, i don't see a problem with the duplication, but that's me.
> second, it sounds like your distro is claiming version numbers it shouldn't ?
> why are you calling it version "13.1.5" instead of "13.1 patch 5" or "13.1-5"

As I said above, maybe using ".5" as an example was a poor choice.  I
could just as easily configure --with-pkgversion-suffix=" patch 5" to
get:

  GNU gdb (GDB) 13.1 patch 5

that's why the new option takes a string, not a version number.  And
notice, in the example I give, the '.' is included in the configure
option, it's not being added within GDB.  I'm free at configure time to
customise the output how I see fit.

> or something like that ?  this sounds like a bug in the distro/vendor that
> you're working on.

I'd disagree with "bug" here, surely it's just a choice that you
personally disagree with?  I'd like to discuss the benefits and/or
drawbacks of the proposal on its technical merits, rather than just
dismissing it as a bug.

>
> in Gentoo we use:
>> GNU gdb (Gentoo 12.1 p3) 12.1
>> GNU gdb (Gentoo 12.1 vanilla) 12.1
> to make it very clear to everyone involved:
> (1) it's a Gentoo build
> (2) what our upstream base version is
> (3) what the Gentoo packaging version is
> (4) how we've patched it, or not

That's great.  And can continue unchanged if that's your preference.
This proposal is about choice, not about trying to force all distros to
do things one particular way.

Some distros might want the version number to match the version number
from the package that was used to install GDB.  I don't think either
approach is wrong, it's just, right now, one approach is supported in
upstream GDB, and one approach is not.

>
> personally i've never found the "(GDB)" to be useful information.  seems like
> we could do away with it entirely ?  i'll admit i haven't looked at the history
> of it at all though.

I agree it seems a little weird.  But I certainly don't want to get off
track looking at that right now.  My interest is the other end of the
version string.

>
> if we want to avoid changing existing behavior/format in the --version strings,
> maybe we should have a new configure option that inserts a new line so it's
> very clear what's going on ?

I was hoping to propose a plan that would allow distros to continue to
operate as they currently do, while at the same time offering more
flexibility.

When I started thinking about this work, I did initially wonder about a
totally generic "version format" type idea, e.g. configure with:

  --with-version-format="GNU gdb {pkgversion} {version_number} patch 5" \
  --with-pkgversion="My Distro"

which would give:

  GNU gdb (My Distro) 13.1 patch 5

But could also allow:

  --with-version-format="GNU gdb (GDB) {version_number}\nVendor: My Distro 13.1 patch 5" \
  --with-pkgversion="My Distro"

Which would give:

  GNU gdb (GDB) 13.1
  Vendor: My Distro 13.1 patch 5

But I rejected this idea because (a) totally over the top for what I
actually wanted (append to the version string), and (b) would allow
vendors to easily drop the 'GNU gdb' string, which I didn't think was a
good idea, and (c) a vendor might even drop the major version number,
which seemed like a bad plan.

>
> $ gdb --version
> GNU gdb (GDB) 12.1
> Vendor: Gentoo 12.1 p3

Personally, not a fan of information duplication like this.

> Copyright (C) 2022 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
>
>> --- /dev/null
>> +++ b/gdbsupport/pkgversion-suffix.m4
>> +
>> +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]),
>
> i really dislike how this is made into a gdb-only thing.  the existing options
> --with-pkgversion= & --with-bugurl= are pretty standard across the GNU toolchain
> project space and are extremely helpful to keep consistent.  can we please look
> for a solution that maintains that consistency ?

I guess by this you mean adding the macro to config/acx.m4?  I'm not
super keen to rush off to do that right from the start.  I'd much rather
get something that working (and acceptable) for GDB, and then have folk
generalise it if it works.

I deliberately picked the --with-pkgversion-suffix name to be consistent
with the existing --with-pkgversion option, so if at some future time to
macro was moved into acx.m4, the configure interface would remain the
same.

If I rewrote the proposal, but changed my example from ".5" to " patch
5", it feels like a lot of the issues you raised above would disappear.
Would you feel more comfortable with that approach?

I think your second concern, about where the autoconf macro lives can be
put aside until we reach agreement on the core of the issue.

Thanks,
Andrew
  
Sam James Nov. 17, 2022, 4:26 p.m. UTC | #4
> On 16 Nov 2022, at 16:58, Mike Frysinger via Gdb-patches <gdb-patches@sourceware.org> wrote:
> 
> On 11 Nov 2022 11:24, Andrew Burgess via Gdb-patches wrote:
>> Once GDB 13.1 is released, then the version string, for a build of GDB
>> made from the release branch should look like this:
>> 
>>  $ gdb --version
>>  GNU gdb (GDB) 13.1
>> 
>> We provide a configure option, --with-pkgversion, which allows control
>> over the 'GDB' string within '(GDB) ', and so, if we configure like
>> this:
>> 
>>  $ ../src/configure --with-pkgversion="My Distro"
>> 
>> then the final GDB's version string would look like this:
>> 
>>  $ gdb --version
>>  GNU gdb (My Distro) 13.1
>> 
>> It is not unreasonable to think that somebody building a distribution
>> specific version of GDB like this might want to also augment the
>> version number (13.1) in order to indicate a local patch level.
>> 
>> Now, the existing configure option, --with-pkgversion, clearly seems
>> to indicate that the package specific version number should be
>> included here, however, I don't find this result satisfactory.
>> 
>> Here are some possibilities.  I could include the full version number,
>> including my local patch number, like this:
>> 
>>  GNU gdb (My Distro 13.1.5) 13.1
>> 
>> I don't like this because of the duplication.  I could drop the
>> upstream version number, like this:
>> 
>>  GNU gdb (My Distro 5) 13.1
>> 
>> But I don't like this because it (IMHO) can lead to confusion, is this
>> GDB version 5?  Version 13.1?  I think this can potentially cause
>> confusion for a user.
>> 
>> I propose that a far better solution is to add a new configure option
>> that will allow me to attach additional content at the end of the
>> version string, like this:
>> 
>>  GNU gdb (My Distro) 13.1.5
> 
> i strongly dislike this proposal because it's smooshing distro versions and
> official versions with no clear separation at all.  this is bad for us, bad
> for our users, and imo bad for even the distros/vendors.
> 
> if --with-pkgversion= isn't specified, the users will see the bare version only.
> (yes, i'm aware people can patch the source to display whatever they want, but
> that doesn't mean we have to encourage or make it easy to do)
> 
> even if it is specified, users will say things like "i'm using GDB 13.1.5",
> and then we'll have to figure out whose "13.1.5" that is.  users will also do
> things like search for "GDB version 13.1.5" and then get confused when no such
> release exists.
> 
> it also means once we release a GDB version X, we can never release a point
> version after that (e.g. X.Y).  which is what these docs, albeit perhaps
> outdated, explain:
> https://sourceware.org/gdb/wiki/Internals%20Versions
> i'm aware that currently we've moved to X.Y and don't seem to ever plan on
> doing plain X or X.Y.Z, but that doesn't mean we should cede the entire
> future to random vendors.
> 
> backing up a bit, the example you provided is:
>> GNU gdb (My Distro 13.1.5) 13.1
> first off, i don't see a problem with the duplication, but that's me.
> second, it sounds like your distro is claiming version numbers it shouldn't ?
> why are you calling it version "13.1.5" instead of "13.1 patch 5" or "13.1-5"
> or something like that ?  this sounds like a bug in the distro/vendor that
> you're working on.
> 
> in Gentoo we use:
>> GNU gdb (Gentoo 12.1 p3) 12.1
>> GNU gdb (Gentoo 12.1 vanilla) 12.1
> to make it very clear to everyone involved:
> (1) it's a Gentoo build
> (2) what our upstream base version is
> (3) what the Gentoo packaging version is
> (4) how we've patched it, or not
> 
> personally i've never found the "(GDB)" to be useful information.  seems like
> we could do away with it entirely ?  i'll admit i haven't looked at the history
> of it at all though.
> 
> if we want to avoid changing existing behavior/format in the --version strings,
> maybe we should have a new configure option that inserts a new line so it's
> very clear what's going on ?
> 
> $ gdb --version
> GNU gdb (GDB) 12.1
> Vendor: Gentoo 12.1 p3
> Copyright (C) 2022 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> 
>> --- /dev/null
>> +++ b/gdbsupport/pkgversion-suffix.m4
>> +
>> +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]),
> 
> i really dislike how this is made into a gdb-only thing.  the existing options
> --with-pkgversion= & --with-bugurl= are pretty standard across the GNU toolchain
> project space and are extremely helpful to keep consistent.  can we please look
> for a solution that maintains that consistency ?

I feel the same. The approach we use in Gentoo seems to work well enough
And diverting from the standard autotools way of doing this feels unfortunate.

It's really nice to be able to bang these options in to GNU projects and
have it just work.

I agree the suggested output change might be a bit neater though.

When I first saw the patch, I assumed that someone had just missed
the existing options existed.

Best,
sam
  

Patch

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])
+])