public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [libgfortran,patch] New autoconf test
@ 2007-01-09  7:55 François-Xavier Coudert
  2007-01-09  8:00 ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: François-Xavier Coudert @ 2007-01-09  7:55 UTC (permalink / raw)
  To: bonzini, dj, neroden, aoliva; +Cc: gcc-patches, GFortran

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-01-09 11:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-09  7:55 [libgfortran,patch] New autoconf test François-Xavier Coudert
2007-01-09  8:00 ` Paolo Bonzini
2007-01-09  9:44   ` Andreas Schwab
     [not found]     ` <19c433eb0701090147l4f311893w2d429aec4c616d6f@mail.gmail.com>
2007-01-09 10:40       ` Andreas Schwab
2007-01-09 10:44       ` Paolo Bonzini
2007-01-09 11:41         ` François-Xavier Coudert

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).