public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Piotr Kubaj <pkubaj@anongoth.pl>
To: FX <fxcoudert@gmail.com>
Cc: gcc-patches@gcc.gnu.org, Fortran List <fortran@gcc.gnu.org>,
	segher@kernel.crashing.org
Subject: Re: [PATCH] fortran: use fpu-glibc on powerpc*-unknown-freebsd
Date: Thu, 14 Apr 2022 02:49:49 +0200	[thread overview]
Message-ID: <YldvrUMCG8ddv7fb@KGPE-D16> (raw)
In-Reply-To: <FC979A37-66F2-4199-9EB1-C69EEDB4AB47@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 607 bytes --]

Hello,

can you check the following patch?

On 22-04-13 17:27:11, FX wrote:
> Hi,
> 
> > the problem is that configure checks for feenableexcept() in libm:
> > AC_CHECK_LIB([m],[feenableexcept],[have_feenableexcept=yes AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],[libm includes feenableexcept])])
> > 
> > FreeBSD doesn't have this function in libm, it's implemented in /usr/include/fenv.h.
> 
> I see. Then we probably can use AC_CHECK_FUNCS, or design a specific check, so that it gives the right value on both glibc and FreeBSD targets.
> 
> Could you test something on your end?
> 
> FX

-- 

[-- Attachment #1.2: 0001-powerpc-properly-detect-feenableexcept-on-FreeBSD.patch --]
[-- Type: text/x-diff, Size: 3874 bytes --]

From d5e255f09b4cfd2cb3688d0e2d5feba85d1f5dc8 Mon Sep 17 00:00:00 2001
From: Piotr Kubaj <pkubaj@FreeBSD.org>
Date: Thu, 14 Apr 2022 02:35:26 +0200
Subject: [PATCH] powerpc: properly detect feenableexcept on FreeBSD

FreeBSD doesn't have feenableexcept in libm, but in fenv.h.

Signed-off-by: Piotr Kubaj <pkubaj@FreeBSD.org>
---
 libgfortran/configure    | 48 +++++++++++++++++++++++++++++++++++++++-
 libgfortran/configure.ac | 18 ++++++++++++++-
 2 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/libgfortran/configure b/libgfortran/configure
index ae64dca3114..2f1011d7fdc 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -27338,8 +27338,52 @@ fi
 
 
 
+case x$target in
+  xpowerpc*-freebsd*)
+    # Check for the existence of <fenv.h> functions.
+    for ac_header in fenv.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "fenv.h" "ac_cv_header_fenv_h" "$ac_includes_default"
+if test "x$ac_cv_header_fenv_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_FENV_H 1
+_ACEOF
+ ac_has_fenv_h=yes
+else
+  ac_has_fenv_h=no
+fi
+
+done
+
+    if test x"$ac_has_fenv_h" = x"yes"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for feenableexcept in <fenv.h>" >&5
+$as_echo_n "checking for feenableexcept in <fenv.h>... " >&6; }
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <fenv.h>
+int
+main ()
+{
+int except, ret;
+                      ret = feenableexcept(except);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  have_feenableexcept=yes
+$as_echo "#define HAVE_FEENABLEEXCEPT 1" >>confdefs.h
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_feenableexcept" >&5
+$as_echo "$have_feenableexcept" >&6; }
+    fi
+    ;;
+  *)
 # Check for GNU libc feenableexcept
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for feenableexcept in -lm" >&5
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for feenableexcept in -lm" >&5
 $as_echo_n "checking for feenableexcept in -lm... " >&6; }
 if ${ac_cv_lib_m_feenableexcept+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -27384,6 +27428,8 @@ $as_echo "#define HAVE_FEENABLEEXCEPT 1" >>confdefs.h
 
 fi
 
+    ;;
+esac
 
 # At least for glibc, clock_gettime is in librt.  But don't
 # pull that in if it still doesn't give us the function we want.  This
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 97cc490cb5e..7c285aaf79c 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -602,8 +602,24 @@ fi
 # Check whether we have a __float128 type, depends on enable_libquadmath_support
 LIBGFOR_CHECK_FLOAT128
 
+case x$target in
+  xpowerpc*-freebsd*)
+    # Check for the existence of <fenv.h> functions.
+    AC_CHECK_HEADERS(fenv.h, ac_has_fenv_h=yes, ac_has_fenv_h=no)
+    if test x"$ac_has_fenv_h" = x"yes"; then
+      AC_MSG_CHECKING([for feenableexcept in <fenv.h>])
+      AC_TRY_COMPILE([#include <fenv.h>],
+                     [int except, ret;
+                      ret = feenableexcept(except);
+                     ],[have_feenableexcept=yes AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],[fenv.h includes feenableexcept])])
+      AC_MSG_RESULT($have_feenableexcept)
+    fi
+    ;;
+  *)
 # Check for GNU libc feenableexcept
-AC_CHECK_LIB([m],[feenableexcept],[have_feenableexcept=yes AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],[libm includes feenableexcept])])
+    AC_CHECK_LIB([m],[feenableexcept],[have_feenableexcept=yes AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],[libm includes feenableexcept])])
+    ;;
+esac
 
 # At least for glibc, clock_gettime is in librt.  But don't
 # pull that in if it still doesn't give us the function we want.  This
-- 
2.35.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-04-14  0:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-20 15:30 FX
2022-04-13 14:56 ` Piotr Kubaj
2022-04-13 15:27   ` FX
2022-04-14  0:49     ` Piotr Kubaj [this message]
2022-04-14  7:05       ` FX
2022-04-14 14:09         ` Piotr Kubaj
2022-04-28 17:09           ` Piotr Kubaj
2022-04-28 18:55             ` FX
2022-04-30 18:28               ` Piotr Kubaj
2022-04-30 19:17                 ` FX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YldvrUMCG8ddv7fb@KGPE-D16 \
    --to=pkubaj@anongoth.pl \
    --cc=fortran@gcc.gnu.org \
    --cc=fxcoudert@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).