Build fails on Ubuntu 16.04

Created a configure time test to see if clang will compile ICG correctly.
If the compilation fails, an error message telling the user to go download
clang/llvm from llvm.org is show.

refs #174
This commit is contained in:
Alex Lin 2016-06-02 08:52:00 -05:00
parent 1615e0f13b
commit 5966c61add
2 changed files with 62 additions and 0 deletions

View File

@ -16,6 +16,24 @@ AC_DEFUN([AX_LLVM_HOME],[
AC_SUBST([LLVM_HOME])
])
dnl Test if clang will link successfully. Some systems like Ubuntu 16.04 shipping with clang that does not work.
AC_DEFUN([AX_TEST_CLANG],[
LLVM_INCLUDE_DIR=`$LLVM_CONFIG --includedir`
LLVM_ALL_LD_FLAGS=`$LLVM_CONFIG --ldflags --libs`
AS_IF([LLVM_SYSTEM_LD_FLAGS=`$LLVM_CONFIG --system-libs 2>/dev/null`],[],[])
AC_LANG(C++)
AC_DEFINE([__STDC_CONSTANT_MACROS])
AC_DEFINE([__STDC_FORMAT_MACROS])
AC_DEFINE([__STDC_LIMIT_MACROS])
AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include "llvm/Support/Host.h"]],[[llvm::sys::getDefaultTargetTriple(); return 0; ]])])
AC_MSG_CHECKING([if clang works properly])
${CLANG}++ conftest.cpp --std=c++11 -I${LLVM_INCLUDE_DIR} ${LLVM_ALL_LD_FLAGS} ${LLVM_SYSTEM_LD_FLAGS} >&AS_MESSAGE_LOG_FD
AS_IF([test $? == 0 ],AC_MSG_RESULT([yes]),
[AC_MSG_ERROR([cannot use ${CLANG}. Download clang/llvm directly from http://llvm.org])
])
/bin/rm -f a.out
])
AC_DEFUN([AX_HDF5_HOME],[
AC_ARG_WITH([hdf5],
AS_HELP_STRING([--with-hdf5@<:@=DIR@:>@], [HDF5 root directory]),
@ -199,6 +217,7 @@ AC_CHECK_FILE([$LLVM_LIB_DIR/libLLVMSupport.a],
)
AC_PATH_PROG(CLANG, clang, noclang, "$LLVM_BIN_DIR:$LLVM_HOME/bin:/bin:/usr/bin:/usr/local/bin:/sw/bin")
AS_IF([test "$ac_cv_path_CLANG" = "noclang"],AC_MSG_ERROR([could not find clang]),[])
AX_TEST_CLANG
dnl look for udunits in /usr/include and /usr/include/udunits2
AX_UDUNITS_HOME([])

43
configure vendored
View File

@ -2251,6 +2251,8 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
@ -5749,6 +5751,47 @@ if test "$ac_cv_path_CLANG" = "noclang"; then :
as_fn_error $? "could not find clang" "$LINENO" 5
fi
LLVM_INCLUDE_DIR=`$LLVM_CONFIG --includedir`
LLVM_ALL_LD_FLAGS=`$LLVM_CONFIG --ldflags --libs`
if LLVM_SYSTEM_LD_FLAGS=`$LLVM_CONFIG --system-libs 2>/dev/null`; then :
fi
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
$as_echo "#define __STDC_CONSTANT_MACROS 1" >>confdefs.h
$as_echo "#define __STDC_FORMAT_MACROS 1" >>confdefs.h
$as_echo "#define __STDC_LIMIT_MACROS 1" >>confdefs.h
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include "llvm/Support/Host.h"
int
main ()
{
llvm::sys::getDefaultTargetTriple(); return 0;
;
return 0;
}
_ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if clang works properly" >&5
$as_echo_n "checking if clang works properly... " >&6; }
${CLANG}++ conftest.cpp --std=c++11 -I${LLVM_INCLUDE_DIR} ${LLVM_ALL_LD_FLAGS} ${LLVM_SYSTEM_LD_FLAGS} >&5
if test $? == 0 ; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
as_fn_error $? "cannot use ${CLANG}. Download clang/llvm directly from http://llvm.org" "$LINENO" 5
fi
/bin/rm -f a.out
# Check whether --with-udunits was given.