Re: [pushed/v2 1/9] gdb/configure: Add --with-libgmp-prefix option

Bernd Edlinger
2020-11-16T14:20:36Z

On 11/16/20 4:45 AM, Joel Brobecker wrote:
> Hi Bernd,
>
>> I noticed that this does not allow to build gmp in-tree like it is
>> possible for gcc. I tried to overcome this by the attached patch.
>
> Indeed. It's not something I had considered.
>
>> While doing so, I also noticed an incompatibility with the top level
>> configure stript, which advertises, and passes -with-gmp-include
>> and -with-gmp-lib if in-tree gmp is found.
>>
>> So the --with-libgmp-prefix is not that the top level configure
>> script suggests:
>>
>> $ ./configure --help | grep gmp
>> --with-gmp-dir=PATH this option has been REMOVED
>> --with-gmp=PATH specify prefix directory for the installed GMP
>> --with-gmp-include=PATH/include plus
>> --with-gmp-lib=PATH/lib
>> --with-gmp-include=PATH specify directory for installed GMP include files
>> --with-gmp-lib=PATH specify directory for the installed GMP library
>>
>> What do you think, can we allow these traditional configure options
>> additional to the new --with-libgmp-prefix?
>
> Can you check if these options are actually used elsewhere in
> the binutils-gdb project? The idea I have in the back of my mind
> is to see whether we can use the same options as the ones we've been
> using in GDB or not. The fact that we have an AC_LIB_HAVE_LINKFLAGS
> macro which takes care of handling dependencies for us tells me
> that we are transitioning away from the model above where we add
> the options "by hand" in configure.ac, and instead rely on the new
> macro.
>

I think they are also used as configuration options in mpfr
and mpc, and understood by the top level configuration.

$ mpc-1.0.3/configure --help
[...]
--with-mpfr-include=DIR MPFR include directory
--with-mpfr-lib=DIR MPFR lib directory
--with-mpfr=DIR MPFR install directory
--with-gmp-include=DIR GMP include directory
--with-gmp-lib=DIR GMP lib directory
--with-gmp=DIR GMP install directory
[...]
$
[...]
--with-gmp-include=DIR GMP include directory
--with-gmp-lib=DIR GMP lib directory
--with-gmp=DIR GMP install directory
--with-gmp-build=DIR GMP build directory (please read INSTALL file)
[...]

> One thing I did note is that GDB has some options for MPFR support
> and in particular, it has --with-mpfr:
>
> --with-mpfr include MPFR support (auto/yes/no)
>
> As you can see, the --with-gmp option you propose is not consistent
> with the above.
>

Hmm, yes, indeed, the --with-mpfr seems to be hand-crafted, since there is
currently no --with-gmp=[auto/yes/no], (neither before or after my patch).
I think the --with-mpfr might probably cause problems with mpc in-tree build,
if that ever happens.

Of course the this mpfr support does not work with in-tree mpfr either.
For that to work we would need at minimum --with-mpfr-include=DIR and
--with-mpfr-lib=DIR or equivalent, however mpfr is probably not worth the effort.

> Unfortunately, in digging further, I found that toplevel configure
> *also* has --with-mpfr, with a different meaning:
>
> --with-mpfr=PATH specify prefix directory for installed MPFR package.
> Equivalent to --with-mpfr-include=PATH/include plus
> --with-mpfr-lib=PATH/lib
>
> The way we expect people to configure GDB is to configure it as
> part of the binutils-gdb project, so I don't see how GDB's --with-mpfr
> could work, unless the top-level configury is more elaborate than
> I remembered.
>
> Depending on the above, perhaps it might be better to actually
> to change the top-level configury to advertise the --with-gmp-prefix
> options instead of adding parallel support for the old-style
> options in GDB's configury. And while at it, perhaps start deprecating
> the old-style ones in the top-level configury.
>

Of course there is still mpfr's --with-gmp=DIR configuration option.

But there may also be other surprises like this in configure.ac :

*-*-freebsd*)
if test "x$with_gmp" = x && test "x$with_gmp_dir" = x \
&& ! test -d ${srcdir}/gmp \
&& test -f /usr/local/include/gmp.h; then
with_gmp=/usr/local
fi
;;

as you see, this option was already there for a while.

> One more note: For me, I think we can handle the question of
> in-tree building independently of the question of the configury's
> options -- which is good, because I think the latterm might require
> a bit of discussion.
>
>> Can we the top level Makefile.def change in binutils-gdb or has this
>> be checked-in first in gcc?
>
> That's a good question. I *think* that binutils + GDB now have
> ownership, but I might be wrong. Hopefully others know better.
> If not, I will ask.
>
>> 2020-11-15 Bernd Edlinger <bernd.edlinger@hotmail.de>
>>
>> * Makefile.def: Prepare for GDB build with intree GMP.
>> * Makefile.in: Regenerate.
>>
>> gdb:
>> 2020-11-15 Bernd Edlinger <bernd.edlinger@hotmail.de>
>>
>> * configure.ac: Add --with-gmp= --with-gmp-include= and --with-gmp-lib=
>> for compatibility with top level configure script.
>> * configure: Regenerate.
>
> Looking at your patch, I'm wondering how this would all fit together...
> Would it all work automatically (like it does for libiconv, I believe),
> or where you planning on having to pass --with-gmp options ?
>

No, all it needs, is a symlink named "gmp" pointing to gmp's source tree, in the
top level directory, like gcc's contrib/download_prerequisites does.

Once the gmp directory is there the --with-gmp-include and --with-gmp-lib options
are passed to in-tree mpfr if any, and now additionally to gdb.

The --with-gmp=DIR option itself is not needed at all for the in-tree build.

Bernd.