diff mbox

[configure,libgfortran] : PR78478: Use fpu-generic for x86 when _SOFT_FLOAT is defined

Message ID CAFULd4Z4O4fMQv2R6pLHJmgahkCZXoLSXvdgiSj1FMit-WHZhw@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Jan. 19, 2017, 8:43 p.m. UTC
Hello!

Attached patch avoids bootstrap error when building libgfortran for
soft-float x86 targets.  Configure detects when _SOFT_FLOAT is defined
and uses fpu-generic.h instead of fpu-387.h header.

The patch also imports ax_check_define.m4 from autoconf archive [1] -
the macro is really handy, and I guess it can be used in many other
places, avoiding reinventing the wheel.

2017-01-19  Uros Bizjak  <ubizjak@gmail.com>

    PR target/78478
    * config/ax_check_define.m4: New file.

libgfortran/ChangeLog:

2017-01-19  Uros Bizjak  <ubizjak@gmail.com>

    PR target/78478
    * acinclude.m4: Include ../config/ax_check_define.m4
    * configure.ac: Check if _SOFT_FLOAT is defined.
    * configure.host (i?86 | x86_64): Use fpu-generic when
    have_soft_float is set.
    * configure: Regenerate.

Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

OK for mainline and gcc-6 branch?

[1] https://www.gnu.org/software/autoconf-archive/ax_check_define.html

Uros.

Comments

Janne Blomqvist Jan. 19, 2017, 8:57 p.m. UTC | #1
On Thu, Jan 19, 2017 at 10:43 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
> Attached patch avoids bootstrap error when building libgfortran for
> soft-float x86 targets.  Configure detects when _SOFT_FLOAT is defined
> and uses fpu-generic.h instead of fpu-387.h header.
>
> The patch also imports ax_check_define.m4 from autoconf archive [1] -
> the macro is really handy, and I guess it can be used in many other
> places, avoiding reinventing the wheel.
>
> 2017-01-19  Uros Bizjak  <ubizjak@gmail.com>
>
>     PR target/78478
>     * config/ax_check_define.m4: New file.
>
> libgfortran/ChangeLog:
>
> 2017-01-19  Uros Bizjak  <ubizjak@gmail.com>
>
>     PR target/78478
>     * acinclude.m4: Include ../config/ax_check_define.m4
>     * configure.ac: Check if _SOFT_FLOAT is defined.
>     * configure.host (i?86 | x86_64): Use fpu-generic when
>     have_soft_float is set.
>     * configure: Regenerate.
>
> Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
>
> OK for mainline and gcc-6 branch?

Ok, thanks.

>
> [1] https://www.gnu.org/software/autoconf-archive/ax_check_define.html
>
> Uros.
diff mbox

Patch

Index: config/ax_check_define.m4
===================================================================
--- config/ax_check_define.m4	(nonexistent)
+++ config/ax_check_define.m4	(working copy)
@@ -0,0 +1,92 @@ 
+# ===========================================================================
+#      http://www.gnu.org/software/autoconf-archive/ax_check_define.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AC_CHECK_DEFINE([symbol], [ACTION-IF-FOUND], [ACTION-IF-NOT])
+#   AX_CHECK_DEFINE([includes],[symbol], [ACTION-IF-FOUND], [ACTION-IF-NOT])
+#
+# DESCRIPTION
+#
+#   Complements AC_CHECK_FUNC but it does not check for a function but for a
+#   define to exist. Consider a usage like:
+#
+#    AC_CHECK_DEFINE(__STRICT_ANSI__, CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500")
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#
+#   This program is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation; either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 8
+
+AU_ALIAS([AC_CHECK_DEFINED], [AC_CHECK_DEFINE])
+AC_DEFUN([AC_CHECK_DEFINE],[
+AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$1])dnl
+AC_CACHE_CHECK([for $1 defined], ac_var,
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+  #ifdef $1
+  int ok;
+  #else
+  choke me
+  #endif
+]])],[AS_VAR_SET(ac_var, yes)],[AS_VAR_SET(ac_var, no)]))
+AS_IF([test AS_VAR_GET(ac_var) != "no"], [$2], [$3])dnl
+AS_VAR_POPDEF([ac_var])dnl
+])
+
+AU_ALIAS([AX_CHECK_DEFINED], [AX_CHECK_DEFINE])
+AC_DEFUN([AX_CHECK_DEFINE],[
+AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$2_$1])dnl
+AC_CACHE_CHECK([for $2 defined in $1], ac_var,
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <$1>]], [[
+  #ifdef $2
+  int ok;
+  #else
+  choke me
+  #endif
+]])],[AS_VAR_SET(ac_var, yes)],[AS_VAR_SET(ac_var, no)]))
+AS_IF([test AS_VAR_GET(ac_var) != "no"], [$3], [$4])dnl
+AS_VAR_POPDEF([ac_var])dnl
+])
+
+AC_DEFUN([AX_CHECK_FUNC],
+[AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$2])dnl
+AC_CACHE_CHECK([for $2], ac_var,
+dnl AC_LANG_FUNC_LINK_TRY
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([$1
+                #undef $2
+                char $2 ();],[
+                char (*f) () = $2;
+                return f != $2; ])],
+                [AS_VAR_SET(ac_var, yes)],
+                [AS_VAR_SET(ac_var, no)])])
+AS_IF([test AS_VAR_GET(ac_var) = yes], [$3], [$4])dnl
+AS_VAR_POPDEF([ac_var])dnl
+])# AC_CHECK_FUNC
Index: libgfortran/acinclude.m4
===================================================================
--- libgfortran/acinclude.m4	(revision 244636)
+++ libgfortran/acinclude.m4	(working copy)
@@ -1,6 +1,7 @@ 
 m4_include(../config/acx.m4)
 m4_include(../config/no-executables.m4)
 m4_include(../config/math.m4)
+m4_include(../config/ax_check_define.m4)
 
 dnl Check that we have a working GNU Fortran compiler
 AC_DEFUN([LIBGFOR_WORKING_GFORTRAN], [
Index: libgfortran/configure
===================================================================
--- libgfortran/configure	(revision 244636)
+++ libgfortran/configure	(working copy)
@@ -25822,6 +25822,43 @@ 
 fi
 
 
+# Check if _SOFT_FLOAT is defined
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _SOFT_FLOAT defined" >&5
+$as_echo_n "checking for _SOFT_FLOAT defined... " >&6; }
+if test "${ac_cv_defined__SOFT_FLOAT+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  #ifdef _SOFT_FLOAT
+  int ok;
+  #else
+  choke me
+  #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_defined__SOFT_FLOAT=yes
+else
+  ac_cv_defined__SOFT_FLOAT=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_defined__SOFT_FLOAT" >&5
+$as_echo "$ac_cv_defined__SOFT_FLOAT" >&6; }
+if test $ac_cv_defined__SOFT_FLOAT != "no"; then :
+  have_soft_float=yes
+fi
+
 # Runs configure.host to set up necessary host-dependent shell variables.
 # We then display a message about it, and propagate them through the
 # build chain.
Index: libgfortran/configure.ac
===================================================================
--- libgfortran/configure.ac	(revision 244636)
+++ libgfortran/configure.ac	(working copy)
@@ -556,6 +556,9 @@ 
 AC_CHECK_FUNC([fp_trap],[have_fp_trap=yes AC_DEFINE([HAVE_FP_TRAP],[1],[fp_trap is present])])
 AC_CHECK_FUNC([fp_enable],[have_fp_enable=yes AC_DEFINE([HAVE_FP_ENABLE],[1],[fp_enable is present])])
 
+# Check if _SOFT_FLOAT is defined
+AC_CHECK_DEFINE([_SOFT_FLOAT],[have_soft_float=yes])
+
 # Runs configure.host to set up necessary host-dependent shell variables.
 # We then display a message about it, and propagate them through the
 # build chain.
Index: libgfortran/configure.host
===================================================================
--- libgfortran/configure.host	(revision 244636)
+++ libgfortran/configure.host	(working copy)
@@ -40,7 +40,11 @@ 
 # the x86 denormal exception.
 case "${host_cpu}" in
   i?86 | x86_64)
-    fpu_host='fpu-387'
+    if test "x${have_soft_float}" = "xyes"; then
+      fpu_host='fpu-generic'
+    else
+      fpu_host='fpu-387'
+    fi
     ieee_support='yes'
     ;;
 esac