Hi Tobias,

On 5/28/25 22:46, Tobias Burnus wrote:
Hi Harald,

Harald Anlauf wrote:
This breaks bootstrap here on openSUSE Leap 15.6 with mpfr-4.0.2:

../../gcc-trunk/gcc/fortran/simplify.cc: In function 'gfc_expr* gfc_simplify_cospi(gfc_expr*)': ../../gcc-trunk/gcc/fortran/simplify.cc:2305:3: error: 'mpfr_fmod_ui' was not declared in this scope; did you mean 'mpfr_fmodquo'?
 2305 |   mpfr_fmod_ui (cs, n, 2, GFC_RND_MODE);
      |   ^~~~~~~~~~~~

Interestingly, mpfr_fmod_ui has been added only in 4.2.0,
at the same time as mpfr_sinpi.

Solution is to use mpfr_fmod.

I have now committed the attached patch as r16-940-ga64a7f0a6cf8af.

* * *

I build GCC successfully with mpfr 3.1.6 and "make check-fortran"
in $build/gcc was also successful. Except for the following fails:

I get an ICE for gfortran.dg/complex_intrinsic_8.f90 in gfc_simplify_atan:

mpfr/src/init2.c:52: MPFR assertion failed:
    p >= 2 && p <= ((mpfr_prec_t)((mpfr_uprec_t)(~(mpfr_uprec_t)0)>>1))

but that looks unrelated. Likewise (same assert in init2.c) for
arith_power via gfortran.dg/integer_exponentiation_4.f90 and
in gimple_resimplify2 (with -O1) for /gfortran.dg/large_real_kind_2.F90.

As those seem to be mpfr bugs, they don't trigger for the ...pi functions,
I have decided to ignore them when applying the patch.

Sorry for the breakage!

All good!  Thanks for the quick fix!

Harald

Tobias

PS: I tried to build mpfr 3.1.0 in tree but that had compile issues with my
GCC 14 system compiler; but at least mpfr-3.1.6 seems to build fine. I think
MPFR 4.0.x avoids the assert.


@Yuao: To build mpfr in tree, you can use:
   ./contrib/download_prerequisites
and the then build like normal. This installs multiple libraries - but not
all are needed and mpfr 4.1.0 might be to new. Thus, the following is better:

For only mpfr, the simplest is to download it from https://www.mpfr.org/ history.html unpack the tarball, and add a symlink 'ln -s mpfr-3.1.6 mpfr'. If you now build GCC, it will automatically first configure and build 'mpfr' and then use it to build
GCC.


Reply via email to