From 870a2d2b82eaeb0dcf86e6e572d30c2135b13795 Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Fri, 14 Mar 2025 11:26:21 -0400 Subject: [PATCH] Update to AX_FC_REAL8 macro This is a refactor of AX_FC_REAL8. The GNU test for -f-default-real-8 and -fdefault-double-8 is split into two separate tests. The macro was also redesigned to avoid duplication of the test program, and to follow the same pattern as in autoconf's lib/fortran.m4. The AMD flang compilers require -fdefault-real-8 but not -fdefault-double-8. We now test for the first flag before testing for both. This patch will slightly improve support for AMD flang compilers. --- ac/deps/m4/ax_fc_real8.m4 | 81 +++++++++++++++++++-------------------- ac/m4/ax_fc_real8.m4 | 81 +++++++++++++++++++-------------------- 2 files changed, 80 insertions(+), 82 deletions(-) diff --git a/ac/deps/m4/ax_fc_real8.m4 b/ac/deps/m4/ax_fc_real8.m4 index e914b9f39a..565018a984 100644 --- a/ac/deps/m4/ax_fc_real8.m4 +++ b/ac/deps/m4/ax_fc_real8.m4 @@ -15,12 +15,14 @@ dnl avoiding any flags with affect integers, but this should still be used with dnl some care. dnl dnl GCC -fdefault-real-8, -fdefault-double-8 +dnl AMD (flang) -fdefault-real-8 dnl [Common alias] -r8 -dnl Intel Fortran -real-kind 64 -dnl PGI Fortran -Mr8 -dnl Cray Fortran -s real64 +dnl Intel -real-kind 64 +dnl PGI/Nvidia -Mr8 +dnl Cray -s real64 dnl NAG -double dnl +dnl dnl NOTE: dnl - Many compilers accept -r8 for real and double precision sizes, but dnl several compiler-specific options are also provided. @@ -34,31 +36,28 @@ dnl dnl Neither flag describes what we actually want, but we include it here dnl as a last resort. dnl -AC_DEFUN([AX_FC_REAL8], -[ +AC_DEFUN([AX_FC_REAL8], [ REAL8_FCFLAGS= - AC_ARG_ENABLE([real8], - [AS_HELP_STRING([--disable-real-8], [do not force 8-byte reals])]) + AC_ARG_ENABLE([real8], [ + AS_HELP_STRING([--disable-real-8], [do not force 8-byte reals]) + ]) if test "$enable_real8" != no; then AC_CACHE_CHECK([for $FC option to force 8-byte reals], - [ac_cv_prog_fc_real8], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([], [ - real :: x(4) - double precision :: y(4) - integer, parameter :: & - m = merge(1, 0, kind(x(1)) == selected_real_kind(15, 307)), & - n = merge(1, 0, kind(y(1)) == selected_real_kind(15, 307)) - print *, x(::m) - print *, y(::n) - ])], - [ac_cv_prog_fc_real8='none needed'], - [ac_cv_prog_fc_real8='unsupported' - for ac_option in "-fdefault-real-8 -fdefault-double-8" -r8 "-real-kind 64" -Mr8 "-s real64" -double; do - ac_save_FCFLAGS=$FCFLAGS - FCFLAGS="$FCFLAGS $ac_option" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([], [ + [ac_cv_prog_fc_real8], [ + ac_cv_prog_fc_real8='unsupported' + ac_fc_real8_FCFLAGS_save=$FCFLAGS + for ac_flag in none \ + -fdefault-real-8 \ + "-fdefault-real-8 -fdefault-double-8" \ + -r8 \ + "-real-kind 64" \ + -Mr8 \ + "-s real64" \ + -double + do + test "$ac_flag" != none && FCFLAGS="$ac_fc_real8_FCFLAGS_save $ac_flag" + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([], [ real :: x(4) double precision :: y(4) integer, parameter :: & @@ -66,21 +65,21 @@ AC_DEFUN([AX_FC_REAL8], n = merge(1, 0, kind(y(1)) == selected_real_kind(15, 307)) print *, x(::m) print *, y(::n) - ])], - [ac_cv_prog_fc_real8=$ac_option] - ) - FCFLAGS=$ac_save_FCFLAGS - if test "$ac_cv_prog_fc_real8" != unsupported; then - break - fi - done]) - ]) - case $ac_cv_prog_fc_real8 in #( - "none needed" | unsupported) - ;; #( - *) - REAL8_FCFLAGS=$ac_cv_prog_fc_real8 ;; - esac + ]) + ], [ac_cv_prog_fc_real8=$ac_flag ; break]) + done + FCFLAGS=$ac_fc_real8_FCFLAGS_save + ]) + case $ac_cv_prog_fc_real8 in #( + "none") + ac_cv_prog_fc_real8='none needed' + ;; #( + unsupported) + ;; #( + *) + REAL8_FCFLAGS=$ac_cv_prog_fc_real8 + ;; + esac fi - AC_SUBST(REAL8_FCFLAGS) + AC_SUBST([REAL8_FCFLAGS]) ]) diff --git a/ac/m4/ax_fc_real8.m4 b/ac/m4/ax_fc_real8.m4 index e914b9f39a..565018a984 100644 --- a/ac/m4/ax_fc_real8.m4 +++ b/ac/m4/ax_fc_real8.m4 @@ -15,12 +15,14 @@ dnl avoiding any flags with affect integers, but this should still be used with dnl some care. dnl dnl GCC -fdefault-real-8, -fdefault-double-8 +dnl AMD (flang) -fdefault-real-8 dnl [Common alias] -r8 -dnl Intel Fortran -real-kind 64 -dnl PGI Fortran -Mr8 -dnl Cray Fortran -s real64 +dnl Intel -real-kind 64 +dnl PGI/Nvidia -Mr8 +dnl Cray -s real64 dnl NAG -double dnl +dnl dnl NOTE: dnl - Many compilers accept -r8 for real and double precision sizes, but dnl several compiler-specific options are also provided. @@ -34,31 +36,28 @@ dnl dnl Neither flag describes what we actually want, but we include it here dnl as a last resort. dnl -AC_DEFUN([AX_FC_REAL8], -[ +AC_DEFUN([AX_FC_REAL8], [ REAL8_FCFLAGS= - AC_ARG_ENABLE([real8], - [AS_HELP_STRING([--disable-real-8], [do not force 8-byte reals])]) + AC_ARG_ENABLE([real8], [ + AS_HELP_STRING([--disable-real-8], [do not force 8-byte reals]) + ]) if test "$enable_real8" != no; then AC_CACHE_CHECK([for $FC option to force 8-byte reals], - [ac_cv_prog_fc_real8], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([], [ - real :: x(4) - double precision :: y(4) - integer, parameter :: & - m = merge(1, 0, kind(x(1)) == selected_real_kind(15, 307)), & - n = merge(1, 0, kind(y(1)) == selected_real_kind(15, 307)) - print *, x(::m) - print *, y(::n) - ])], - [ac_cv_prog_fc_real8='none needed'], - [ac_cv_prog_fc_real8='unsupported' - for ac_option in "-fdefault-real-8 -fdefault-double-8" -r8 "-real-kind 64" -Mr8 "-s real64" -double; do - ac_save_FCFLAGS=$FCFLAGS - FCFLAGS="$FCFLAGS $ac_option" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([], [ + [ac_cv_prog_fc_real8], [ + ac_cv_prog_fc_real8='unsupported' + ac_fc_real8_FCFLAGS_save=$FCFLAGS + for ac_flag in none \ + -fdefault-real-8 \ + "-fdefault-real-8 -fdefault-double-8" \ + -r8 \ + "-real-kind 64" \ + -Mr8 \ + "-s real64" \ + -double + do + test "$ac_flag" != none && FCFLAGS="$ac_fc_real8_FCFLAGS_save $ac_flag" + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([], [ real :: x(4) double precision :: y(4) integer, parameter :: & @@ -66,21 +65,21 @@ AC_DEFUN([AX_FC_REAL8], n = merge(1, 0, kind(y(1)) == selected_real_kind(15, 307)) print *, x(::m) print *, y(::n) - ])], - [ac_cv_prog_fc_real8=$ac_option] - ) - FCFLAGS=$ac_save_FCFLAGS - if test "$ac_cv_prog_fc_real8" != unsupported; then - break - fi - done]) - ]) - case $ac_cv_prog_fc_real8 in #( - "none needed" | unsupported) - ;; #( - *) - REAL8_FCFLAGS=$ac_cv_prog_fc_real8 ;; - esac + ]) + ], [ac_cv_prog_fc_real8=$ac_flag ; break]) + done + FCFLAGS=$ac_fc_real8_FCFLAGS_save + ]) + case $ac_cv_prog_fc_real8 in #( + "none") + ac_cv_prog_fc_real8='none needed' + ;; #( + unsupported) + ;; #( + *) + REAL8_FCFLAGS=$ac_cv_prog_fc_real8 + ;; + esac fi - AC_SUBST(REAL8_FCFLAGS) + AC_SUBST([REAL8_FCFLAGS]) ])