[PATCH]: middle-end, properly detect GMP 4.3.0 header/lib mismatches

Kaveh R. GHAZI ghazi@caip.rutgers.edu
Tue Apr 28 19:59:00 GMT 2009


We have a mechanism to detect if one has bootstrapped GCC with different
versions of the GMP header vs the GMP library.  This is to detect if e.g.
someone installed the headers from a package without the corresponding
libraries.  (It can happen, e.g. in some cases header and lib are located
in separate packages and the user may have an older one installed
somewhere.)  In the output of "gcc -v" we output a warning if the versions
don't match.

GMP had a quirky versioning system where it would omit the "micro" version
for a ".0" release.  So we had gmp-4.1, gmp-4.1.1, ..., gmp-4.2,
gmp-4.2.1, ..., etc.  This had to be factored in when checking the GMP
version and GCC had code to work around this. (Note MPFR is not affected
by this.)

However with the recent release of gmp-4.3.0, the GMP version number
system has standardized on the 3-number format for all releases including
".0" ones.  The intent according to the GMP website is to use this format
going forward.  See under "Misc:" http://gmplib.org/gmp4.3.html

This change causes a minor nit for us in that the warning yields a false
positive for gmp-4.3.0.  See the last line of this output:

 > GNU C (GCC) version 4.5.0 20090427 (experimental) [trunk revision 146864] (x86_64-unknown-linux-gnu)
 >         compiled by GNU C version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21), GMP version 4.3, MPFR version 2.3.1.
 > warning: GMP header version 4.3 differs from library version 4.3.0.

So this patch modifies GCC's GMP version checking code to handle this case
for gmp-4.3.0 and later versions.

Tested by bootstrapping the patch on all three branches.  I also tested a
c-only disable-bootstrap make with gmp-4.2, gmp-4.2.2 and gmp-4.3.0 to
make sure the warning is gone in all cases where the header matches the
library.  Finally I also tested with a mismatched gmp header and library
to ensure the warning still occurs in the appropriate cases.

Okay everywhere?

		Thanks,
		--Kaveh


2009-04-26  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* toplev.c (print_version): Update GMP version string calculation.

diff -rup orig/egcc-4.3-SVN20090426/gcc/toplev.c egcc-4.3-SVN20090426/gcc/toplev.c
--- orig/egcc-4.3-SVN20090426/gcc/toplev.c	2008-04-25 02:06:43.000000000 +0200
+++ egcc-4.3-SVN20090426/gcc/toplev.c	2009-04-26 23:06:20.000000000 +0200
@@ -1198,10 +1198,14 @@ print_version (FILE *file, const char *i
 	   indent, __VERSION__);

   /* We need to stringify the GMP macro values.  Ugh, gmp_version has
-     two string formats, "i.j.k" and "i.j" when k is zero.  */
+     two string formats, "i.j.k" and "i.j" when k is zero.  As of
+     gmp-4.3.0, GMP always uses the 3 number format.  */
 #define GCC_GMP_STRINGIFY_VERSION3(X) #X
 #define GCC_GMP_STRINGIFY_VERSION2(X) GCC_GMP_STRINGIFY_VERSION3(X)
-#if __GNU_MP_VERSION_PATCHLEVEL == 0
+#define GCC_GMP_VERSION_NUM(X,Y,Z) (((X) << 16L) | ((Y) << 8) | (Z))
+#define GCC_GMP_VERSION \
+  GCC_GMP_VERSION_NUM(__GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL)
+#if GCC_GMP_VERSION < GCC_GMP_VERSION_NUM(4,3,0) && __GNU_MP_VERSION_PATCHLEVEL == 0
 #define GCC_GMP_STRINGIFY_VERSION GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION) "." \
   GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_MINOR)
 #else



More information about the Gcc-patches mailing list