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]

Re: [PATCH]: include GMP/MPFR version info in "gcc -v" output


On 2/18/07, Kaveh R. GHAZI <ghazi@caip.rutgers.edu> wrote:
On Sat, 17 Feb 2007, Richard Guenther wrote:

> > Thanks, I'll change it.  BTW the output looks like this:
> >
> >         GNU C version 4.3.0 20070216 (experimental) (sparc-sun-solaris2.10)
> >                 compiled by GNU C version 3.4.6.
> >         GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
> >         GMP: header version <4.2.1>, library version <4.2.1>
> >         MPFR: header version <2.2.1>, library version <2.2.1>
>
> The <> look inconsistent with the GCC version numbers.  I'd put the
> information next to the compiler used for building gcc, like
>
>    compiled by GNU C version 3.4.6, GMP version 4.2.1, MPFR version 2.2.1.
>
> and print the header/library version only on a mismatch as a warning.
> Richard.


I'm not sure I agree about combining the two. With the combined form, it's not clear to the user that gcc is checking internally that the two versions are identical. They may be left wondering whether gcc is showing the header or lib version or has the smarts to check both.

Also, the string mismatch detection turns out to be a little bit ugly.
Although MPFR provides a clean stringified copy of it's version macros,
GMP does not.  Furthermore, GMP has two formats, it uses x.y.z or x.y when
z==0.  This switching formats makes me nervous about relying on it in a
comparsion.  I'd rather leave it up to the user to eyeball the difference.

Because of these concerns, my preference would be to stick with the
previous patch showing header and lib versions separately (and I'll take
out the <>) but if you insist, here's one with the string mismatch check.
The new output looks like this:

        GNU C version 4.3.0 20070216 (experimental) (sparc-sun-solaris2.10)
                compiled by GNU C version 3.4.6, GMP version 4.2.1, MPFR version 2.2.1.
        GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
        Compiler executable checksum: b755fbced9d1486c44eeb04212724fda

So would you agree to version 2 without <>, or version 3 below?

So with the recent discussions I think the version below is ok for the mainline if it still works as designed.

Thanks,
Richard.

--Kaveh


2007-02-17 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>


* toplev.c (print_version): Output GMP/MPFR version info.

diff -rup orig/egcc-SVN20070216/gcc/toplev.c egcc-SVN20070216/gcc/toplev.c
--- orig/egcc-SVN20070216/gcc/toplev.c  2007-02-10 20:03:41.000000000 -0500
+++ egcc-SVN20070216/gcc/toplev.c       2007-02-17 17:24:13.309054173 -0500
@@ -1150,12 +1150,16 @@ print_version (FILE *file, const char *i
 {
   static const char fmt1[] =
 #ifdef __GNUC__
-    N_("%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n")
+    N_("%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s, ")
 #else
-    N_("%s%s%s version %s (%s) compiled by CC.\n")
+    N_("%s%s%s version %s (%s) compiled by CC, ")
 #endif
     ;
   static const char fmt2[] =
+    N_("GMP version %s, MPFR version %s.\n");
+  static const char fmt3[] =
+    N_("warning: %s header version %s differs from library version %s.\n");
+  static const char fmt4[] =
     N_("%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n");
 #ifndef __VERSION__
 #define __VERSION__ "[?]"
@@ -1165,8 +1169,32 @@ print_version (FILE *file, const char *i
           indent, *indent != 0 ? " " : "",
           lang_hooks.name, version_string, TARGET_NAME,
           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.  */
+#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_STRINGIFY_VERSION GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION) "." \
+  GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_MINOR)
+#else
+#define GCC_GMP_STRINGIFY_VERSION GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION) "." \
+  GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_MINOR) "." \
+  GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_PATCHLEVEL)
+#endif
   fprintf (file,
           file == stderr ? _(fmt2) : fmt2,
+          GCC_GMP_STRINGIFY_VERSION, MPFR_VERSION_STRING);
+  if (strcmp (GCC_GMP_STRINGIFY_VERSION, gmp_version))
+    fprintf (file,
+            file == stderr ? _(fmt3) : fmt3,
+            "GMP", GCC_GMP_STRINGIFY_VERSION, gmp_version);
+  if (strcmp (MPFR_VERSION_STRING, mpfr_get_version ()))
+    fprintf (file,
+            file == stderr ? _(fmt3) : fmt3,
+            "MPFR", MPFR_VERSION_STRING, mpfr_get_version ());
+  fprintf (file,
+          file == stderr ? _(fmt4) : fmt4,
           indent, *indent != 0 ? " " : "",
           PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
 }



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