[PATCH]: fix the --with-mpfr-dir=PATH configure flag

Kaveh R. GHAZI ghazi@caip.rutgers.edu
Fri Nov 17 23:23:00 GMT 2006

The --with-mpfr-dir=PATH configure flag present in the top level configure
exists to allow one to point gcc at a build directory of mpfr and use it
without installing mpfr.  There exists an analogous --with-gmp-dir=PATH as

As noted here:

--with-mpfr-dir=PATH looks for PATH/libmpfr.a.  This doesn't work for
mpfr-2.2.0 because it uses libtool and places its library in the .libs (or
on DOS the _libs) subdirectory.

Prior versions of mpfr were included in gmp.  I did some archaeology and
found that up until and including gmp-4.1.3, mpfr didn't use libtool, so
this flag worked if you passed in for example:
--with-mpfr-dir=/path/to/gmp-4.1.3/mpfr.  Some time after this, maybe when
mpfr became its own package, is when mpfr started using libtool to create
shared libs as well as static and put things in the subdir.

The effect is that --with-mpfr-dir=PATH is broken on all GCC 4.x series if
you use that flag to build gcc with mpfr-2.2.0. This is a regression,
albeit not because of something changed in GCC, but because of changes to
GMP/MPFR.  Finding mpfr in an installation directory via --with-mpfr=PATH
obviously works okay, or we'd all be hosed and would have noticed. :-)

So we need to search .libs, _libs and "." for libmpfr.a.  The patch below
does this.  The analogous --with-gmp-dir=PATH already checks these places
because I suspect gmp started using libtool earlier.

Tested via configuring with --enable-languages=c,f95 using the flag
--with-mpfr-dir= and pointing it at a build dir of mpfr-2.2.0 as well as
the version of mpfr included with gmp-4.1.3.  I tried this with gcc 4.0.x,
4.1.x, 4.2.x and mainline.  In all cases, it was broken with mpfr-2.2.0
without my patch.  With the patch, mpfr-2.2.0 in its build directory is
usable.  The older mpfr build directory works in all cases both before and
after my patch.

Okay for all active branches?


2006-11-17  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* configure.in (--with-mpfr-dir): Also look in .libs and _libs for
	* configure: Regenerate.

diff -rup orig/egcc-SVN20061116/configure.in egcc-SVN20061116/configure.in
--- orig/egcc-SVN20061116/configure.in	2006-11-13 20:01:53.000000000 -0500
+++ egcc-SVN20061116/configure.in	2006-11-17 17:01:25.140438242 -0500
@@ -1058,7 +1058,13 @@ AC_ARG_WITH(mpfr-dir, [  --with-mpfr-dir

 if test "x$with_mpfr_dir" != x; then
-  gmplibs="$with_mpfr_dir/libmpfr.a"
+  if test -f "$with_mpfr_dir/.libs/libmpfr.a"; then
+    gmplibs="$with_mpfr_dir/.libs/libmpfr.a"
+  elif test -f "$with_mpfr_dir/_libs/libmpfr.a"; then
+    gmplibs="$with_mpfr_dir/_libs/libmpfr.a"
+  else
+    gmplibs="$with_mpfr_dir/libmpfr.a"
+  fi

More information about the Gcc-patches mailing list