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

Bernd Edlinger
2020-12-15T15:10:38Z

On 12/14/20 7:47 PM, Simon Marchi wrote:
> 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@';};
>

Yes, the names for those macros are a bit funny :-)

I just used existing macros to make the delta smaller in the top level config.
extra_mpfr_configure_flags, are in fact the --with-gmp-include/lib parameters,
that are passed to in-tree mpfr, and

extra_mpc_mpfr_configure_flags, are the --with-mpfr-include/lib parameters,
that are passed to in-tree mpc.

I would like to rename those after merging this change and probably other
changes to the gcc repository, and finally merge the gcc changes
again to the binutils-gdb repository.

The binutils toplevel configure files are 2 years behind gcc.
But I think it is straight forward to make gdb/binutils/gcc build from
the same source tree. I just tried this the other day, and just
had a problem with --disable-source-highlight, but

> 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.
>

Yes. It is intended as a convenience, when you do not like to install
the libraries on your system, or when you build for a cross-target,
You should do that manually before configure when you would otherwise
run into a build error. I will clarify that README text.

Bernd.

> 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
>