Skip to content

Commit

Permalink
Merge pull request #3697 from roystgnr/fpe_updates
Browse files Browse the repository at this point in the history
Update configuration to add default --enable-fpe-safety
  • Loading branch information
roystgnr authored Nov 10, 2023
2 parents 48d2447 + 01a843e commit d47c86f
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 21 deletions.
210 changes: 192 additions & 18 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ with_cxx_std
enable_sanitize
enable_glibcxx_debugging
enable_glibcxx_debugging_cppunit
enable_fpe_safety
enable_coverage
with_methods
enable_werror
Expand Down Expand Up @@ -2014,6 +2015,7 @@ Optional Features:
dbg mode
--enable-glibcxx-debugging-cppunit
Use GLIBCXX debugging flags for unit tests
--disable-fpe-safety remove FPE-trapping compiler flags
--enable-coverage configure code coverage analysis tools
--enable-werror Turn compilation warnings into errors
--enable-paranoid-warnings
Expand Down Expand Up @@ -8038,34 +8040,70 @@ fi
if test "x$compiler_brand_detected" = "xno"
then :

clang_version="`($CXX --version 2>&1)`"
is_clang="`echo $clang_version | grep 'clang'`"
ACSM_CLANG_VERSION_STRING="`($CXX --version 2>&1)`"
is_clang="`echo $ACSM_CLANG_VERSION_STRING | grep 'clang'`"

if test "x$is_clang" != "x"
then :

is_apple_clang="`echo $clang_version | grep 'Apple'`"
is_apple_clang="`echo $ACSM_CLANG_VERSION_STRING | grep 'Apple'`"
clang_vendor="clang"
if test "x$is_apple_clang" != "x"
then :
clang_vendor="Apple clang"
fi

clang_major_minor=unknown

if test "x$PERL" != "x"
then :

clang_major_minor=`echo $clang_version | $PERL -ne 'print $1 if /version\s(\d+\.\d+)/'`
if test "x$clang_major_minor" = "x"
then :
clang_major_minor=unknown
fi

fi
case "x$ACSM_CLANG_VERSION_STRING" in #(
*clang\ version\ 17.*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is clang-17.x >>>" >&5
printf "%s\n" "<<< C++ compiler is clang-17.x >>>" >&6; }
ACSM_CLANG_VERSION=17 ;; #(
*clang\ version\ 16.*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is clang-16.x >>>" >&5
printf "%s\n" "<<< C++ compiler is clang-16.x >>>" >&6; }
ACSM_CLANG_VERSION=16 ;; #(
*clang\ version\ 15.*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is clang-15.x >>>" >&5
printf "%s\n" "<<< C++ compiler is clang-15.x >>>" >&6; }
ACSM_CLANG_VERSION=15 ;; #(
*clang\ version\ 14.*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is clang-14.x >>>" >&5
printf "%s\n" "<<< C++ compiler is clang-14.x >>>" >&6; }
ACSM_CLANG_VERSION=14 ;; #(
*clang\ version\ 13.*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is clang-13.x >>>" >&5
printf "%s\n" "<<< C++ compiler is clang-13.x >>>" >&6; }
ACSM_CLANG_VERSION=13 ;; #(
*clang\ version\ 12.*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is clang-12.x >>>" >&5
printf "%s\n" "<<< C++ compiler is clang-12.x >>>" >&6; }
ACSM_CLANG_VERSION=12 ;; #(
*clang\ version\ 11.*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is clang-11.x >>>" >&5
printf "%s\n" "<<< C++ compiler is clang-11.x >>>" >&6; }
ACSM_CLANG_VERSION=11 ;; #(
*clang\ version\ 10.*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is clang-10.x >>>" >&5
printf "%s\n" "<<< C++ compiler is clang-10.x >>>" >&6; }
ACSM_CLANG_VERSION=10 ;; #(
*clang\ version\ 9.*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is clang-9.x >>>" >&5
printf "%s\n" "<<< C++ compiler is clang-9.x >>>" >&6; }
ACSM_CLANG_VERSION=9 ;; #(
*clang\ version\ 8.*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is clang-8.x >>>" >&5
printf "%s\n" "<<< C++ compiler is clang-8.x >>>" >&6; }
ACSM_CLANG_VERSION=8 ;; #(
*clang\ version\ 7.*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is clang-7.x >>>" >&5
printf "%s\n" "<<< C++ compiler is clang-7.x >>>" >&6; }
ACSM_CLANG_VERSION=7 ;; #(
*) :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler \"$ACSM_CLANG_VERSION\" is unknown but accepted clang version >>>" >&5
printf "%s\n" "<<< C++ compiler \"$ACSM_CLANG_VERSION\" is unknown but accepted clang version >>>" >&6; }
ACSM_CLANG_VERSION=other ;;
esac

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< C++ compiler is ${clang_vendor}, version ${clang_major_minor} >>>" >&5
printf "%s\n" "<<< C++ compiler is ${clang_vendor}, version ${clang_major_minor} >>>" >&6; }
ACSM_GXX_VERSION=clang
compiler_brand_detected=yes

Expand Down Expand Up @@ -26494,7 +26532,17 @@ fi
ACSM_CXXFLAGS_DBG="$ACSM_CXXFLAGS_DBG -Wunused-parameter -Wunused -Wpointer-arith -Wformat -Wparentheses -Qunused-arguments -Woverloaded-virtual -fno-limit-debug-info"
ACSM_NODEPRECATEDFLAG="-Wno-deprecated"

ACSM_FPE_SAFETY_FLAGS="-ftrapping-math"
if test "x$ACSM_CLANG_VERSION" = "xother" || test $ACSM_CLANG_VERSION -ge 10
then :
ACSM_FPE_SAFETY_FLAGS="-ftrapping-math"
else $as_nop
ACSM_FPE_SAFETY_FLAGS=""
fi

if test "x$ACSM_CLANG_VERSION" = "xother" || test $ACSM_CLANG_VERSION -ge 12
then :
ACSM_FPE_SAFETY_FLAGS="$ACSM_FPE_SAFETY_FLAGS -Wno-unsupported-floating-point-opt"
fi

ACSM_PARANOID_FLAGS="-Wall -Wextra -Wcast-align -Wdisabled-optimization -Wformat=2"
ACSM_PARANOID_FLAGS="$ACSM_PARANOID_FLAGS -Wformat-nonliteral -Wformat-security -Wformat-y2k"
Expand Down Expand Up @@ -26596,6 +26644,132 @@ fi






# Check whether --enable-fpe-safety was given.
if test ${enable_fpe_safety+y}
then :
enableval=$enable_fpe_safety; case "${enableval}" in #(
yes) :
acsm_enablefpesafety=yes ;; #(
no) :
acsm_enablefpesafety=no ;; #(
*) :
as_fn_error $? "bad value ${enableval} for --enable-fpe-safety" "$LINENO" 5 ;;
esac
else $as_nop
acsm_enablefpesafety=yes
fi


if test "$acsm_enablefpesafety" = "yes"
then :

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

ac_fpe_safety_save_CFLAGS="$CFLAGS"
CFLAGS="${CFLAGS} ${ACSM_FPE_SAFETY_FLAGS}"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main (void)
{

;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :

else $as_nop

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unable to compile C with FPE safety flag ($CC $ACSM_FPE_SAFETY_FLAGS)" >&5
printf "%s\n" "$as_me: WARNING: unable to compile C with FPE safety flag ($CC $ACSM_FPE_SAFETY_FLAGS)" >&2;}
ACSM_FPE_SAFETY_FLAGS=""

fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CFLAGS="$ac_fpe_safety_save_CFLAGS"
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


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

ac_fpe_safety_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="${CXXFLAGS} ${ACSM_FPE_SAFETY_FLAGS}"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main (void)
{

;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :

else $as_nop

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unable to compile C++ with FPE safety flag ($CXX $ACSM_FPE_SAFETY_FLAGS)" >&5
printf "%s\n" "$as_me: WARNING: unable to compile C++ with FPE safety flag ($CXX $ACSM_FPE_SAFETY_FLAGS)" >&2;}
ACSM_FPE_SAFETY_FLAGS=""

fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CXXFLAGS="$ac_fpe_safety_save_CXXFLAGS"
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


if test "x$ACSM_FPE_SAFETY_FLAGS" != "x"
then :

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< Adding $ACSM_FPE_SAFETY_FLAGS for FPE safety >>>" >&5
printf "%s\n" "<<< Adding $ACSM_FPE_SAFETY_FLAGS for FPE safety >>>" >&6; }

else $as_nop

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< No flags found to use for FPE safety >>>" >&5
printf "%s\n" "<<< No flags found to use for FPE safety >>>" >&6; }

fi
ACSM_CXXFLAGS_OPT="$ACSM_CXXFLAGS_OPT $ACSM_FPE_SAFETY_FLAGS"
ACSM_CXXFLAGS_DBG="$ACSM_CXXFLAGS_DBG $ACSM_FPE_SAFETY_FLAGS"
ACSM_CXXFLAGS_DEVEL="$ACSM_CXXFLAGS_DEVEL $ACSM_FPE_SAFETY_FLAGS"

ACSM_CFLAGS_OPT="$ACSM_CFLAGS_OPT $ACSM_FPE_SAFETY_FLAGS"
ACSM_CFLAGS_DBG="$ACSM_CFLAGS_DBG $ACSM_FPE_SAFETY_FLAGS"
ACSM_CFLAGS_DEVEL="$ACSM_CFLAGS_DEVEL $ACSM_FPE_SAFETY_FLAGS"

else $as_nop

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: <<< Not enabling flags for FPE safety >>>" >&5
printf "%s\n" "<<< Not enabling flags for FPE safety >>>" >&6; }

fi


CXXFLAGS_OPT="$ACSM_CXXFLAGS_OPT"
CXXFLAGS_DEVEL="$ACSM_CXXFLAGS_DEVEL"
CXXFLAGS_DBG="$ACSM_CXXFLAGS_DBG"
Expand Down
2 changes: 1 addition & 1 deletion contrib/timpi
2 changes: 1 addition & 1 deletion m4/autoconf-submodule
2 changes: 2 additions & 0 deletions m4/compiler.m4
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ AC_DEFUN([LIBMESH_SET_BUILD_FLAGS],
ACSM_SET_GLIBCXX_DEBUG_FLAGS
ACSM_SET_FPE_SAFETY_FLAGS
CXXFLAGS_OPT="$ACSM_CXXFLAGS_OPT"
CXXFLAGS_DEVEL="$ACSM_CXXFLAGS_DEVEL"
CXXFLAGS_DBG="$ACSM_CXXFLAGS_DBG"
Expand Down

0 comments on commit d47c86f

Please sign in to comment.