This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

[RFC PATCH]: enable building GMP/MPFR in local tree


It turned out to be much easier than I thought to decipher the top level
machinery and get GMP/MPFR building inside the GCC tree. :-)

The patch below is sufficient to build both GMP and MPFR and use them when
linking cc1.  When I add in my previous patch for PR 29335 to evaluate
sin/cos/tan at compile-time, it works.
http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00360.html

Note: you need to unpack gmp-4.2.1 and mpfr-2.2.0 into the top level gcc
directory and strip off the version numbers from the directory names.

Note2: I did not need any special CFLAGS mentioned by Vincent here:
http://gcc.gnu.org/ml/gcc/2006-10/msg00139.html


Some remaining bits include:

1.  Cleaning up the fortran configure hacks that check for GMP/MPFR and
possibly disable building fortran.  We always have these libs so we can
always build fortran.

2.  Building GMP/MPFR takes a non-trivial portion of the bootstrap.  I can
imagine people won't want to do this every time.  So we should allow using
the system GMP/MPFR and/or a copy the user built and installed somewhere
assuming they are the correct version.  I feel we should require the same
version we have in the tree to avoid bugs in older libraries.  I think
this could be a followup patch.  OTOH, requiring a minimum version (for
MPFR at least) may not be sufficient.  E.g. there is a cumulative patch on
the MPFR site which patches bugs found so far.  I imagine we would want to
include this in our local tree, but installed 2.2.0 copies may not have
it.  I haven't studied the MPFR patch to see if we care about any of the
fixes in there or not.

3.  Assuming we're merciless in requiring an up-to-date version of
GMP/MPFR in #2, remove hacks in fortran that work around bugs in older
copies of GMP/MPFR.  We can also do this separately after everything
settles down.  Can fortran folks help with this?

4.  Finish the transcendetals patch.  I.e. update all the math builtins to
take advantage of MPFR.  Remove one-off code to evaluate common arguments.
Remove GCC's sqrt calculating function, etc.  Add testcases.


I'm including this preliminary patch to solicit feedback about some of the
choices I made.  E.g.:

1.  I didn't see any point in shared GMP/MPFR libraries so I passed
--disable-shared to both configures.  E.g. the xgcc binary doesn't use any
GMP/MPFR functions, so no need to have these as part of the share libs it
loads.  Static libs is the way to go.

2.  Are there any other special configure flags we want to pass when
building GMP/MPFR?  I notice that MPFR does something special when it has
access to the GMP implementation headers.  However the implementation
headers are in $(srcdir) while gmp.h is in $(builddir).  So I had to
specify only the latter to find gmp.h when configuring MPFR.  What exactly
is the benefit to MPFR for having access to the GMP implementation
headers.  I.e. is it faster?  Any loss if we don't have them?

3.  For similar reasons, in the GCC dir I use -I flags which point to the
GMP builddir for gmp.h, but I pass -I for the MPFR source dir for mpfr.h.
I assume this is correct?

4.  MPFR wants to check for gmp.h (generated file) and libgmp.a when
configuring, so I had to make a dependency from configure-mpfr on all-gmp.
I assume that's right?

5.  Should we install the GMP/MPFR libs built by GCC?  I lean towards no.

6.  Should we "make check" these two libs?  Should we include the results
in the testsuite reports?  I lean towards yes for both, but we don't have
to solve that right away.  It could also be a follow-up


Any comments on these or any other issues I haven't thought of?

		Thanks,
		--Kaveh

PS: Patch below has been tested on Solaris 10 with my transcendentals
patch for PR 29335 via a c-only --disable-bootstrap and three-stage -j30
c-only bootstrap on Solaris 7 to ensure I got the dependencies right at
the top level.


2006-10-08  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* Makefile.def: Add entries for GMP and MPFR.
	* configure.in (host_libs): Likewise.

	* Makefile.in, configure: Regenerate.

gcc:
	* Makefile.in (GMPINC, GMPLIBS): Update for in-tree builds.
	(LIBDEPS, LIBS): Add $(GMPLIBS).

diff -rup orig/egcc-SVN20061008/Makefile.def egcc-SVN20061008/Makefile.def
--- orig/egcc-SVN20061008/Makefile.def	2006-07-17 20:02:13.000000000 -0400
+++ egcc-SVN20061008/Makefile.def	2006-10-08 13:58:09.118075306 -0400
@@ -64,6 +64,7 @@ host_modules= { module= gcc; bootstrap=t
 		extra_make_flags="$(EXTRA_GCC_FLAGS)"; };
 host_modules= { module= gawk; };
 host_modules= { module= gettext; };
+host_modules= { module= gmp; bootstrap=true; extra_configure_flags='--disable-shared'; };
 host_modules= { module= gnuserv; };
 host_modules= { module= gprof; };
 host_modules= { module= gzip; };
@@ -82,6 +83,7 @@ host_modules= { module= libtool; };
 host_modules= { module= m4; };
 host_modules= { module= make; };
 host_modules= { module= mmalloc; no_check=true; };
+host_modules= { module= mpfr; bootstrap=true; extra_configure_flags='--disable-shared --with-gmp-build=../gmp'; };
 host_modules= { module= patch; };
 host_modules= { module= perl; };
 host_modules= { module= prms; };
@@ -270,7 +272,9 @@ dependencies = { module=configure-gcc; o
 dependencies = { module=configure-gcc; on=all-gas; };
 dependencies = { module=configure-gcc; on=all-ld; };
 dependencies = { module=all-gcc; on=all-libiberty; hard=true; };
+dependencies = { module=all-gcc; on=all-gmp; hard=true; };
 dependencies = { module=all-gcc; on=all-intl; };
+dependencies = { module=all-gcc; on=all-mpfr; hard=true; };
 dependencies = { module=all-gcc; on=all-build-texinfo; };
 dependencies = { module=all-gcc; on=all-build-bison; };
 dependencies = { module=all-gcc; on=all-build-byacc; };
@@ -331,6 +335,9 @@ dependencies = { module=all-binutils; on
 // library.
 dependencies = { module=install-binutils; on=install-opcodes; };

+// mpfr configure depends on gmp being configured and built.
+dependencies = { module=configure-mpfr; on=all-gmp; hard=true; };
+
 // libopcodes depends on libbfd
 dependencies = { module=install-opcodes; on=install-bfd; };

diff -rup orig/egcc-SVN20061008/configure.in egcc-SVN20061008/configure.in
--- orig/egcc-SVN20061008/configure.in	2006-09-27 20:01:59.000000000 -0400
+++ egcc-SVN20061008/configure.in	2006-10-08 13:17:06.714306731 -0400
@@ -123,7 +123,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"
+host_libs="intl mmalloc libiberty opcodes bfd readline tcl tk itcl libgui zlib libcpp libdecnumber gmp mpfr"

 # these tools are built for the host environment
 # Note, the powerpc-eabi build depends on sim occurring before gdb in order to
diff -rup orig/egcc-SVN20061008/gcc/Makefile.in egcc-SVN20061008/gcc/Makefile.in
--- orig/egcc-SVN20061008/gcc/Makefile.in	2006-10-04 20:01:31.000000000 -0400
+++ egcc-SVN20061008/gcc/Makefile.in	2006-10-08 14:21:45.934917761 -0400
@@ -298,8 +298,8 @@ ZLIB = @zlibdir@ -lz
 ZLIBINC = @zlibinc@

 # How to find GMP
-GMPLIBS = @GMPLIBS@
-GMPINC = @GMPINC@
+GMPINC = -I../gmp -I$(srcdir)/../mpfr
+GMPLIBS = ../mpfr/.libs/libmpfr.a ../gmp/.libs/libgmp.a

 CPPLIB = ../libcpp/libcpp.a
 CPPINC = -I$(srcdir)/../libcpp/include
@@ -837,7 +837,7 @@ LIBIBERTY = ../libiberty/libiberty.a
 BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a

 # Dependencies on the intl and portability libraries.
-LIBDEPS= $(CPPLIB) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) $(LIBDECNUMBER)
+LIBDEPS= $(CPPLIB) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) $(LIBDECNUMBER) $(GMPLIBS)

 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
@@ -845,7 +845,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)
+LIBS = @LIBS@ $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBIBERTY) $(LIBDECNUMBER) $(GMPLIBS)

 # Any system libraries needed just for GNAT.
 SYSLIBS = @GNAT_LIBEXC@


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