Patchwork [libgfortran] : Fix PR59313, gfortran.dg/erf_3.F90 FAILs

login
register
mail settings
Submitter Rainer Orth
Date Dec. 5, 2013, 9:30 p.m.
Message ID <yddfvq7c7f2.fsf@CeBiTec.Uni-Bielefeld.DE>
Download mbox | patch
Permalink /patch/297399/
State New
Headers show

Comments

Rainer Orth - Dec. 5, 2013, 9:30 p.m.
Uros Bizjak <ubizjak@gmail.com> writes:

> Currently, gfortran.dg/erf_3.F90 FAILs on targets with 128bit
> (quadruple) long double, since high-precision erfc_scaled_r16 gets
> defined only for __float128 quadruple precision.
>
> Attached patch defines this function also for 128bit long double targets.
>
> [BTW: The patch really implements what FX's ChangeLog says:
>
>     * intrinsics/erfc_scaled_inc.c: Do not provide quadruple
>     precision variant.]
>
> 2013-12-01  Uros Bizjak  <ubizjak@gmail.com>
>
>     PR libfortran/59313
>     * intrinsics/erfc_scaled.c (erfc_scaled_r16): Also provide for
>     quadruple precision long double variant.
>
> Tested on x86_64-pc-linux-gnu and alphaev68-pc-linux-gnu.
>
> OK for mainline?

Unfortunately, this breaks Solaris/SPARC bootstrap:

/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c: In function 'erfc_scaled_r16':
/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:64:22: error: 'M_2_SQRTPIl' undeclared (first use in this function)
 # define _M_2_SQRTPI M_2_SQRTPIl
                      ^
/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:117:31: note: in expansion of macro '_M_2_SQRTPI'
       return (1 + sum) / x * (_M_2_SQRTPI / 2);
                               ^
/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:64:22: note: each undeclared identifier is reported only once for each function it appears in
 # define _M_2_SQRTPI M_2_SQRTPIl
                      ^
/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:117:31: note: in expansion of macro '_M_2_SQRTPI'
       return (1 + sum) / x * (_M_2_SQRTPI / 2);
                               ^
/vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:119:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make[3]: *** [erfc_scaled.lo] Error 1

It seems M_2_SQRTPI[lq] are GNU extensions, thus missing in Solaris
<math.h>.  The following patch at least allows Solaris bootstrap to
continue:



I suppose the same should be done for M_2_SQRTPIq?

	Rainer
Tobias Burnus - Dec. 5, 2013, 10:17 p.m.
Rainer Orth wrote:
> Unfortunately, this breaks Solaris/SPARC bootstrap:
>
> /vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:64:22: error: 'M_2_SQRTPIl' undeclared (first use in this function)
>   # define _M_2_SQRTPI M_2_SQRTPIl
>
> It seems M_2_SQRTPI[lq] are GNU extensions, thus missing in Solaris
> <math.h>.  The following patch at least allows Solaris bootstrap to
> continue:

The patch is looks good to me.

> diff --git a/libgfortran/intrinsics/erfc_scaled.c b/libgfortran/intrinsics/erfc_scaled.c
> +# ifndef M_2_SQRTPIl
> +#  define M_2_SQRTPIl 1.128379167095512573896158903121545172L
> +# endif
>
> I suppose the same should be done for M_2_SQRTPIq?

I don't think so. That's defined in libquadmath's quadmath.h, which is 
part of GCC.

Tobias
Rainer Orth - Dec. 5, 2013, 10:29 p.m.
Tobias Burnus <burnus@net-b.de> writes:

> Rainer Orth wrote:
>> Unfortunately, this breaks Solaris/SPARC bootstrap:
>>
>> /vol/gcc/src/hg/trunk/local/libgfortran/intrinsics/erfc_scaled.c:64:22: error: 'M_2_SQRTPIl' undeclared (first use in this function)
>>   # define _M_2_SQRTPI M_2_SQRTPIl
>>
>> It seems M_2_SQRTPI[lq] are GNU extensions, thus missing in Solaris
>> <math.h>.  The following patch at least allows Solaris bootstrap to
>> continue:
>
> The patch is looks good to me.

Thanks.  I'll commit it with a proper ChangeLog entry after testing completes.

>> diff --git a/libgfortran/intrinsics/erfc_scaled.c b/libgfortran/intrinsics/erfc_scaled.c
>> +# ifndef M_2_SQRTPIl
>> +#  define M_2_SQRTPIl 1.128379167095512573896158903121545172L
>> +# endif
>>
>> I suppose the same should be done for M_2_SQRTPIq?
>
> I don't think so. That's defined in libquadmath's quadmath.h, which is part
> of GCC.

Ah, that explains why I couldn't find the definition even in current git
glibc :-)

	Rainer

Patch

diff --git a/libgfortran/intrinsics/erfc_scaled.c b/libgfortran/intrinsics/erfc_scaled.c
--- a/libgfortran/intrinsics/erfc_scaled.c
+++ b/libgfortran/intrinsics/erfc_scaled.c
@@ -61,6 +61,9 @@  see the files COPYING3 and COPYING.RUNTI
 #else
 
 # define _THRESH -106.566990228185312813205074546585730L
+# ifndef M_2_SQRTPIl
+#  define M_2_SQRTPIl 1.128379167095512573896158903121545172L
+# endif
 # define _M_2_SQRTPI M_2_SQRTPIl
 # define _INF __builtin_infl()
 # ifdef HAVE_ERFCL