From 46d7f9a7edf26d6d2fd70338a9b115f2596e7174 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 21 Jan 2005 13:53:48 +0000 Subject: [PATCH] Ensure that compilers that pretend to be gcc don't actually get the gcc-specific compiler flags (because they don't work -- @#$%@#$%!!!) This commit was SVN r4092. --- config/ompi_setup_cc.m4 | 36 ++++++++++++++++++++++++++++++++++-- config/ompi_setup_cxx.m4 | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/config/ompi_setup_cc.m4 b/config/ompi_setup_cc.m4 index 3ceb06041b..bfc871f75e 100644 --- a/config/ompi_setup_cc.m4 +++ b/config/ompi_setup_cc.m4 @@ -39,6 +39,32 @@ AC_DEFINE_UNQUOTED(OMPI_CC, "$CC", [OMPI underlying C compiler]) CPPFLAGS="$CPPFLAGS -DOMPI_BUILDING=1" +# Check for compilers that impersonate gcc + +AC_MSG_CHECKING([for compilers that impersonate gcc]) +msg= +TRULY_GCC=$GCC +if test "$GCC" = "yes"; then + AC_TRY_COMPILE([], [ +int i = 3; +#if __INTEL_COMPILER +#error Yes, I am lying about being gcc. +#endif +], [], [msg=intel]) + + # If we made it through unscathed, then it really is gcc + if test -z "$msg"; then + TRULY_GCC=yes + else + TRULY_GCC=no + fi +else + # We never thought that this was gcc to begin with + msg=not applicable + TRULY_GCC=no +fi +AC_MSG_RESULT([$msg]) + # Do we want debugging? if test "$WANT_DEBUG" = "1"; then @@ -47,8 +73,11 @@ if test "$WANT_DEBUG" = "1"; then AC_MSG_WARN([-g has been added to CFLAGS (--enable-debug)]) fi +# These flags are generally gcc-specific; even the gcc-impersonating +# compilers won't accept them. + OMPI_CFLAGS_BEFORE_PICKY="$CFLAGS" -if test "$GCC" = "yes" -a "$WANT_PICKY_COMPILER" = 1; then +if test "$TRULY_GCC" = "yes" -a "$WANT_PICKY_COMPILER" = 1; then add="-Wall -Wundef -Wno-long-long -Wsign-compare" add="$add -Wmissing-prototypes -Wstrict-prototypes" add="$add -Wcomment -pedantic" @@ -68,7 +97,7 @@ if test "$GCC" = "yes" -a "$WANT_PICKY_COMPILER" = 1; then fi # See if this version of gcc allows -finline-functions and/or -# -fno-strict-aliasing +# -fno-strict-aliasing. Even check the gcc-impersonating compilers. if test "$GCC" = "yes"; then CFLAGS_orig="$CFLAGS" @@ -124,6 +153,9 @@ fi # prohibitive). If we're using anything else, be conservative and # just use -O. +# Note: gcc-imperonating compilers accept -O3, so there's no need for +# $TRULY_GCC here. + if test "$GCC" = yes; then OPTFLAGS="-O3" else diff --git a/config/ompi_setup_cxx.m4 b/config/ompi_setup_cxx.m4 index 4a41b5a0de..a158b145ee 100644 --- a/config/ompi_setup_cxx.m4 +++ b/config/ompi_setup_cxx.m4 @@ -27,6 +27,32 @@ BASECXX="`basename $CXX`" CXXFLAGS="$ompi_cxxflags_save" AC_DEFINE_UNQUOTED(OMPI_CXX, "$CXX", [OMPI underlying C++ compiler]) +# Check for compilers that impersonate g++ + +AC_MSG_CHECKING([for compilers that impersonate g++]) +msg= +TRULY_GXX=$GXX +if test "$GXX" = "yes"; then + AC_TRY_COMPILE([], [ +int i = 3; +#if __INTEL_COMPILER +#error Yes, I am lying about being g++. +#endif +], [], [msg=intel]) + + # If we made it through unscathed, then it really is g++ + if test -z "$msg"; then + TRULY_GXX=yes + else + TRULY_GXX=no + fi +else + # We never thought that this was GXX to begin with + msg=not applicable + TRULY_GXX=no +fi +AC_MSG_RESULT([$msg]) + # Do we want debugging? if test "$WANT_DEBUG" = "1"; then @@ -35,8 +61,11 @@ if test "$WANT_DEBUG" = "1"; then AC_MSG_WARN([-g has been added to CXXFLAGS (--enable-debug)]) fi +# These flags are generally g++-specific; even the g++-impersonating +# compilers won't accept them. + OMPI_CXXFLAGS_BEFORE_PICKY="$CXXFLAGS" -if test "$GCC" = "yes" -a "$WANT_PICKY_COMPILER" = 1; then +if test "$TRULY_GXX" = "yes" -a "$WANT_PICKY_COMPILER" = 1; then add="-g -Wall -Wundef -Wno-long-long" # see if -Wno-long-double works... @@ -53,8 +82,9 @@ if test "$GCC" = "yes" -a "$WANT_PICKY_COMPILER" = 1; then unset add fi -# See if this version of gcc allows -finline-functions -if test "$GCC" = "yes"; then +# See if this version of g++ allows -finline-functions + +if test "$GXX" = "yes"; then CXXFLAGS_orig="$CXXFLAGS" CXXFLAGS="$CXXFLAGS -finline-functions" add= @@ -122,6 +152,9 @@ esac # Same rationale for g++ as with gcc in OMPI_SETUP_CC. +# Note: gcc-imperonating compilers accept -O3, so there's no need for +# $TRULY_GCC here. + if test "$GXX" = yes; then OPTFLAGS="-O3" else