This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[libgfortran,patch] New autoconf test


Hi all,

I'd like to have the opinion of a autoconf or build machinery expert
on this patch. I'm trying to add a test in libgfortran/configure.ac to
check that the gfortran compiler that was just built (before the
target libraries) is working, and if not, issue a clear error message.
The following patch appears to do just this on my i686-linux setup,
but
 a) is it the right way of doing this?
 b) would it work in a cross-compiler setup?

Index: libgfortran/acinclude.m4
===================================================================
--- libgfortran/acinclude.m4    (revision 120585)
+++ libgfortran/acinclude.m4    (working copy)
@@ -1,6 +1,24 @@
m4_include(../config/acx.m4)
m4_include(../config/no-executables.m4)

+dnl Check that we have a working GNU Fortran compiler
+AC_DEFUN([LIBGFOR_WORKING_GFORTRAN], [
+  AC_MSG_CHECKING([whether the GNU Fortran compiler is working])
+  cat > conftest.f90 <<EOF
+    program foo
+      real, parameter :: bar = sin(12.34)
+    end program foo
+EOF
+  if ( $FC conftest.f90 -c -o conftest.o ); then
+    echo "yes"
+    rm conftest.f90 conftest.o
+  else
+    AC_MSG_ERROR(GNU Fortran is not working; error message is printed above)
+    rm conftest.f90
+  fi
+])
+
+
dnl Check:
dnl * If we have gettimeofday;
dnl * If we have struct timezone for use in calling it;
Index: libgfortran/configure.ac
===================================================================
--- libgfortran/configure.ac    (revision 120585)
+++ libgfortran/configure.ac    (working copy)
@@ -143,6 +143,10 @@
FC="$GFORTRAN"
AC_PROG_FC(gfortran)

+# We need a working compiler at that point, otherwise give a clear
+# error message and bail out.
+LIBGFOR_WORKING_GFORTRAN
+
# extra LD Flags which are required for targets
case "${host}" in
  *-darwin*)


For gfortran developers: the reason why we need to do that is that people sometime get an unusable f951 (liked with a wrong mpfr library, or that doesn't work because LD_LIBRARY_PATH is not set correctly) and in that case, they currently don't have a clear error message but a rather cryptic error while compiling the library. See PR 26893 (especially the last comments).

Thanks,
FX


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]