On Fri, 27 Jan 2017, Jakub Jelinek wrote: > On Fri, Jan 27, 2017 at 08:41:59AM +0100, Rainer Orth wrote: > > > On 01/24/2017 02:37 AM, Markus Trippelsdorf wrote: > > >> MPFR_RNDx was introduced in MPFR 3.0.0. Since the minimal version that > > >> gcc checks for is 2.4.0, this leads to a build failure. > > >> > > >> The fix is straightforward. > > >> > > >> Tested on x86_64-pc-linux-gnu. Committed to trunk as obvious. > > >> > > >> * gimple-ssa-sprintf.c (format_floating): Change MPFR_RNDx to > > >> GMP_RNDx for compatibility. > > > > > > This was changed once before for this reason (in r240350). I forgot > > > all about it and put it back in my latest patch for some reason. I > > > don't remember why exactly but I suspect I might have been trying to > > > overcome some MPFR oddity. It might help to #undef the MPFR_RNDx > > > macros after including <mpfr.h> to avoid this in the future. In any > > > event, thanks for the fix. > > > > we certainly should do something like this: your latest patch introduced > > the same failure again: > > > > /vol/gcc/src/hg/trunk/local/gcc/gimple-ssa-sprintf.c: In function 'long > > long unsigned int {anonymous}::format_floating_max(tree, char, long long > > int)': > > /vol/gcc/src/hg/trunk/local/gcc/gimple-ssa-sprintf.c:1501:27: error: > > 'MPFR_RNDN' was not declared in this scope > > mpfr_from_real (x, &rv, MPFR_RNDN); > > ^ > > Makefile:1098: recipe for target 'gimple-ssa-sprintf.o' failed > > make[3]: *** [gimple-ssa-sprintf.o] Error 1 > > So what about poisoning MPFR_RND{N,D,Z,U} then?
Works for me. Richard. > With mpfr 3.1.5 it seems to work, both when using system gcc (6.3.1) > and when building in stage3. I don't have mpfr 2.4.* around and apparently > it is incompatible with gmp 6.1.x, so I'd have to build both gmp and mpfr > (and likely mpc too). Can you just quickly try this if it works for you? > > Newer mpfr.h has: > typedef enum { > MPFR_RNDN=0, /* round to nearest, with ties to even */ > MPFR_RNDZ, /* round toward zero */ > MPFR_RNDU, /* round toward +Inf */ > MPFR_RNDD, /* round toward -Inf */ > MPFR_RNDA, /* round away from zero */ > MPFR_RNDF, /* faithful rounding (not implemented yet) */ > MPFR_RNDNA=-1 /* round to nearest, with ties away from zero (mpfr_round) */ > } mpfr_rnd_t; > > /* kept for compatibility with MPFR 2.4.x and before */ > #define GMP_RNDN MPFR_RNDN > #define GMP_RNDZ MPFR_RNDZ > #define GMP_RNDU MPFR_RNDU > #define GMP_RNDD MPFR_RNDD > > so the question is if it will work with compilers that pretend to be GCC > (clang++, icc). I've just tried it with both, clang++ 3.8.0 compiles it > fine (with noisy warnings about various non-issues), icpc 16.0.2 does error > out on a couple of unrelated things, but doesn't mention the *RND* stuff. > icpc claims to be GCC 6.3.1 (maybe it always pretends to be the same version > as system gcc?) and errors e.g. on: > ../../gcc/hash-table.h(956): error: declaration is incompatible with function > template "void hash_table<Descriptor, > Allocator>::traverse_noresize<Argument,Callback>(Argument)" (declared at line > 444) > hash_table<Descriptor, Allocator>::traverse_noresize (Argument argument) > ../../gcc/gimple.h(62): error: identifier "__builtin_FILE" is undefined > ../../gcc/gimple.h(63): error: identifier "__builtin_LINE" is undefined > ../../gcc/gimple.h(64): error: identifier "__builtin_FUNCTION" is undefined > > 2017-01-27 Jakub Jelinek <ja...@redhat.com> > > * realmpfr.h: Poison MPFR_RND{N,Z,U,D}. > * gimple-ssa-sprintf.c (format_floating_max): Use GMP_RNDN > instead of MPFR_RNDN. > > --- gcc/realmpfr.h.jj 2017-01-01 12:45:39.000000000 +0100 > +++ gcc/realmpfr.h 2017-01-27 09:04:56.082042138 +0100 > @@ -32,5 +32,10 @@ extern void real_from_mpfr (REAL_VALUE_T > const real_format *, mp_rnd_t); > extern void mpfr_from_real (mpfr_ptr, const REAL_VALUE_TYPE *, mp_rnd_t); > > -#endif /* ! GCC_REALGMP_H */ > +#if (GCC_VERSION >= 3000) > + /* For compatibility with mpfr 2.4 and earlier, we want to only use > + GMP_RND*. */ > + #pragma GCC poison MPFR_RNDN MPFR_RNDZ MPFR_RNDU MPFR_RNDD > +#endif > > +#endif /* ! GCC_REALGMP_H */ > --- gcc/gimple-ssa-sprintf.c.jj 2017-01-27 08:49:03.000000000 +0100 > +++ gcc/gimple-ssa-sprintf.c 2017-01-27 08:53:52.911721864 +0100 > @@ -1498,7 +1498,7 @@ format_floating_max (tree type, char spe > round-to-nearest mode. */ > mpfr_t x; > mpfr_init2 (x, rfmt->p); > - mpfr_from_real (x, &rv, MPFR_RNDN); > + mpfr_from_real (x, &rv, GMP_RNDN); > > /* Return a value one greater to account for the leading minus sign. */ > return 1 + get_mpfr_format_length (x, "", prec, spec, 'D'); > > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)