This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 4.5 2/N]: Integrate GCC with the complex math library MPC (configury)


This patch adds the configury bits for the MPC integration.  As previously
mentioned, I'm making MPC is optional at this point.  So the configure
parts check for the appropriate verison of MPC and arrange to elide the
relevant code if MPC is not available.  At this point, the "appropriate
version" is the svn repo if you want to try it out.

I also added the necessary bits for in-tree building of MPC if it appears
as a directory named "mpc".

One bit of surgery was required in the GMP/MPFR checking code.  Since
those libraries were mandatory the checks were written in a way that
required everything at once.  I had to change it slightly to be more
forgiving if MPC wasn't available.  So I rewrote it to first check for all
the headers, then all the libraries, and back out gracefully if the MPC
bits weren't there.  It made this patch larger than it would otherwise
have been.

Bootstrapped in conjunction with the other MPC patches on
x86_64-unknown-linux-gnu with and without MPC, no regressions.  I tested
in-tree building, it worked as well.  I also did some checks against
various versions of mpfr to ensure the configure stuff still correctly
rejects older libraries, etc.

Okay for mainline?

		Thanks,
		--Kaveh


2009-03-12  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* Makefile.def: Add mpc support and dependencies.
	* Makefile.tpl: Likewise.
	* configure.ac: Likewise.  Reorganize GMP/MPFR checks.

	* Makefile.in, configure: Regenerate.

gcc:
	* Makefile.in: Add MPC support.
	* configure.ac: Likeise.

	* config.in, configure: Regenerate.

diff -rup orig/egcc-SVN20090312/Makefile.def egcc-SVN20090312/Makefile.def
--- orig/egcc-SVN20090312/Makefile.def	2009-01-17 02:02:31.000000000 +0100
+++ egcc-SVN20090312/Makefile.def	2009-03-14 08:15:58.000000000 +0100
@@ -69,6 +69,9 @@ host_modules= { module= mpfr; lib_path=.
 		no_install= true;
 	        host="none-${host_vendor}-${host_os}";
 		target="none-${host_vendor}-${host_os}"; };
+host_modules= { module= mpc; lib_path=.libs; bootstrap=true;
+		extra_configure_flags='--disable-shared --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-mpfr-include=$$s/mpfr';
+		no_install= true; };
 host_modules= { module= ppl; lib_path=.libs; bootstrap=true;
 		extra_configure_flags='--disable-shared --with-libgmp-prefix=$$r/$(HOST_SUBDIR)/gmp/ --with-libgmpxx-prefix=$$r/$(HOST_SUBDIR)/gmp/';
 		no_install= true;
@@ -306,6 +309,7 @@ dependencies = { module=all-gcc; on=all-
 dependencies = { module=all-gcc; on=all-gmp; };
 dependencies = { module=all-gcc; on=all-intl; };
 dependencies = { module=all-gcc; on=all-mpfr; };
+dependencies = { module=all-gcc; on=all-mpc; };
 dependencies = { module=all-gcc; on=all-ppl; };
 dependencies = { module=all-gcc; on=all-cloog; };
 dependencies = { module=all-gcc; on=all-build-texinfo; };
@@ -331,6 +335,7 @@ dependencies = { module=all-fixincludes;
 dependencies = { module=all-gnattools; on=all-target-libada; };

 dependencies = { module=configure-mpfr; on=all-gmp; };
+dependencies = { module=configure-mpc; on=all-mpfr; };
 dependencies = { module=configure-ppl; on=all-gmp; };
 dependencies = { module=configure-ppl; on=all-mpfr; };
 dependencies = { module=configure-cloog; on=all-ppl; };
diff -rup orig/egcc-SVN20090312/Makefile.tpl egcc-SVN20090312/Makefile.tpl
--- orig/egcc-SVN20090312/Makefile.tpl	2009-02-06 02:02:53.000000000 +0100
+++ egcc-SVN20090312/Makefile.tpl	2009-03-14 08:15:58.000000000 +0100
@@ -199,6 +199,8 @@ HOST_EXPORTS = \
 	TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \
 	GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \
 	GMPINC="$(HOST_GMPINC)"; export GMPINC; \
+	MPCLIBS="$(HOST_MPCLIBS)"; export MPCLIBS; \
+	MPCINC="$(HOST_MPCINC)"; export MPCINC; \
 	PPLLIBS="$(HOST_PPLLIBS)"; export PPLLIBS; \
 	PPLINC="$(HOST_PPLINC)"; export PPLINC; \
 	CLOOGLIBS="$(HOST_CLOOGLIBS)"; export CLOOGLIBS; \
@@ -262,6 +264,10 @@ NORMAL_TARGET_EXPORTS = \
 HOST_GMPLIBS = @gmplibs@
 HOST_GMPINC = @gmpinc@

+# Where to find MPC
+HOST_MPCLIBS = @mpclibs@
+HOST_MPCINC = @mpcinc@
+
 # Where to find PPL
 HOST_PPLLIBS = @ppllibs@
 HOST_PPLINC = @pplinc@
diff -rup orig/egcc-SVN20090312/configure.ac egcc-SVN20090312/configure.ac
--- orig/egcc-SVN20090312/configure.ac	2009-01-30 02:03:00.000000000 +0100
+++ egcc-SVN20090312/configure.ac	2009-03-14 09:16:34.000000000 +0100
@@ -158,7 +158,7 @@ build_tools="build-texinfo build-byacc b

 # these libraries are used by various programs built for the host environment
 #
-host_libs="intl mmalloc libiberty opcodes bfd readline tcl tk itcl libgui zlib libcpp libdecnumber gmp mpfr ppl cloog"
+host_libs="intl mmalloc libiberty opcodes bfd readline tcl tk itcl libgui zlib libcpp libdecnumber gmp mpfr mpc ppl cloog"

 # these tools are built for the host environment
 # Note, the powerpc-eabi build depends on sim occurring before gdb in order to
@@ -1187,10 +1187,42 @@ fi
 ACX_PROG_GNAT
 ACX_PROG_CMP_IGNORE_INITIAL

-# Check for GMP and MPFR
+# Check for GMP, MPFR and MPC
 gmplibs="-lmpfr -lgmp"
 gmpinc=
 have_gmp=no
+mpclibs=
+mpcinc=
+have_mpc=no
+
+# Specify a location for mpc
+# check for this first so it ends up on the link line before mpfr.
+AC_ARG_WITH(mpc, [  --with-mpc=PATH        specify prefix directory for installed MPC package.
+                          Equivalent to --with-mpc-include=PATH/include
+                          plus --with-mpc-lib=PATH/lib])
+AC_ARG_WITH(mpc_include, [  --with-mpc-include=PATH
+                          specify directory for installed MPC include files])
+AC_ARG_WITH(mpc_lib, [  --with-mpc-lib=PATH    specify directory for the installed MPC library])
+
+if test "x$with_mpc" != x; then
+  mpclibs="-L$with_mpc/lib -lmpc"
+  mpcinc="-I$with_mpc/include $mpcinc"
+fi
+if test "x$with_mpc_include" != x; then
+  mpcinc="-I$with_mpc_include $mpcinc"
+fi
+if test "x$with_mpc_lib" != x; then
+  mpclibs="-L$with_mpc_lib -lmpc"
+fi
+if test "x$with_mpc$with_mpc_include$with_mpc_lib" = x && test -d ${srcdir}/mpc; then
+  mpclibs='-L$$r/$(HOST_SUBDIR)/mpc/src/.libs -L$$r/$(HOST_SUBDIR)/mpc/src/_libs -lmpc'
+  mpcinc='-I$$s/mpc/src '"$mpcinc"
+  # Do not test the mpc version.  Assume that it is sufficient, since
+  # it is in the source tree, and the library has not been built yet
+  # but it would be included on the link line in the version check below
+  # hence making the test fail.
+  have_mpc=yes
+fi

 # Specify a location for mpfr
 # check for this first so it ends up on the link line before gmp.
@@ -1269,16 +1301,43 @@ if test -d ${srcdir}/gcc && test "x$have
   #endif
   ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])

+  # If we have GMP, check the MPFR version.
   if test x"$have_gmp" = xyes; then
-    saved_LIBS="$LIBS"
-    LIBS="$LIBS $gmplibs"
     dnl MPFR 2.3.0 is acceptable, but MPFR 2.3.2 is better.
     AC_MSG_CHECKING([for correct version of mpfr.h])
-    AC_TRY_LINK([#include <gmp.h>
+    AC_TRY_COMPILE([#include <gmp.h>
     #include <mpfr.h>],[
     #if MPFR_VERSION < MPFR_VERSION_NUM(2,3,0)
     choke me
     #endif
+    ], AC_TRY_COMPILE([#include <gmp.h>
+    #include <mpfr.h>],[
+    #if MPFR_VERSION < MPFR_VERSION_NUM(2,3,2)
+    choke me
+    #endif
+    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])]),
+     [AC_MSG_RESULT([no]); have_gmp=no])
+  fi
+
+  # Check for the MPC header version.
+  if test x"$have_mpc" != xyes ; then
+    CFLAGS="$CFLAGS $mpcinc"
+    AC_MSG_CHECKING([for the correct version of mpc.h])
+    AC_TRY_COMPILE([#include <mpc.h>],[
+    #if MPC_VERSION < MPC_VERSION_NUM (0,6,0)
+    choke me
+    #endif
+    ], [AC_MSG_RESULT([yes]); have_mpc=maybe],
+       [AC_MSG_RESULT([no]); have_mpc=no; mpclibs= ; mpcinc= ])
+  fi
+
+  # Now check the MPFR library.
+  if test x"$have_gmp" = xyes; then
+    saved_LIBS="$LIBS"
+    LIBS="$LIBS $gmplibs"
+    AC_MSG_CHECKING([for the correct version of the gmp/mpfr libraries])
+    AC_TRY_LINK([#include <gmp.h>
+    #include <mpfr.h>],[
     mpfr_t n;
     mpfr_t x;
     int t;
@@ -1287,16 +1346,36 @@ if test -d ${srcdir}/gcc && test "x$have
     mpfr_atan2 (n, n, x, GMP_RNDN);
     mpfr_erfc (n, x, GMP_RNDN);
     mpfr_subnormalize (x, t, GMP_RNDN);
-    ], [AC_TRY_LINK([#include <gmp.h>
-    #include <mpfr.h>],[
-    #if MPFR_VERSION < MPFR_VERSION_NUM(2,3,2)
-    choke me
-    #endif
-    mpfr_t n; mpfr_init(n);
-    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([buggy but acceptable])])],
-     [AC_MSG_RESULT([no]); have_gmp=no])
-      LIBS="$saved_LIBS"
+    ], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); have_gmp=no])
+    LIBS="$saved_LIBS"
   fi
+
+  if test x"$have_mpc" = xmaybe; then
+    saved_LIBS="$LIBS"
+    LIBS="$LIBS $mpclibs $gmplibs"
+    AC_MSG_CHECKING([for the correct version of the mpc library])
+    AC_TRY_LINK([#include <mpc.h>],[
+    mpc_t n;
+    mpc_init2 (n, 53);
+    mpc_set_ui_ui (n, 1, 1, MPC_RNDNN);
+    mpc_sin (n, n, MPC_RNDNN);
+    mpc_cos (n, n, MPC_RNDNN);
+    mpc_tan (n, n, MPC_RNDNN);
+    mpc_sinh (n, n, MPC_RNDNN);
+    mpc_cosh (n, n, MPC_RNDNN);
+    mpc_tanh (n, n, MPC_RNDNN);
+    mpc_exp (n, n, MPC_RNDNN);
+    mpc_log (n, n, MPC_RNDNN);
+    mpc_sqrt (n, n, MPC_RNDNN);
+    mpc_proj (n, n, MPC_RNDNN);
+    mpc_neg (n, n, MPC_RNDNN);
+    mpc_sqr (n, n, MPC_RNDNN);
+    mpc_clear (n);
+    ], [AC_MSG_RESULT([yes]); have_mpc=yes],
+       [AC_MSG_RESULT([no]); have_mpc=no; mpclibs= ; mpcinc= ])
+    LIBS="$saved_LIBS"
+  fi
+
   CFLAGS="$saved_CFLAGS"

   if test x$have_gmp != xyes; then
@@ -1311,9 +1390,11 @@ They may be located in separate packages
   fi
 fi

-# Flags needed for both GMP and/or MPFR
+# Flags needed for both GMP, MPFR and/or MPC.
 AC_SUBST(gmplibs)
 AC_SUBST(gmpinc)
+AC_SUBST(mpclibs)
+AC_SUBST(mpcinc)


 # Check for PPL
diff -rup orig/egcc-SVN20090312/gcc/Makefile.in egcc-SVN20090312/gcc/Makefile.in
--- orig/egcc-SVN20090312/gcc/Makefile.in	2009-02-21 02:03:05.000000000 +0100
+++ egcc-SVN20090312/gcc/Makefile.in	2009-03-14 08:15:58.000000000 +0100
@@ -279,6 +279,10 @@ ZLIBINC = @zlibinc@
 GMPLIBS = @GMPLIBS@
 GMPINC = @GMPINC@

+# How to find MPC
+MPCLIBS = @MPCLIBS@
+MPCINC = @MPCINC@
+
 # How to find PPL
 PPLLIBS = @PPLLIBS@
 PPLINC = @PPLINC@
@@ -914,7 +918,7 @@ BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
 # How to link with both our special library facilities
 # and the system's installed libraries.
 LIBS = @LIBS@ $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBIBERTY) $(LIBDECNUMBER)
-BACKENDLIBS = $(CLOOGLIBS) $(PPLLIBS) $(GMPLIBS)
+BACKENDLIBS = $(CLOOGLIBS) $(PPLLIBS) $(MPCLIBS) $(GMPLIBS)
 # Any system libraries needed just for GNAT.
 SYSLIBS = @GNAT_LIBEXC@

@@ -942,7 +946,7 @@ BUILD_ERRORS = build/errors.o
 # libintl.h will be found in ../intl if we are using the included libintl.
 INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
 	   -I$(srcdir)/../include @INCINTL@ \
-	   $(CPPINC) $(GMPINC) $(DECNUMINC) \
+	   $(CPPINC) $(MPCINC) $(GMPINC) $(DECNUMINC) \
 	   $(PPLINC) $(CLOOGINC)

 .c.o:
diff -rup orig/egcc-SVN20090312/gcc/configure.ac egcc-SVN20090312/gcc/configure.ac
--- orig/egcc-SVN20090312/gcc/configure.ac	2009-02-16 02:03:08.000000000 +0100
+++ egcc-SVN20090312/gcc/configure.ac	2009-03-14 08:15:58.000000000 +0100
@@ -3959,6 +3959,12 @@ fi
 AC_ARG_VAR(GMPLIBS,[How to link GMP])
 AC_ARG_VAR(GMPINC,[How to find GMP include files])

+AC_ARG_VAR(MPCLIBS,[How to link MPC])
+AC_ARG_VAR(MPCINC,[How to find MPC include files])
+if test "x${MPCLIBS}" != "x" ; then
+   AC_DEFINE(HAVE_mpc, 1, [Define if mpc is in use.])
+fi
+
 AC_ARG_VAR(PPLLIBS,[How to link PPL])
 AC_ARG_VAR(PPLINC,[How to find PPL include files])


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]