This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch,Fortran+Build] Use more complicated quad-math config check
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Tue, 15 Feb 2011 16:16:57 +0100
- Subject: [Patch,Fortran+Build] Use more complicated quad-math config check
On some targets, __float128 exists but the support is insufficient to
build libquadmath because some functionality is not provided by libc (or
should it be by libgcc?). Thus, the configure test for libquadmath
failed - and libquadmath is not build. (That's OK.)
In libgfortran, there is a similar check, but seemingly it uses fewer
features and thus does not fail on some targets, which cannot build
libquadmath. Result: The build fails as libquadmath is not available.
The solution is to use the same check as for libquadmath. (Additionally,
one should, e.g., provide the missing bits in libgcc to enable a working
quadmath support. But that's a separate issue.)
There are two related PRs to this issue:
a) PR 47716 for NetBSD 5.1 (x86-64); there the patch has been confirmed
to work; unfortunately, there seem to be more issues on that platform.
(Lots of test suite failures, cf. PR.)
b) PR 47648 for FreeBSD on ia64. (FreeBSD on x86-64 is OK.)
Build and regtested on x86-64 linux (and build on NetBSD, cf. PR).
OK for the trunk?
Tobias
PS: The result of the configure check is as if libgfortran were build
with --disable-libquadmath-support. The front end will still believe
that __float128 [or rather: REAL(16)] is available.
2011-02-15 Tobias Burnus <burnus@net-b.de>
PR fortran/47716
PR fortran/47648
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Use check from
libquadmath, which uses more features.
* configure: Regenerate.
diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4
index 9873d9f..1bc1c7b 100644
--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
@@ -284,24 +284,33 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
AC_CACHE_CHECK([whether we have a usable __float128 type],
libgfor_cv_have_float128, [
- AC_TRY_LINK([
-/* no header */
-],[
- typedef _Complex float __attribute__((mode(TC))) __complex128;
-
- __float128 x;
- x = __builtin_huge_valq() - 2.e1000Q;
-
- __complex128 z1, z2;
- z1 = x;
- z2 = 2.Q;
-
- z1 /= z2;
- z1 /= 7.Q;
-],
- libgfor_cv_have_float128=yes,
- libgfor_cv_have_float128=no)
- ])
+ GCC_TRY_COMPILE_OR_LINK([
+ typedef _Complex float __attribute__((mode(TC))) __complex128;
+
+ __float128 foo (__float128 x)
+ {
+
+ __complex128 z1, z2;
+
+ z1 = x;
+ z2 = x / 7.Q;
+ z2 /= z1;
+
+ return (__float128) z2;
+ }
+
+ __float128 bar (__float128 x)
+ {
+ return x * __builtin_huge_valq ();
+ }
+ ],[
+ foo (1.2Q);
+ bar (1.2Q);
+ ],[
+ libgfor_cv_have_float128=yes
+ ],[
+ libgfor_cv_have_float128=no
+])])
if test "x$libgfor_cv_have_float128" = xyes; then
AC_DEFINE(HAVE_FLOAT128, 1, [Define if have a usable __float128 type.])
diff --git a/libgfortran/configure b/libgfortran/configure
index 42f72b5..9d3c891 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -25075,42 +25075,99 @@ if test "${libgfor_cv_have_float128+set}" = set; then :
$as_echo_n "(cached) " >&6
else
- if test x$gcc_no_link = xyes; then
- as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
-fi
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ if test x$gcc_no_link = xyes; then
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-/* no header */
+ typedef _Complex float __attribute__((mode(TC))) __complex128;
+
+ __float128 foo (__float128 x)
+ {
+
+ __complex128 z1, z2;
+
+ z1 = x;
+ z2 = x / 7.Q;
+ z2 /= z1;
+
+ return (__float128) z2;
+ }
+
+ __float128 bar (__float128 x)
+ {
+ return x * __builtin_huge_valq ();
+ }
int
main ()
{
- typedef _Complex float __attribute__((mode(TC))) __complex128;
+ foo (1.2Q);
+ bar (1.2Q);
- __float128 x;
- x = __builtin_huge_valq() - 2.e1000Q;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
- __complex128 z1, z2;
- z1 = x;
- z2 = 2.Q;
+ libgfor_cv_have_float128=yes
- z1 /= z2;
- z1 /= 7.Q;
+else
+
+ libgfor_cv_have_float128=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ if test x$gcc_no_link = xyes; then
+ as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ typedef _Complex float __attribute__((mode(TC))) __complex128;
+
+ __float128 foo (__float128 x)
+ {
+
+ __complex128 z1, z2;
+
+ z1 = x;
+ z2 = x / 7.Q;
+ z2 /= z1;
+
+ return (__float128) z2;
+ }
+
+ __float128 bar (__float128 x)
+ {
+ return x * __builtin_huge_valq ();
+ }
+
+int
+main ()
+{
+
+ foo (1.2Q);
+ bar (1.2Q);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- libgfor_cv_have_float128=yes
+
+ libgfor_cv_have_float128=yes
+
else
- libgfor_cv_have_float128=no
+
+ libgfor_cv_have_float128=no
+
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-
+fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgfor_cv_have_float128" >&5
$as_echo "$libgfor_cv_have_float128" >&6; }