diff --git a/configure b/configure index 7624cbf0d2ae3d..13a2ae0b5a72a3 100755 --- a/configure +++ b/configure @@ -9434,9 +9434,18 @@ printf "%s\n" "$BOLT_APPLY_FLAGS" >&6; } # compiler and platform. BASECFLAGS tweaks need to be made even if the # user set OPT. -save_CFLAGS=$CFLAGS -CFLAGS="-fstrict-overflow -fno-strict-overflow" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports -fstrict-overflow and -fno-strict-overflow" >&5 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-strict-overflow" >&5 +printf %s "checking for --with-strict-overflow... " >&6; } + +# Check whether --with-strict-overflow was given. +if test ${with_strict_overflow+y} +then : + withval=$with_strict_overflow; + if test "x$with_strict_overflow" = xyes +then : + save_CFLAGS=$CFLAGS + CFLAGS="-fstrict-overflow -fno-strict-overflow" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports -fstrict-overflow and -fno-strict-overflow" >&5 printf %s "checking if $CC supports -fstrict-overflow and -fno-strict-overflow... " >&6; } if test ${ac_cv_cc_supports_fstrict_overflow+y} then : @@ -9458,42 +9467,40 @@ then : ac_cv_cc_supports_fstrict_overflow=yes else case e in #( e) ac_cv_cc_supports_fstrict_overflow=no - ;; + ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; + ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cc_supports_fstrict_overflow" >&5 printf "%s\n" "$ac_cv_cc_supports_fstrict_overflow" >&6; } -CFLAGS=$save_CFLAGS + CFLAGS=$save_CFLAGS -if test "x$ac_cv_cc_supports_fstrict_overflow" = xyes + if test "x$ac_cv_cc_supports_fstrict_overflow" = xyes then : STRICT_OVERFLOW_CFLAGS="-fstrict-overflow" - NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow" + NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow" else case e in #( - e) STRICT_OVERFLOW_CFLAGS="" - NO_STRICT_OVERFLOW_CFLAGS="" ;; + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --with-strict-overflow=yes requires a compiler that supports -fstrict-overflow" >&5 +printf "%s\n" "$as_me: WARNING: --with-strict-overflow=yes requires a compiler that supports -fstrict-overflow" >&2;} + STRICT_OVERFLOW_CFLAGS="" + NO_STRICT_OVERFLOW_CFLAGS="" ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-strict-overflow" >&5 -printf %s "checking for --with-strict-overflow... " >&6; } - -# Check whether --with-strict-overflow was given. -if test ${with_strict_overflow+y} -then : - withval=$with_strict_overflow; - if test "x$ac_cv_cc_supports_fstrict_overflow" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --with-strict-overflow=yes requires a compiler that supports -fstrict-overflow" >&5 -printf "%s\n" "$as_me: WARNING: --with-strict-overflow=yes requires a compiler that supports -fstrict-overflow" >&2;} +else case e in #( + e) STRICT_OVERFLOW_CFLAGS="" + NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow" + ;; +esac fi else case e in #( e) with_strict_overflow=no + STRICT_OVERFLOW_CFLAGS="" + NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow" ;; esac fi diff --git a/configure.ac b/configure.ac index 7a7e32d42945b9..518ba5735f84a8 100644 --- a/configure.ac +++ b/configure.ac @@ -2221,28 +2221,6 @@ AC_MSG_RESULT([$BOLT_APPLY_FLAGS]) # compiler and platform. BASECFLAGS tweaks need to be made even if the # user set OPT. -dnl Historically, some of our code assumed that signed integer overflow -dnl is defined behaviour via twos-complement. -dnl Set STRICT_OVERFLOW_CFLAGS and NO_STRICT_OVERFLOW_CFLAGS depending on compiler support. -dnl Pass the latter to modules that depend on such behaviour. -_SAVE_VAR([CFLAGS]) -CFLAGS="-fstrict-overflow -fno-strict-overflow" -AC_CACHE_CHECK([if $CC supports -fstrict-overflow and -fno-strict-overflow], - [ac_cv_cc_supports_fstrict_overflow], - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[]], [[]])], - [ac_cv_cc_supports_fstrict_overflow=yes], - [ac_cv_cc_supports_fstrict_overflow=no] - ) -) -_RESTORE_VAR([CFLAGS]) - -AS_VAR_IF([ac_cv_cc_supports_fstrict_overflow], [yes], - [STRICT_OVERFLOW_CFLAGS="-fstrict-overflow" - NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow"], - [STRICT_OVERFLOW_CFLAGS="" - NO_STRICT_OVERFLOW_CFLAGS=""]) - AC_MSG_CHECKING([for --with-strict-overflow]) AC_ARG_WITH([strict-overflow], AS_HELP_STRING( @@ -2251,12 +2229,37 @@ AC_ARG_WITH([strict-overflow], ), [ AS_VAR_IF( - [ac_cv_cc_supports_fstrict_overflow], [no], - [AC_MSG_WARN([--with-strict-overflow=yes requires a compiler that supports -fstrict-overflow])], - [] + [with_strict_overflow], [yes], + [dnl Historically, some of our code assumed that signed integer overflow + dnl is defined behaviour via twos-complement. + dnl Set STRICT_OVERFLOW_CFLAGS and NO_STRICT_OVERFLOW_CFLAGS depending on compiler support. + dnl Pass the latter to modules that depend on such behaviour. + _SAVE_VAR([CFLAGS]) + CFLAGS="-fstrict-overflow -fno-strict-overflow" + AC_CACHE_CHECK([if $CC supports -fstrict-overflow and -fno-strict-overflow], + [ac_cv_cc_supports_fstrict_overflow], + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [ac_cv_cc_supports_fstrict_overflow=yes], + [ac_cv_cc_supports_fstrict_overflow=no] + ) + ) + _RESTORE_VAR([CFLAGS]) + + AS_VAR_IF([ac_cv_cc_supports_fstrict_overflow], [yes], + [STRICT_OVERFLOW_CFLAGS="-fstrict-overflow" + NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow"], + [AC_MSG_WARN([--with-strict-overflow=yes requires a compiler that supports -fstrict-overflow]) + STRICT_OVERFLOW_CFLAGS="" + NO_STRICT_OVERFLOW_CFLAGS=""]) + ], + [STRICT_OVERFLOW_CFLAGS="" + NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow"] ) ], - [with_strict_overflow=no] + [with_strict_overflow=no + STRICT_OVERFLOW_CFLAGS="" + NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow"] ) AC_MSG_RESULT([$with_strict_overflow])