4eb3ee7835
We have repeatedly seen users inadvertantly try to use a C compiler for $CXX (e.g., using icc instead of icpc in recent versions of the Intel compiler). Unfortunately, this would "sorta work", meaning that configure would complete successfully and the build would fail much later in the process (when $CXX was used to try to link a C++ compiler). This was further compounded by the fact that many C compilers will switch into "C++ mode" when they compile files that end in .cc -- meaning that they'll *compile* C++ codes properly, but they won't *link* properly. Hence, users would get all the way down to compiling the C++ MPI bindings or ompi_info (i.e., very late in the build process) before the problem became evident. We already have a test in configure that tries to compile, link, and run a sample C++ program. This helped ensure that $CXX was a valid compiler, but it did not catch if the user accidentally supplied a C compiler instead of a C++ compiler because the test program was simply "return 0". This commit updates the test program to use some C++-specific constructs (std::string) so that if the user supplies a C compiler in $CXX, the program may *compile*, but it will definitely fail to *link*. Hence, the process will fail early in configure (with a descriptive message about how the compiler failed to work properly) rather than late in the build. This commit was SVN r10829.
85 строки
3.0 KiB
Bash
85 строки
3.0 KiB
Bash
dnl -*- shell-script -*-
|
|
dnl
|
|
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
dnl University Research and Technology
|
|
dnl Corporation. All rights reserved.
|
|
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
dnl of Tennessee Research Foundation. All rights
|
|
dnl reserved.
|
|
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
dnl University of Stuttgart. All rights reserved.
|
|
dnl Copyright (c) 2004-2005 The Regents of the University of California.
|
|
dnl All rights reserved.
|
|
dnl $COPYRIGHT$
|
|
dnl
|
|
dnl Additional copyrights may follow
|
|
dnl
|
|
dnl $HEADER$
|
|
dnl
|
|
dnl sets:
|
|
dnl F77 : full pathname to compiler
|
|
dnl BASEF77 : compiler name (no path)
|
|
dnl OMPI_WANT_F77_BINDINGS : (actually set by ompi_configure_options, may be
|
|
dnl redefined here)
|
|
dnl FC : Same as F77. Side effect of AC_PROG_FC. Should
|
|
dnl not be used
|
|
dnl defines:
|
|
dnl OMPI_F77 : same as F77
|
|
dnl OMPI_WANT_F77_BINDINGS :
|
|
dnl am_conditional:
|
|
dnl OMPI_WANT_F77_BINDINGS :
|
|
|
|
AC_DEFUN([OMPI_SETUP_F77],[
|
|
|
|
# Modularize this setup so that sub-configure.in scripts can use this
|
|
# same setup code.
|
|
|
|
ompi_show_subtitle "Fortran 77 compiler"
|
|
|
|
#
|
|
# Check for the compiler
|
|
#
|
|
# Note that we don't actually *use* the fortran compiler to build
|
|
# anything in OMPI; it's only used here in configure to find out
|
|
# symbol conventions, type sizes, etc. We also pass it down to
|
|
# the wrapper compiler mpif77.
|
|
#
|
|
# Always run this test, even if fortran isn't wanted so that F77 has
|
|
# value for the Fint tests
|
|
#
|
|
ompi_fflags_save="$FFLAGS"
|
|
AC_PROG_F77([gfortran g77 f77 xlf frt ifort pgf77 fort77 fl32 af77])
|
|
FFLAGS="$ompi_fflags_save"
|
|
if test -z "$F77"; then
|
|
AC_MSG_WARN([*** Fortran 77 bindings disabled (could not find compiler)])
|
|
OMPI_WANT_F77_BINDINGS=0
|
|
OMPI_F77="none"
|
|
BASEF77="none"
|
|
OMPI_F77_ABSOLUTE="none"
|
|
else
|
|
OMPI_F77="$F77"
|
|
BASEF77="`basename $OMPI_F77`"
|
|
OMPI_F77_ABSOLUTE="`which $F77`"
|
|
|
|
if test "$OMPI_WANT_F77_BINDINGS" = "0" ; then
|
|
AC_MSG_WARN([*** Fortran 77 bindings disabled by user])
|
|
OMPI_WANT_F77_BINDINGS=0
|
|
else
|
|
OMPI_WANT_F77_BINDINGS=1
|
|
fi
|
|
fi
|
|
|
|
# make sure the compiler actually works, if not cross-compiling
|
|
# Don't just use the AC macro so that we can have a pretty
|
|
# message.
|
|
AS_IF([test $OMPI_WANT_F77_BINDINGS -eq 1],
|
|
[OMPI_CHECK_COMPILER_WORKS([Fortran 77], [], [], [],
|
|
[AC_MSG_ERROR([Could not run a simple Fortran 77 program. Aborting.])])])
|
|
|
|
AC_DEFINE_UNQUOTED(OMPI_WANT_F77_BINDINGS, $OMPI_WANT_F77_BINDINGS,
|
|
[Whether we want the MPI f77 bindings or not])
|
|
AC_DEFINE_UNQUOTED(OMPI_F77, "$OMPI_F77", [OMPI underlying F77 compiler])
|
|
AM_CONDITIONAL(OMPI_WANT_F77_BINDINGS, test "$OMPI_WANT_F77_BINDINGS" = "1")
|
|
AC_SUBST(OMPI_F77_ABSOLUTE)
|
|
])
|