diff --git a/configure b/configure index eca5f03cdcfb2d..ca61aeaa1886ee 100755 --- a/configure +++ b/configure @@ -9472,15 +9472,25 @@ 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 "checking if $CC supports -fstrict-overflow and -fno-strict-overflow... " >&6; } -if test ${ac_cv_cc_supports_fstrict_overflow+y} +{ 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 : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fstrict-overflow" >&5 +printf %s "checking whether C compiler accepts -fstrict-overflow... " >&6; } +if test ${ax_cv_check_cflags___fstrict_overflow+y} then : printf %s "(cached) " >&6 else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext + e) + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -fstrict-overflow" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -9493,45 +9503,84 @@ main (void) _ACEOF if ac_fn_c_try_compile "$LINENO" then : - ac_cv_cc_supports_fstrict_overflow=yes + ax_cv_check_cflags___fstrict_overflow=yes else case e in #( - e) ac_cv_cc_supports_fstrict_overflow=no - ;; + e) ax_cv_check_cflags___fstrict_overflow=no ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; + CFLAGS=$ax_check_save_flags ;; 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 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fstrict_overflow" >&5 +printf "%s\n" "$ax_cv_check_cflags___fstrict_overflow" >&6; } +if test "x$ax_cv_check_cflags___fstrict_overflow" = xyes +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fno-strict-overflow" >&5 +printf %s "checking whether C compiler accepts -fno-strict-overflow... " >&6; } +if test ${ax_cv_check_cflags___fno_strict_overflow+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -fno-strict-overflow" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -if test "x$ac_cv_cc_supports_fstrict_overflow" = xyes +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ax_cv_check_cflags___fno_strict_overflow=yes +else case e in #( + e) ax_cv_check_cflags___fno_strict_overflow=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS=$ax_check_save_flags ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fno_strict_overflow" >&5 +printf "%s\n" "$ax_cv_check_cflags___fno_strict_overflow" >&6; } +if test "x$ax_cv_check_cflags___fno_strict_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 -fno-strict-overflow" >&5 +printf "%s\n" "$as_me: WARNING: --with-strict-overflow=yes requires a compiler that supports -fno-strict-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 +else case e in #( + 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 + + +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 c21024a1e77433..564e058a6d6644 100644 --- a/configure.ac +++ b/configure.ac @@ -2235,28 +2235,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( @@ -2265,12 +2243,29 @@ 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. + AX_CHECK_COMPILE_FLAG([-fstrict-overflow], + [AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], + [STRICT_OVERFLOW_CFLAGS="-fstrict-overflow" + NO_STRICT_OVERFLOW_CFLAGS="-fno-strict-overflow"], + [AC_MSG_WARN([--with-strict-overflow=yes requires a compiler that supports -fno-strict-overflow]) + STRICT_OVERFLOW_CFLAGS="" + NO_STRICT_OVERFLOW_CFLAGS=""])], + [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])