Re: [PATCH v2] Enable GDB build with in-tree GMP and MPFR

Simon Marchi
2020-12-14T18:47:41Z

I'll give a shot at reviewing this, to make it progress.

Joel, there's a question for you below.

On 2020-12-14 12:40 p.m., Bernd Edlinger wrote:
> Well,
>
> I thought, I should add a few words in the README
> about this feature:
>
> diff --git a/gdb/README b/gdb/README
> index e65c5ea..db0a774 100644
> --- a/gdb/README
> +++ b/gdb/README
> @@ -488,6 +488,9 @@ more obscure GDB `configure' options are not listed here.
> Build GDB using the GMP library installed at the directory DIR.
> If your host does not have GMP installed, you can get the latest
> version at `https://gmplib.org/'.
> + You can also build GMP in-tree when you use the script
> + ./contrib/download_prerequisites. Note however, that this
> + does only work with a separate build directory.
>
> `--with-mpfr'
> Build GDB with GNU MPFR, a library for multiple-precision
> @@ -499,6 +502,9 @@ more obscure GDB `configure' options are not listed here.
> available, GDB will fall back to using host floating-point
> arithmetic. If your host does not have GNU MPFR installed, you
> can get the latest version from `https://www.mpfr.org/'.
> + You can also build MPFR in-tree when you use the script
> + ./contrib/download_prerequisites. Note however, that this
> + does only work with a separate build directory.
>
> `--with-python[=PYTHON]'
> Build GDB with Python scripting support. (Done by default if
>
>
> Tested on x86_64-pc-linux-gnu.
> Is it OK for trunk?
>
>
> Thanks
> Bernd.
>

There is already --with-libgmp-prefix / --without-libgmp-prefix,
provided (I think by):

# Verify that we have a usable GMP library.
AC_LIB_HAVE_LINKFLAGS([gmp], [], [#include <gmp.h>],
[mpz_t n;
mpz_init (n);])

So with this patch, we now have:

--with-gmp-include=DIR GMP include directory
--with-gmp-lib=DIR GMP lib directory
--with-gmp=DIR GMP install directory
--with-libgmp-prefix[=DIR] search for libgmp in DIR/include and DIR/lib
--without-libgmp-prefix don't search for libgmp in includedir and libdir

I think that's getting a bit confusing. That's too many ways to set gmp
paths, with -with-libgmp-prefix and --with-gmp doing the same thing.

If the rest of the binutils/gcc ecosystem already uses --with-gmp,
--with-gmp-include and --with-gmp-lib, I think we should align with
those. Fortunately, we haven't yet shipped a GDB with
--with-libgmp-prefix, so I think it's safe to remove it. It might mean
that we have to stop using AC_LIB_HAVE_LINKFLAGS though, or customize
it. Joel, do you agree?

In this line, in top-level Makefile.def, do you need to also add
something about gmp, and why pass flags about mpc_mpfr (I sincerely
don't know what it is/does)?

host_modules= { module= gdb;
extra_configure_flags='@extra_mpfr_configure_flags@ @extra_mpc_mpfr_configure_flags@';};

In the README, you say:

You can also build GMP in-tree when you use the script
./contrib/download_prerequisites. Note however, that this
does only work with a separate build directory.

That leaves me with some questions:

- do I need to run this script myself before configure?
- if I do, does that mean the build will use the downloaded version,
even if there is a working version on my system?

It would be good to answer those questions in the README text.

An alternative to downloading the pre-requisites would be to check them
in the repo. We do it for readline already: there is a copy in the
repo, which is used by default, but you can specify
--with-system-readline if you want to use the system's readline. We
could do the same with gmp and mpfr. The downside is that we deviate a
bit from how gcc does, the the upside is that it's simpler, IMO.

Note that any change to the files outside GDB will have to be approved
by the binutils folks too. And changes to the top-level Makefile will
have to be replicated to the gcc repo.

Simon